Jump to content

trying to call Sybase stored procedure with parameters from PHP

Recommended Posts

I'm trying to run a stored procedure on a Sybase database in a PHP file using PDO and dblib as the driver. I can call a procedure with no parameters with no problems using something like:

    call custom.show_clocked_in_employees

This works perfectly. However, if the procedure takes parameters, I get an error. So if I have a procedure like this that takes 2 parameters:

    create procedure custom.custom_sp_R_cons_rvc_time_prd_ttls(in business_date_start timestamp,in business_date_end timestamp)
    result(start_business_date timestamp,end_business_date timestamp,store_number OBJ_NUM,store_id SEQ_NUM,...)
      declare @start_business_date timestamp;
      declare @end_business_date timestamp;

I've tried calling it these ways:

    call custom.custom_sp_R_cons_rvc_time_prd_ttls('2017-05-02', '2017-05-02')

    call custom.custom_sp_R_cons_rvc_time_prd_ttls('2017-05-02 00:00:00.000000', '2017-05-02 00:00:00.000000')

    exec custom.custom_sp_R_cons_rvc_time_prd_ttls('2017-05-02', '2017-05-02')

    exec custom.custom_sp_R_cons_rvc_time_prd_ttls '2017-05-02', '2017-05-02'

No matter what I do, I get an error like:

this error:

    [0] => HY000
    [1] => 13638
    [2] => SQL Anywhere Error -188: Not enough values for host variables [13638] (severity 16) [(null)]
    [3] => -1
    [4] => 16


    [2] => SQL Anywhere Error -131: Syntax error near '2017-05-02' on line 1 [102] (severity 15) [(null)]


If I run this procedure in a SQL client like RazorSQL using:

    call custom.custom_sp_R_cons_rvc_time_prd_ttls('2017-05-02', '2017-05-02')

it works perfectly, so PDO/PHP/? appears to not be sending the data to the client correctly. What is the syntax to use to call a Sybase procedure with parameters using PDO?

Link to post
Share on other sites
This thread is more than a year old.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.