plsql - pl /sql procedure execution giving an error -
my stored proc defined as
create or replace procedure test( name in table1.col_name%type, price in table1.col_price%type ) begin update table1 t set t.name =name t.price = price; commit; end test; i trying execute as
exec test(name => 'john', price => 1000); however, gives invalid sql error. missing here?
your input parameter %type statements claim column names col_name , col_price. not how refer them in stored procedure (name , price).
bad things can happen when name variables after column names. asktom recommends limited convention of variable naming conventions:
- local variables start
l_ - parameters start
p_ - global package variables start
g_
that link has general discussion on pl/sql naming conventions. use v_ variables (aside indexes , other obvious things), that's me.
lastly, col_ in column names seem redundant; use name , price column names.
so, said, think want:
create table table1 ( name varchar2(30), price number ); create or replace procedure test( p_name in table1.name%type, p_price in table1.price%type ) begin update table1 set name = p_name price = p_price; commit; end test; / insert table1 values ('john', 500); commit; select * table1; exec test(p_name => 'bob', p_price => 500); select * table1; -- clean test artifacts drop procedure test; drop table table1; giving output:
table table1 created. procedure test compiled 1 rows inserted. committed. name price ------------------------------ ---------- john 500 anonymous block completed name price ------------------------------ ---------- bob 500 procedure test dropped. table table1 dropped.
Comments
Post a Comment