oracle存储过程语法二

来源:互联网 发布:淘宝代销邮费算谁的 编辑:程序博客网 时间:2024/04/29 14:07
type typeaaaa is record(
     column1        table1.column1%type,     
     column2        table1.column2%TYPE,
     column3        table1.column3%type,
     column4        table1.column4%TYPE
      );

   record1 typeaaaa;
   
   cursor cur_info is
          SELECT column1, column2, column3, column4
            FROM table1 A;
   
   BEGIN
 
 open cur_info;
 fetch cur_info into record1;
 while (cur_info%found) LOOP
 
 UPDATE (SELECT TD.a1,
               TD.a2,
               TD.a3,
               B.ba1,
               B.ba2,
               B.ba3
          FROM table_a TD, table_b B
         WHERE TD.no = B.no
           AND TD.date = B.date)
   SET a1 = ba1, a2 = ba2, a3 = ba3;
   
   
   UPDATE table1 A
      SET column1   = 1,
          column2 = '2',
          column3      = 0
    WHERE NOT EXISTS (SELECT NULL
             FROM table2 B
            WHERE A.no = B.no
              AND A.date = B.date)
      AND column1 = 'xxxxx';
   
   
    MERGE INTO tablea AA
 USING (SELECT column1, column2,column3
          FROM tableb) BB
 ON (AA.column1 = BB.column1 AND AA.column2 = BB.column2 AND AA.column3 = BB.column3)
 WHEN MATCHED THEN
   UPDATE
      SET AA.column5    = BB.column5,
          AA.column6 = BB.column6;

   fetch cur_info into record1;
  end loop;
   

0 0
原创粉丝点击