0

Hi I am trying to return a value from Oracle using dynamic SQL. I am getting an error SQL command not properly ended. I can't figure out what I am doing wrong. Here is the latest code I've tried:

PROCEDURE get_record_counts
AS
v_EXT_RECCOUNT   VARCHAR2(05) := '0';
BEGIN

 EXECUTE IMMEDIATE 'select count(*)  from ' ||  r_cls.EXT_TABLE ||  ' RETURN v_EXT_RECCOUNT into v_EXT_RECCOUNT ';


END  get_record_counts;

1 Answer 1

3

You'd want

EXECUTE IMMEDIATE 'select count(*) from ' || r_cls.ext_table
   INTO v_ext_reccount

assuming that r_cls.ext_table resolves to a varchar2 variable that contains a table name that the caller has appropriate permissions on. In the snippet you posted, that is not a valid variable name but I'm guessing that there is more code that you've removed that declares that variable.

Sign up to request clarification or add additional context in comments.

1 Comment

That did the trick. I was trying to add the "into" portion in the quotes of the execute immediate. Thanks!

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.