Skip to Content.
Sympa Menu

freetds - Re: [freetds] FreeTDS & Stored Procs

freetds AT lists.ibiblio.org

Subject: FreeTDS Development Group

List archive

Chronological Thread  
  • From: "James K. Lowden" <jklowden AT schemamania.org>
  • To: FreeTDS Development Group <freetds AT lists.ibiblio.org>
  • Subject: Re: [freetds] FreeTDS & Stored Procs
  • Date: Thu, 13 Nov 2003 08:40:45 -0500

On Thu, 13 Nov 2003 03:45:43 EST, Thompbil18 AT aol.com wrote:
> > Is "exec <store procedure> @charparam = 'value',
> > @intparam = 123, @dateparam = 'JanĀ  1 2003' "
> > the format of a stored proc query whith FreeTDS???
>
> No, thats just straight TSQL like you'd put in query analyzer.

Or, yes, that's just straight T-SQL. That works fine with ct-lib; it's
just not as flexible as the API is.

Even though ct-lib gives you other choices, my experience is that
constructing a string to call a stored procedure is the easiest way to
work in C++.

If you derive a simple class from std::string that can put quotes around
strings and deal with quotes in strings, calling stored procedures isn't
much harder than streaming to a file. I'm thinking of something like:

stringstream query;
query << "exec my_proc @charparam = "
<< cvalue.quoted()
<< ", @intparam = "
<< ivalue
<< ", @dateparam = "
<< dvalue.quoted()
;

(Obviously, if your string-derived class overloads operator<<(), you don't
even have to call its quoted() method.)

You can't get output parameters that way. I deal with that by not using
them; I write my stored procedures to return all outputs as results. I
just think that's easier.

But, hey, Bill put in a lot of work to make output procedures DTRT, and
lots of people like working that way. I'd be the last one to say don't
use it. Well, maybe not *last*, but ....

--jkl




Archive powered by MHonArc 2.6.24.

Top of Page