Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Qlik Open Lakehouse is Now Generally Available! Discover the key highlights and partner resources here.
cancel
Showing results for 
Search instead for 
Did you mean: 
alec1982
Specialist II
Specialist II

execute stored procedure error

Hi guys,

I am trying to execute the following stored procedure but i am getting errors... any advice?

EXECUTE sdobj.GETSTNGROSSAMOUNT (#coson) from sddta.cusord where #coson=800300

I have never used stored procedures before so I am not sure if the above script is correct..

Thxs,

Alec

8 Replies
Siva_Sankar
Master II
Master II

First step is that you have to create a variable for each parameter you need to pass to the Store Procedure. In this example, let's suppose you just have a single date parameter:

let vDate = '2013-01-01' //here is important to use the same format that is used in the database

Store_Procedure_table:

Load * ;

SQL EXECUTE DB.OWNER.STORE_PROCEDURE '$(vDate)'; //with the last part you're passing the needed parameter

If you had several parameters you can separate them with commas and alwas with the $-expansion and between single quotes,

Regards.

Siva

jagan
Partner - Champion III
Partner - Champion III

Hi,

Try like this

LET coson = 'StoredProcedureParameterValue';

TableName:

SQL EXECUTE sdobj.GETSTNGROSSAMOUNT ($(StoredProcedureParameterValue)) ;


Where your stored procedure in the database should have the following code


CREATE PROCEDURE sdobj.GETSTNGROSSAMOUNT

(

     value INT

)

BEGIN

SELECT * from sddta.cusord where #coson=value

END


Hope this helps you.


Regards,

Jagan.

Not applicable

Hi,

Please try the following code:

SQL
EXEC ProcedureName
@Parameter1='Data',
@Parameter2='Data'
;
SQL SELECT *
FROM TemptableName;

In this TemptableName is the table in which the procedure stores the output.

Hope this helps.

-Shruti


alec1982
Specialist II
Specialist II
Author

Hi guys,

Thank you for the details however none of them helped..

Anybody can help and give me how my script should look like to query the stored procedure giving the above details?

As I said I'm not an expert when it comes to stored procedures.

Thxs for your help.

Alec

jagan
Partner - Champion III
Partner - Champion III

Hi,

Do you have stored procedure in the stored procedure in the database?  If not then you have to create it in database, or else if it is a query you can just directly execute that query like

TableName:

SQL SELECT * from sddta.cusord where #coson=800300;

Hope this helps you.

Regards,

Jagan.

alec1982
Specialist II
Specialist II
Author

Hello,

Thank you for your help but SQL SELECT * from sddta.cusord where #coson=800300; doesn't bring what I am looking for and yes there is a stored procedure in the database..

Thxs,

Alec

iktrayanov
Creator III
Creator III

The first thing i wold try is to execute the SQL statement on the server to make sure it works.

So try

SELECT * from sddta.cusord where #coson=800300

on your SQL server

jagan
Partner - Champion III
Partner - Champion III

Hi,

Check this

Stored Procedure Parameters SQL

Regards,

Jagan.