47

I'm trying to run this stored procedure

DECLARE
  P_TICKER_SERIAL VARCHAR2(200);
  P_SECTOR_CODE   VARCHAR2(200);
  P_SOURCE_ID     VARCHAR2(200);
  P_COUNTRY_CODE  VARCHAR2(200);
  P_FILTER_TYPE   NUMBER;
  CUR_OUT         SYS_REFCURSOR;
  dbUserTable     DBUSER%ROWTYPE;
BEGIN
  P_TICKER_SERIAL :='14232';
  P_SECTOR_CODE   := '15';
  P_SOURCE_ID     := 'TDWL';
  P_COUNTRY_CODE  := 'SA';
  P_FILTER_TYPE   := 1;

  PKG_name.GET_user(
    P_TICKER_SERIAL => P_TICKER_SERIAL,
    P_SECTOR_CODE   => P_SECTOR_CODE,
    P_SOURCE_ID     => P_SOURCE_ID,
    P_COUNTRY_CODE  => P_COUNTRY_CODE,
    P_FILTER_TYPE   => P_FILTER_TYPE,
    CUR_OUT         => CUR_OUT
  );
  open CUR_OUT;
  LOOP
    FETCH CUR_OUT INTO dbUserTable;
    dbms_output.put_line(dbUserTable.email);
  END LOOP;
  CLOSE CUR_OUT;
END;
 /

But it gives me this error

Error report:
ORA-06550: line 8, column 15:
PLS-00201: identifier 'DBUSER' must be declared
ORA-06550: line 8, column 15:
PL/SQL: Item ignored
ORA-06550: line 24, column 2:
PLS-00382: expression is of wrong type
ORA-06550: line 24, column 2:
PL/SQL: SQL Statement ignored
ORA-06550: line 26, column 24:
PLS-00320: the declaration of the type of this expression is incomplete or malformed
ORA-06550: line 26, column 5:
PL/SQL: SQL Statement ignored
ORA-06550: line 27, column 28:
PLS-00320: the declaration of the type of this expression is incomplete or malformed
ORA-06550: line 27, column 7:
PL/SQL: Statement ignored
06550. 00000 -  "line %s, column %s:\n%s"
*Cause:    Usually a PL/SQL compilation error.
*Action:

Any one knows what is wrong ? Thanks.

2
  • CUR_OUT represent multi rows not a single value . Commented Nov 25, 2013 at 7:27
  • 1) The GET_user procedure, most likely, opens the cursor, there is no need to open it again(cause of the PLS-00382 error) - remove open CUR_OUT statement; 2) You would need an exit loop condition exit when CUR_OUT%notfound for instance, if you do not want to hang your session forever. Commented Nov 25, 2013 at 7:55

4 Answers 4

72

Try to execute the procedure like this,

var c refcursor;
execute pkg_name.get_user('14232', '15', 'TDWL', 'SA', 1, :c);
print c;
Sign up to request clarification or add additional context in comments.

9 Comments

thanks for your quick reply but it give me this error : Bind Variable "c" is NOT DECLARED anonymous block completed
@Samy Louize Hanna, Before executing the proceudre, you need to run var c refcursor This mechanism is for assigning values to a variable.
Error starting at line 3 in command: execute pkg_name.get_user('14232', '15', 'TDWL', 'SA', 1, :c) Error report: ORA-00904: "TDWL": invalid identifier ORA-06512: at "schema.PKG_name", line 156 ORA-06512: at line 1 00904. 00000 - "%s: invalid identifier" *Cause: *Action: Line 156 doesn't refer to my stored procedure
@Samy Louize Hanna, The error message looks like, there is something wrong with your procedure code.
Line 156 doesn't refer to my stored procedure
|
11

Consider you've created a procedure like below.

CREATE OR REPLACE PROCEDURE GET_FULL_NAME like
(
  FIRST_NAME IN VARCHAR2, 
  LAST_NAME IN VARCHAR2,
  FULL_NAME OUT VARCHAR2 
) IS 
BEGIN
  FULL_NAME:= FIRST_NAME || ' ' || LAST_NAME;
END GET_FULL_NAME;

In Oracle SQL Developer, you can run this procedure in two ways.

1. Using SQL Worksheet

Create a SQL Worksheet and write PL/SQL anonymous block like this and hit f5

DECLARE
  FULL_NAME Varchar2(50);
BEGIN
  GET_FULL_NAME('Foo', 'Bar', FULL_NAME);
  Dbms_Output.Put_Line('Full name is: ' || FULL_NAME);
END;

2. Using GUI Controls

  • Expand Procedures

  • Right click on the procudure you've created and Click Run

  • In the pop-up window, Fill the parameters and Click OK.

Cheers!

2 Comments

sorry but the number one point gives problem 'identifier FULL_NAME must be declared'
If I'm not mistaken, I believe you may have meant to write "...you can run this procedure in two steps" (i.e., "steps", not "ways").
3
  • execute PROCEDURE_NAME
  • execute PRECEDURE_NAME(Parameters)

1 Comment

Please consider editing to make more obvious what additional insight you contribute beyond stackoverflow.com/a/20186667/7733418 ; ideally according to How to Answer.
-4

-- If no parameters need to be passed to a procedure, simply:

BEGIN
   MY_PACKAGE_NAME.MY_PROCEDURE_NAME
END;

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.