plsql - Issue using bind variables in PL\SQL script -


i trying use bind variables in oracle procedure , running error. below code using:

declare sql_stmt        varchar2(4000); parm1           varchar2(100); parm2           varchar2(100); parm3           varchar2(100); parm4           varchar2(100);  begin parm1   := 'test1'; parm2   := 'test2'; parm3   := 'test3'; parm4   := 'test4';  sql_stmt :=  ‘exec process_archive.start_processarchive(chr(39)||:1||chr(39),null, chr(39)||:2||chr(39), chr(39)||:3||chr(39), chr(39)||:4||chr(39))’; execute immediate sql_stmt using parm1,parm2,parm3,parm4;  end; / 

when executes, error: "sp-0552:bind variable "4" not declared". beginner pl\sql still learning cannot figure out error coming from. appreciated. thank you.

this works me...

create or replace procedure testproc(a varchar2,                                      b varchar2 default null,                                      c varchar2,                                      d varchar2,                                      e varchar2) begin     dbms_output.put_line('a: '||a);     dbms_output.put_line('b: '||b);     dbms_output.put_line('c: '||c);     dbms_output.put_line('d: '||d);     dbms_output.put_line('e: '||e); end; /  declare     sql_stmt varchar2(4000);     parm1 varchar2(100);     parm2 varchar2(100);     parm3 varchar2(100);     parm4 varchar2(100); begin     parm1 := 'test1';     parm2 := 'test2';     parm3 := 'test3';     parm4 := 'test4';      sql_stmt :=  'begin testproc(:1, null, :2, :3, :4); end;';     execute immediate sql_stmt using in parm1, in parm2, in parm3, in parm4; end; / 

results in...

a: test1 b: c: test2 d: test3 e: test4 

Comments

Popular posts from this blog

php - Wordpress website dashboard page or post editor content is not showing but front end data is showing properly -

How to get the ip address of VM and use it to configure SSH connection dynamically in Ansible -

javascript - Get parameter of GET request -