oracle 存储过程中查询结果无法赋值到变量,请指教
现有一表格local_xx,内有信息若干,要统计总数并且赋值到一个新的表格TEST中,代码如下,但新表格内没有数据,请问该如何修改?CREATEORREPLACEPROC...
现有一表格local_xx,内有信息若干,要统计总数并且赋值到一个新的表格TEST中,代码如下,但新表格内没有数据,请问该如何修改?
CREATE OR REPLACE PROCEDURE test1
IS
tmpVar NUMBER;
strSQL VARCHAR2 (2000);
BEGIN
strSQL := 'drop table test';
EXECUTE IMMEDIATE strSQL;
strSQL := 'CREATE TABLE DDCXD.test(bh NUMBER)';
EXECUTE IMMEDIATE strSQL;
strSQL := 'select count(*) from local_xx';
EXECUTE IMMEDIATE strSQL into tmpVar ;
strSQL := 'insert into test values(' || tmpVar || ')';
EXECUTE IMMEDIATE strSQL;
END test1; 展开
CREATE OR REPLACE PROCEDURE test1
IS
tmpVar NUMBER;
strSQL VARCHAR2 (2000);
BEGIN
strSQL := 'drop table test';
EXECUTE IMMEDIATE strSQL;
strSQL := 'CREATE TABLE DDCXD.test(bh NUMBER)';
EXECUTE IMMEDIATE strSQL;
strSQL := 'select count(*) from local_xx';
EXECUTE IMMEDIATE strSQL into tmpVar ;
strSQL := 'insert into test values(' || tmpVar || ')';
EXECUTE IMMEDIATE strSQL;
END test1; 展开
展开全部
你最后没commit
CREATE OR REPLACE PROCEDURE test1
IS
tmpVar NUMBER;
strSQL VARCHAR2 (2000);
BEGIN
strSQL := 'drop table test';
EXECUTE IMMEDIATE strSQL;
strSQL := 'CREATE TABLE DDCXD.test(bh NUMBER)';
EXECUTE IMMEDIATE strSQL;
strSQL := 'select count(*) from local_xx';
EXECUTE IMMEDIATE strSQL into tmpVar ;
strSQL := 'insert into test values(' || tmpVar || ')';
EXECUTE IMMEDIATE strSQL;
commit;
END test1;
这样就行了
CREATE OR REPLACE PROCEDURE test1
IS
tmpVar NUMBER;
strSQL VARCHAR2 (2000);
BEGIN
strSQL := 'drop table test';
EXECUTE IMMEDIATE strSQL;
strSQL := 'CREATE TABLE DDCXD.test(bh NUMBER)';
EXECUTE IMMEDIATE strSQL;
strSQL := 'select count(*) from local_xx';
EXECUTE IMMEDIATE strSQL into tmpVar ;
strSQL := 'insert into test values(' || tmpVar || ')';
EXECUTE IMMEDIATE strSQL;
commit;
END test1;
这样就行了
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询