兄弟试写的一个procedure
首先判断是否存在记录,存在记录的话update表格
create or replace procedure transfer_terminal (
mer_id in terminal_east.merchantid% type,
ter_id in terminal_east.terminalid% type)
cursor cur_terminal is select * from (select * from terminal_east union select * from terminal_west@west)
as 
if ( exists(select * from (select * from merchant_east union select * from merchant_west@west) where merchantid = mer_id))
begin
update cur_terminal
set merchantid = mer_id
where terminalid = ter_id
end;但是报错Error(5,1): PLS-00103: Encountered the symbol "CURSOR" when expecting one of the following:     ; is with authid as cluster order using external    deterministic parallel_enable pipelined 
不知道怎么回事

解决方案 »

  1.   

    1.分布式数据库,建议建立同义词访问表。
    2.不建议采用游标处理,直接采用sql判断。
      

  2.   

    你语法格式好多不对阿。再看下基础的地方。
    给你排个版,但是你update游标。这不叫程序阿。。create or replace procedure transfer_terminal (
    mer_id in terminal_east.merchantid% type,
    ter_id in terminal_east.terminalid% type)
    cursor cur_terminal is select * from (select * from terminal_east union select * from terminal_west@west)
    as
    if ( exists(select * from (select * from merchant_east union select * from merchant_west@west) where merchantid = mer_id))
    begin
    update cur_terminal
    set merchantid = mer_id
    where terminalid = ter_id
    end; 
      

  3.   

    create or replace procedure transfer_terminal(mer_id in terminal_east.merchantid% type,
                                                  ter_id in terminal_east.terminalid% type) is
      cursor cur_terminal is
        select *
          from (select *
                  from terminal_east
                union
                select * from terminal_west@west);
    begin
      if exists (select *
            from (select *
                    from merchant_east
                  union
                  select * from merchant_west@west)
           where merchantid = mer_id)) then
        update cur_terminal set merchantid = mer_id where terminalid = ter_id;
      end if;
    end;
      

  4.   

    INSERT 或者 UPDATE 可以考虑用MERGE
      

  5.   

    其实问题这样的
    假设有一分布式数据库(东,西区)各有2个表格terminal(terminalid, merchantid), 及merchant(merchantid)
    现需移动terminal, 例如将terminalid = 1, merchantid = 1 的数据,更新为 terminalid = 1, merchantid = 2 
    首先需要判断merchantid=2这条记录是否存在,如存在,则更新。
    这样的procedure应该怎么写啊?或者有其他的实现方法?
      

  6.   

    不明白更新哪个表的merchantid阿,“首先需要判断merchantid=2这条记录是否存在,如存在,则更新。 ‘这句是啥意思,判断merchantid=1这条记录是否存在的意思?
      

  7.   

    需要更新表terminal,将terminal中的merchantidid更新,但是需要判断更新的merchantidid是否存在于merchant表中