declare
v_dwbh number;
begin
select max(dwbh)+1 into v_dwbh from jc_dwml;
insert into jc_dwml (dwbh, dwdm, tydm, dwmc, dwsxbh, qhlxbh, dgbz, zzflbh)
values (v_dwbh,'30439573095','44000001000011', '广东省公安厅办公室', 1, 2, '0', 1)end;
/
v_dwbh number;
begin
select max(dwbh)+1 into v_dwbh from jc_dwml;
insert into jc_dwml (dwbh, dwdm, tydm, dwmc, dwsxbh, qhlxbh, dgbz, zzflbh)
values (v_dwbh,'30439573095','44000001000011', '广东省公安厅办公室', 1, 2, '0', 1)end;
/
SELECT语句本身是一条记录集,用INSERT INTO .... SELECT ....就可以了。
如果用VALUES就不能用SELECT。insert into jc_dwml (dwbh, dwdm, tydm, dwmc, dwsxbh, qhlxbh, dgbz, zzflbh)
select max(dwbh)+1,'30439573095', '44000001000011', '广东省公安厅办公室', 1, 2, '0', 1
from jc_dwml ;
insert into jc_dwml (dwbh, dwdm, tydm, dwmc, dwsxbh, qhlxbh, dgbz, zzflbh) values ((select max(dwbh)+1 dwbh from jc_dwml), '30439573095', '44000001000011', '广东省公安厅办公室', 1, 2, '0', 1)行begin insert into jc_dwml (dwbh, dwdm, tydm, dwmc, dwsxbh, qhlxbh, dgbz, zzflbh) values ((select max(dwbh)+1 dwbh from jc_dwml), '30439573095', '44000001000011', '广东省公安厅办公室', 1, 2, '0', 1);end;就不行呢错误代码如下ORA-06550: 第 1 行, 第 91 列:
PLS-00103: 出现符号 "SELECT"在需要下列之一时:
(-+modnotnullothers
<an identifier><a double-quoted delimited-identifier>
<a bind variable>avgcountcurrentexistsmaxminpriorsqlstddev
sumvarianceexecuteforalltimetimestampintervaldate
<a string literal with character set specification>
<a number><a single-quoted SQL string>
ORA-06550: 第 1 行, 第 128 列:
PLS-00103: 出现符号 ","在需要下列之一时:
;returnreturningandor
ORA-06550: 第 1 行, 第 199 列:
PLS-00103: 出现符号 "END"在需要下列之一时:
beginfunctionpackagepragma
proceduresubtypetypeuse<an identifier>
<a double-quoted delimited-identifier>cursorformcurrent
begin
insert into jc_dwml (dwbh, dwdm, tydm, dwmc, dwsxbh, qhlxbh, dgbz, zzflbh)
values ((select max(dwbh)+1 dwbh from jc_dwml),
'30439573095', '44000001000011', '广东省公安厅办公室', 1, 2, '0', 1);
end;
我在9i里面完全按照你的sql做,一点问题没有
pl/sql developer 版本:5.1.4.729
PL/SQL Developer Version 5.0.1.480
Integration of SQL and PL/SQL parsers PL/SQL now supports the complete range of syntax for SQL statements, such as INSERT, UPDATE, DELETE, SELECT, and so on. If you received errors for valid SQL syntax in PL/SQL programs before, those statements should now work