INSERT INTO table_name CALL procedure_name

Database
Enthusiast

INSERT INTO table_name CALL procedure_name

Hi,
I tried to do this code:
INSERT INTO table_name CALL procedure_name;

 

But it's not possible so i found something like this:

DECLARE q1 VARCHAR(10000);
SET q1 =
'INSERT INTO table_name '
|| 'CALL procedure_name' ||';';
EXECUTE IMMEDIATE q1;

 

But it's also doesn't work.
Someone know how to write it?

4 REPLIES
Junior Contributor

Re: INSERT INTO table_name CALL procedure_name

You can't insert the result of a CALL because an SP might return multiple result sets.

 

What's this SP actually doing, can you show the source code?

Enthusiast

Re: INSERT INTO table_name CALL procedure_name

The SP return column of IDs (Integer) and I want to insert into table exists.

 

Maybe it's will be help to understand this code SQL, because i just want to convert exactly like this code and get the some data:

INSERT INTO table_name
execute procedure_name

Tags (2)
Junior Contributor

Re: INSERT INTO table_name CALL procedure_name

Well, you can't convert this code exactly.

 

In which different places is this SP called and what's the actual source code?

Teradata Employee

Re: INSERT INTO table_name CALL procedure_name

Apparently form the few other posts the result of the call is an integer?  And you are using Stored Procedure Language?

 

Declare Result1 INT;

Call <stored-proc>(..., :Result1);

insert into <table-name> values(:Result1);