×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Contact US

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

trying to call Sybase stored procedure with parameters from PHP

trying to call Sybase stored procedure with parameters from PHP

trying to call Sybase stored procedure with parameters from PHP

(OP)
I'm trying to run a stored procedure on a Sybase 11.0.1.2596 database (Micros RES 3700) 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:

CODE -->

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,...)

begin

declare@start_business_date timestamp;

declare@end_business_date timestamp;

...

end 

I've tried calling it these ways:

CODE -->

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:

CODE -->

[0]=> HY000

[1]=>13638

[2]=> SQL Anywhere Error -188:Not enough valuesfor host variables [13638](severity 16)[(null)]

[3]=>-1

[4]=>16 

or

CODE -->

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

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

CODE -->

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?

EDIT: The exact way I'm trying to call it is like this:

CODE --> php

$dbh = new PDO('dblib:host=<host_ip>',$user,$password,null);

$stmt =$dbh->prepare('call custom.custom_sp_R_cons_rvc_time_prd_ttls(:start_date, :end_date)');

$new_params = array(':start_date'=>'2017-05-02',':end_date'=>'2017-05-02');

$stmt->execute($new_params); 

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close