[unixODBC-support] Newbie question - how to execute a stored proc

John Bradley jbradley at lanvera.com
Tue Mar 5 21:47:30 GMT 2013


Thanks Nick! I don't think it's a driver or (linux) configuration issue, because once I used -v to see what was actually going on, it all makes sense now. The user I'm using doesn't have access to one of the functions it's trying to use. Thanks for including that in your example. That helped a lot.

From: Nick Gorham [mailto:nick at lurcher.org]
Sent: Tuesday, March 05, 2013 10:40 AM
To: Support for the unixODBC project
Cc: John Bradley
Subject: Re: [unixODBC-support] Newbie question - how to execute a stored proc

On 05/03/13 16:25, John Bradley wrote:
I have a completely newbie question for the list. I've looked through a few years' worth of archives but can't find it addressed anywhere previously and Google isn't helping me at all. I've installed and started using unixODBC and am working on a Linux c shell script that uses ISQL from the command line to run some queries in my MSSQL 2008 DB. Everything works fine, except I can't figure out how to get it to run a stored procedure.

An example of something that works:

variable=`echo select column from schema.table where column=thing|isql dbname userid password -b -x0x20`

This populates variable and everything works. I figured I'd be able to do the same thing with an sp:

`echo exec schema.procname @parm=value|isql dbname userid password -b -x0x20`

But all I get in return is "[ISQL]ERROR: Could not SQLExecute". I've tried every permutation of all caps, mixed case, wrapping things in brackets and just doing it from the ISQL command line and I never get anything but "[ISQL]ERROR: Could not SQLExecute". I know it's something obvious, but I can't figure it out. Can anyone help me?

Thanks,
John

It may depend on the driver you are using. I think what you are doing should work, this is with our (Easysoft) SQLServer driver

echo "exec sp_columns @table_name=fred" | isql -b -x0x20  -v sqlsrv2008 test test
AdventureWorks dbo fred i 4 int 10 4 0 10 1   4   1 YES 38
AdventureWorks dbo fred c 1 char 200 200   1   1  200 2 YES 39

So in theory what you are trying should work.

--
Nick
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.unixodbc.org/pipermail/unixodbc-support/attachments/20130305/8280f8f7/attachment.html>


More information about the unixODBC-support mailing list