Hi! I am trying to do the following stored procedure in oracle 8. The proc. is:
CREATE OR REPLACE PROCEDURE INSERTBLKHEADER(
v_fkey IN callblockheader.pk_sourcefile%type,
v_bSNum IN callblockheader.blockserialnumber%type,
v_bCount IN callblockheader.blockcount%type,
v_fOffset IN callblockheader.fileoffset%type,
v_id OUT NUMBER)
AS
BEGIN
INSERT INTO CallBlockHeader (pk_blockheader,
pk_sourceFile, blockSerialNumber, blockCount,
fileOffset)
VALUES(callblockheader_seq.nextval, v_fkey,
v_bSNum, v_bCount, v_fOffset);
COMMIT;
SELECT pk_blockheader into v_id
FROM callblockheader
WHERE pk_blockheader =
CallBlockHeader_Seq.currval;
END;
/
My problem:
1. I compile the above code and it compiles!
2. In SQL * PLUS, I say:
execute insertblkheader(10,10,10,10); I get the foll. error msg. (Note: The input parameters are all number data types (number(10) - to be specific)
BEGIN insertblkheader(10,10,10,10); END;
*
ERROR at line 1:
ORA-06550: line 1, column 7:
PLS-00306: wrong number or types of arguments in call to 'INSERTBLKHEADER'
ORA-06550: line 1, column 7:
PL/SQL: Statement ignored
Can someone please point where I am going wrong - am i executing it wrong at SQL PLUS prompt?
This stored procedure is being accessed from Visual C++ and the program is expecting to get the value of the v_id parameter.
As the error message says, you are providing the wrong number of arguments. Your procedure has five arguments; you are only passing four! You must provide a variable for v_id.
If i do as you say then, I get this msg. its b'cos v_id is an OUT type parameter.
SQL> execute insertblkheader(2,2,2,2,2);
BEGIN insertblkheader(2,2,2,2,2); END;
*
ERROR at line 1:
ORA-06550: line 1, column 31:
PLS-00363: expression '2' cannot be used as an assignment target
ORA-06550: line 1, column 7:
PL/SQL: Statement ignored
In the above, when they do "select @id = @@identity", they are returning the value to the calling front-end program in Visual C++. I am trying to do the same thing in oracle. The @id is an output parameter.
Am i doing the right stuff in my stored proc. in PL/SQL or am i totally messing up?
Please advise.
I havent read any of the replies. Just read your prob and giving the possible solution.
Try running the following piece of code in SQL*PLUS :
(Set ServerOutPut ON)
DECLARE
OptValue NUMBER ;
BEGIN
Exec insertblkheader(10,10,10,10, OptValue);
DBMS_OUTPUT.PUT_LINE('Value Returned Is : '||OptValue) ;
END ;
This should work. Your procedure has 4 input parameters and 1 output parameter. So total 5 parameters. You need to specify the 5th output parameter, the parameter in which your output value will be stored.
Bookmarks