直接用变量就行了。sqlstr varchar2(200)for i:=0 to 9 loop sqlstr:='select tradedate,creditedCharge into o_date'||to_char(i+1)||', o_moneydate'||to_char(i+1)||' from gdb_b_epptradeinfo b where b.seqno = '||to_char(i);execute immediate sqlstr;end loop;...
EXECUTE IMMEDIATE query_stat into l_djjcxx usingl_jh; DBMS_OUTPUT.put_line(l_djjcxx.zyq); end TEST_TABLE; query_stat里面如果写成 select zyq into l_zyq from '|| l_table_name||' wherejh=:l_jh' 会报错。标红的都是要注意的地方。
EXECUTEIMMEDIATE语句的语法如下: EXECUTE IMMEDIATE dynamic_sql_statement INTO variable1 [, variable2, ...]; dynamic_sql_statement是要执行的SQL语句,可以是任何合法的SQL语句,包括DML语句(INSERT、UPDATE、DELETE)、DDL语句(CREATE、ALTER、DROP)和PL/SQL块。 INTO子句是可选的,用于将执行结果保存到变量中。如...
EXECUTE_IMMEDIATE允许在一个PL/SQL块中动态执行任何有效的SQL或PL/SQL语句。它允许通过字符串形式指定SQL语句,从而实现动态生成和执行SQL语句的目的。 EXECUTE_IMMEDIATE语句的基本语法如下: EXECUTE_IMMEDIATE (sql_statement [INTO { define_variable[, define_variable]..., record_variable}] [USING [in , out ...
execute immediate 'insert into dept values (:1, :2, :3)' using 50, l_depnam, l_loc; commit;end;3. 从动态语句检索值(INTO子句)declare l_cnt varchar2(20);begin execute immediate 'select count(1) from emp' into l_cnt; dbms_output.put_line(l_cnt);end;4. 动态调用例程.例程中用到...
我对execute immediate语句中的"dynamic using子句“有疑问。我需要动态设置"execute immediate语句“和using子句。所以我编写了一个函数(通过user_tab_columns和user user_constraints表),用update语句和bind_variable设置变量,但现在我需要用变量列表设置using子句-- that returns sqlstring:='update tabl 浏览0提问于201...
execute immediate 'insert into dept val s (:1, :2, :3)' using 50, l_depnam, l_loc; commit; end; 3. 从动态语句检索值(INTO子句) Sql代码 declare l_cnt varchar2(20); begin execute immediate 'select count(1) from emp' into l_cnt; ...
EXECUTEIMMEDIATE语句的基本语法如下: ``` EXECUTE IMMEDIATE dynamic_query_string [USING bind_argument_list] [INTO {variable_list , record}] [RETURNING INTO bind_argument_list]; ``` 动态查询字符串dynamic_query_string可以包含任何合法的SQL语句,包括SELECT、INSERT、UPDATE和DELETE语句以及所有其他DDL和DML语...
Execute Immediate代替了以前Oracle8i中DBMS_SQL package包。它解析并马上执行动态的SQL语句或非运行时创建...
execute immediate 'insert into dept vals (:1, :2, :3)' using 50, l_depnam, l_loc; commit; end; 1. 2. 3. 4. 5. 6. 7. 8. 3. 从动态语句检索值(INTO子句) Sql代码 declare l_cnt varchar2(20); begin execute immediate 'select count(1) from emp' ...