on 08-05-2013 2:47 PM
Hi,
I'm looking for a possibility to create a procedure in HANA with optional parameters. Haven't found anything in the docu so a short qeuestion to the this round.
Is anyone aware of a solution for that?
Thx and Regards,
Marcus
Hi Marcus,
Could you try 'call "mySchema"."MyProcedure"('context_p1', '', '',?)'? it maybe can work.
Hope this can help you.
Regards,
Jerry
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
CREATE
PROCEDURE mySchema.MyProcedure(IN Param_1 nvarchar(100) := '', IN Param_2 nvarchar(100) := '', [...])
Hi Ravi,
That's how I realized it right now. I hoped that it will be possible because I have about 20 different values I'm entering in Param_1 as an action_type and depending on that the other params are required and I wouldn't like to "fullfil" the unused parameters with ''.
I now it from other databases (e.g. M$) that the parameters can be defined as optional or with default values.
Regards,
Marcus
Hi Marcus,
If you have the SAP account manager associated with your SAP HANA project, then I'd suggest you to raise a "Feature Request". Depending on the business criticality of the required feature, your SAP account manager can then take it up with the proper development Manager / Team.
Regards,
Ravi
You can mimic having optional parameters in your procedures, but only by specifying default values for the parameters. See this code below.
So here I define two parameters, both have a default value.
create procedure test( in im_var1 nvarchar(10) default 'This',
im_var2 nvarchar(10) default 'That' )
LANGUAGE SQLSCRIPT
SQL SECURITY INVOKER
READS SQL DATA AS
BEGIN
select :im_var1 from dummy;
select :im_var2 from dummy;
END;
Next, I can call the procedure and omit any parameter that has a default value. Of course, I am always able to override the default and specify the value to pass to any parameter. In this case I am passing 'Other' to the second input parameter and omitting the first parameter.
call test( im_var2 => 'Other' );
Hope this helps.
Cheers,
Rich Heilman
Do you want to create a simple procedure and then call the procedure from something like SQL editor and pass input parameters? Is that what you mean? If so it's something like this;
SIMPLE PROCEDURE
/********* Begin Procedure Script ************/
BEGIN
var_out = SELECT YourTable.Field1
//OUTPUT VARIABLE THAT MUST EXIST IN OUTPUT PANE OF PROCEDURE//
FROM "YourSchema"."YourTable"
WHERE YourTable.Field2 = :the_input
//INPUT VARIABLE THAT MUST EXIST IN INPUT PANE OF PROCEDURE//
END
/********* End Procedure Script ************/
CALLING YOUR SIMPLE PROCEDURE FROM SQL EDITOR
call "_SYS_BIC"."YourPackageNameHere/YourProcedureNameHere" ('ValueToPassToProcedureHere',?)
//This 'ValueToPassToProcedureHere' is what will be passed to :the_input input parameter of the procedure.//
Hope this helps.
-Patrick
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Marcus,
If you are on SPS 06, potentially you can use something like:
call "mySchema"."MyProcedure"(Param_1 => 'context_p1', Param_2 => '', Param_3 => '', Param_4 => '');
But for the behavior to make it optional, you can also implement that logic in the procedure code by checking the value of the received parameter and then deciding to use it or not.
Regards,
Ravi
User | Count |
---|---|
78 | |
10 | |
9 | |
7 | |
6 | |
6 | |
5 | |
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.