oracle - in sql merge syntax how to pass userparameter -


i getting error:bind variable "a" not declared

merge emp e1 using  (select e2.empno,e2.sal emp2 e2 e2.empno=:a) on (e1.empno=e2.empno) when matched update set e1.sal=e2.sal when not matched insert values(e2.empno,e2.ename,e2.job,e2.mgr,e2.hiredate,e2.sal,e2.comm,e2.deptno); 

if you're in sql*plus (as suspect error message given),

variable number exec :a := 5 

before try run merge statement.

on other hand, if you're running statement in pl/sql, there no need use colon, instead, place variable name instead:

procedure do_the_merge(a in number) begin    merge....          ....       e2.empno =         ....;  end do_the_merge; 

Comments

Popular posts from this blog

python - Scipy curvefit RuntimeError:Optimal parameters not found: Number of calls to function has reached maxfev = 1000 -

c# - How to add a new treeview at the selected node? -

java - netbeans "Please wait - classpath scanning in progress..." -