SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 SQL Server 2012 Forums
 Transact-SQL (2012)
 How to run a stored procedure in an MS SQL DB from
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

bionic_25
Starting Member

1 Posts

Posted - 07/04/2013 :  05:58:57  Show Profile  Reply with Quote
I am trying to call a stored procedure that accepts parameter inserts. The original query was being run from asp and looked like this:

EXEC [SearchForXML6b]
@sessionID = 973543,
@LineID = 892245,
@SortOrder = 'YearPublished DESC, SortTitle ASC',
@PageNumber = 1,
@RecordsPerPage = 20
I am redesigning the website in PHP, and am using the PDO method for querying the database. I am using a windows server, but have configured php to work on it, and can return simple selects from the db using pdo no problem.

From looking around for help for many hours, the accepted way to do what I need seems to be to do something like this:

$sql = "{:retval = CALL SearchForXML6b (@sessionID = 973543,
@LineID = 892245,
@SortOrder = 'YearPublished DESC, SortTitle ASC',
@PageNumber = 1,
@RecordsPerPage = 20)}";
$stmt = $this->c->prepare( $sql );
$stmt->bindParam('retval', $retval, PDO::PARAM_INT|PDO::PARAM_INPUT_OUTPUT, 4);

However this isn't working.

I have tried using EXEC instead of CALL but apparently PDO doesn't accept this.

I have heard talk of installing OBDC but it seems to be more of a LINUX focused driver. Does anyone know if it is possible to run stored procedures with my configuration?

Note: In SQL Server Management Studio, the SQL executes perfectly when using 'EXEC', but gives an error when trying to use 'CALL' as I don't think it's valid TSQL.

Thanks in advance

visakh16
Very Important crosS Applying yaK Herder

India
52309 Posts

Posted - 07/04/2013 :  07:48:34  Show Profile  Reply with Quote
You may be better off posting this in some PHP forum as issue seems to be in calling procedure from PHP since its executing fine in SSMS

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/
https://www.facebook.com/VmBlogs
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.03 seconds. Powered By: Snitz Forums 2000