Skip to Content
author's profile photo Former Member
Former Member

How to insert the result from a procedure into a table or table variable ?

Can I insert the result from a procedure into a table?

For example:

CREATE PROCEDURE MYPROC

AS

BEGIN

/* I need the result from the system procedure "GET_OBJECT_DEFINITION" */

CALL GET_OBJECT_DEFINITION('MySchema','"MySourceTable"');

/* But how to insert the result from procedure "GET_OBJECT_DEFINITION" into a table or table variable ? */

END;

Best regards

Y. Hu

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

1 Answer

  • author's profile photo Former Member
    Former Member
    Posted on Nov 18, 2015 at 10:32 AM

    Hi Yujun,

    You can do it easily like the example below.

    CREATE PROCEDURE MYPROC

    AS

    BEGIN

    CALL GET_OBJECT_DEFINITION('MySchema', '"MySourceTable"', Some_Output_Variable);

    INSERT INTO ANY_TABLE SELECT cols FROM :Some_Output_Variable;

    END;

    1. You can directly insert into any table you want inside the GET_OBJECT_DEFINITION itself. In that case there is no need of this above MYPROC procedure.

    2. Suppose you don't want to do that, then you can follow the above approach and alter the GET_OBJECT_DEFINITION procedure to return an output table variable and collect those values inside

    table variable (Some_Output_Variable) and insert into the required table over in this procedure.

    Do let me know if you get any doubts in the above explanation.

    Regards,

    Anil

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.