How to execute the stored procedure in Version 9

Hi,

 

I am trying to execute the stored procedure with the following syntax In Metastrom BPM Version 9. But it fails.

 

"exec SPNAME '"+PROCESSNAME.STARTDATE+"'"

 

PROCESSNAME.STARTDATE is my input parameter to the stored procedure. When i tried to run the stored procedure with the hardcoded value like "exec SPNAME '2011-10-11" then its working fine.

 

So can you help me to provide the sample or how to execute the SP?

 

Thanks,

Sath

 

Tagged:

Comments

  • Use FormatDateTime to format the date variable to the format string "yyyy-MM-dd", but to not forget the single quotes. You can always add the quotes to the format string as well: "'yyyy-MM-dd'"

     

    Alternatively, and much better, we recommend using SelectSQL() and passing in the variable as a parameter. The system then sorts out all the data binding for you.


    Sath wrote:

    Hi,

     

    I am trying to execute the stored procedure with the following syntax In Metastrom BPM Version 9. But it fails.

     

    "exec SPNAME '"+PROCESSNAME.STARTDATE+"'"

     

    PROCESSNAME.STARTDATE is my input parameter to the stored procedure. When i tried to run the stored procedure with the hardcoded value like "exec SPNAME '2011-10-11" then its working fine.

     

    So can you help me to provide the sample or how to execute the SP?

     

    Thanks,

    Sath

     


     

  • I use Stored procedures in SelectSQL(). IMO, it's the best way.

     

    If PROCESSNAME.STARTDATE is DateTime object, then you can format it to string in one step.

     

    Sample of using SelectSQL(), several SP parametes and converting DateTime to string:

     

    SelectSql(new YourOwnDBConnection(),"execute dbo.StoredProcedure @param1, @param2", SQLArg("@param1",PROCESSNAME.STARTDATE.ToString("yyyy-mm-dd"), SQLArg("@param2", anyOtherVariable));
    

     

  • Do not format the date as a string. Use the date as an argument directly with SQLArg() and let it do the work!

     

    That is the whole point of the object.