Message Boards

Optional parameters in a called MS SQL stored procedure

Alex TRICA, modified 1 Year ago.

Optional parameters in a called MS SQL stored procedure

New Member Posts: 10 Join Date: 11/15/21 Recent Posts

Hi ! I have a MS SQL procedure called in Java - LIFERAY. It is a general procedure with many optional parameters.  

1. How can define OPTIONAL PARAMETERS in default.xml?  

2 How to call the procedure without a part of the optional parameters ?

thumbnail
Mohammed Yasin, modified 2 Years ago.

RE: Optional parameters in a called MS SQL stored procedure

Liferay Master Posts: 591 Join Date: 8/8/14 Recent Posts

Hi , 
You can either use a Placeholder or QueryPos to include parameter in your Procedure

Ex. 
 CALL somprocedue(? , ? );
 CAL someprocdure([$PARAM1$],[$PARAM2])

Then you can replace the placeholder in your finderimpl using string replace utility or use QueryPos

QueryPos qPos = QueryPos.getInstance(query);
qPos.add(param1);
qPos.add(param2);

 

Alex TRICA, modified 1 Year ago.

RE: Optional parameters in a called MS SQL stored procedure

New Member Posts: 10 Join Date: 11/15/21 Recent Posts

Thank you for answer.

But it don't resolve the problem.

I asked about 'OPTIONAL PARAMETERS'. 

This means that once I have to call the procedure with 1 parameter, another time I have to call it with 3 parameters and so on.

My procedure has 11 parameters, only the first beeing mandatory. How to specify that params 2 ... 11 are OPTIONAL ?

So, if you or other anybody has an idea, please post it.

Many thanks,

Alex

Alex TRICA, modified 1 Year ago.

RE: RE: Optional parameters in a called MS SQL stored procedure

New Member Posts: 10 Join Date: 11/15/21 Recent Posts

HI !

No ideas about a solution concerning OPTIONAL PARAMETERS in a SQL procedure ?

Many thanks for any usable information !

Alex

Alex TRICA, modified 1 Year ago.

RE: Optional parameters in a called MS SQL stored procedure

New Member Posts: 10 Join Date: 11/15/21 Recent Posts

HI !

I  renew my request.

No ideas about a solution concerning OPTIONAL PARAMETERS in a SQL procedure ?

Many thanks for any usable information !

Alex