读书人

在PL/SQL中怎么把两个 Update 连起来

发布时间: 2012-02-17 17:50:42 作者: rapoo

在PL/SQL中,如何把两个 Update 连起来??????
在PL/SQL中,我想把两个Update 连起来一起处理。
Update T_GD_WAREBASE Set WareQty = WareQty - 10 where MateNo = '11 '
Update T_GD_WAREBASE Set WareQty = WareQty - 10 where MateNo = '12 '

我是这样做的:
Update T_GD_WAREBASE Set WareQty = WareQty - 10 where MateNo = '11 ';Update T_GD_WAREBASE Set WareQty = WareQty - 10 where MateNo = '12 ';

它老提示:ORA-00911:无效字符

请问应该怎样做呢?

[解决办法]
自己看测试结果:
create table T_GD_WAREBASE(WareQty number,
2 MateNo number);

Table created

SQL> insert into T_GD_WAREBASE select 100,11 from dual;

1 row inserted

SQL> insert into T_GD_WAREBASE select 120,12 from dual;

1 row inserted

SQL> commit;

Commit complete

SQL> select * from T_GD_WAREBASE;

WAREQTY MATENO
---------- ----------
100 11
120 12

SQL> create or replace procedure pro_test1
2 is
3 var_sql varchar2(8000);
4 begin
5 var_sql := 'begin
6 ';
7 var_sql := var_sql || 'Update T_GD_WAREBASE Set WareQty = WareQty - 10 where
8 MateNo = ' '11 ' ';
9 Update T_GD_WAREBASE Set WareQty = WareQty - 10 where MateNo
10 = ' '12 ' '; ';
11 var_sql := var_sql || '
12 end;
13 ';
14 execute immediate var_sql;
15 commit;
16 end;
17 /

Procedure created

SQL> execute pro_test1;

PL/SQL procedure successfully completed

SQL> select * from T_GD_WAREBASE;

WAREQTY MATENO
---------- ----------
90 11
110 12

读书人网 >oracle

热点推荐