:1在动态sql中是什么意思

时间:2019-02-06 08:48:28

标签: oracle plsql dynamic-sql

vsql='select ename into y from emp where empno=:1'

:1在这里是什么意思?

1 个答案:

答案 0 :(得分:5)

这是您要使用的参数值的 占位符

例如:

SQL> set serveroutput on
SQL> declare
  2    l_empno number := 7902;
  3    v_sql   varchar2(200);
  4    l_ename varchar2(20);
  5  begin
  6    v_sql := 'select ename from emp where empno = :1';
  7    execute immediate v_sql into l_ename using l_empno;   --> this
  8    dbms_output.put_line(l_ename);
  9  end;
 10  /
FORD

PL/SQL procedure successfully completed.

SQL>