on 01-12-2015 11:01 AM
Hi,
I have a stored procedure as follows
PROCEDURE "schema"."myProc" ()
LANGUAGE SQLSCRIPT
SQL SECURITY INVOKER
DEFAULT SCHEMA "schema"
AS
BEGIN
SELECT * FROM "TABLE";
END;
This procedure on call from a SQL editor i.e., call "schema"."myProc"() would result into a records from the table "TABLE".
How can I call the same procedure from another procedure and assign the records from "schema"."myProc"() into a intermediate variable and manipulate the result.
If I use "WITH RESULT VIEW myView" option in a .hbdprocedure, editor throws an error saying "The With Result View statement is not permitted".
Regards,
Vijay.
HowmyProc" ()
Hi Vijay,
I think you can use the table type and OUT parameter to solve this problem. And fill in the intermediate variable you want. Something like the following code
PROCEDURE "schema"."myProc" (OUT out TT_TABLE)
LANGUAGE SQLSCRIPT
SQL SECURITY INVOKER
DEFAULT SCHEMA "schema"
AS
BEGIN
out = SELECT * FROM "TABLE";
END;
Then you can use the following CALL statement in another precedure to assign the result to the "out" variable.
CALL "schema"."myProc"(out);
Best regards,
Wenjun
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Zhou,
Thanks for quick reply, yes this method is one way to achieve the result
The problem with using a "OUT out TT_TABLE" as a output parameter (in my case) is I dont know the table structure of the output, TT_TABLE structure is determined dynamically depending on few conditions in the procedure.So I cannot pre-define the table type for the output.
I was just wondering if we can assign the output table of a procedure call to some intermediate varibale as in below code
temp_table =call "schema"."myproc"();
But this is not allowed, I am getting an error for this. Am I missing some syntax or this kind of a operation is not allowed in SQLScript? .
In xsjs I am able to iterate throught the result set of "myproc"() so I am assuming there should be something in SQLScript to achieve this kind of operation.
Any input would be much appreciated.
Regards,
Vijay.
User | Count |
---|---|
93 | |
10 | |
10 | |
9 | |
9 | |
7 | |
6 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.