softeng2000 has asked for the wisdom of the Perl Monks concerning the following question:

Hi, I ususally use Win32::ODBC module to access SQL DBs. But there is a problem whe I use this code: $nx = 2; $ny = 4; $SqlStatement = "execute sp_test $nx, $ny"; if ($dbLang->Sql($SqlStatement)) { print( "\n----\nSQL Error: " . $dbLang->Error()); print( "SQL statement = \'$SqlStatement\'\n----"); <>;exit; } sp_test uses $ny as OUTPUT parameter. But it doesn't work since there is vaule goes to sp, not reference. Is there a possibility to use parameters by reference in some way to SQL stored procedure? Thank you.

Replies are listed 'Best First'.
Re: SQL Stored Procs
by jptxs (Curate) on Nov 10, 2000 at 05:01 UTC

    Not sure what you're up to after looking a bit. Bets bet is read perldoc DBI where you have the DBI module installed or see the book by the man who wrote the DBI itself: Programming the Perl DBI.

    No idea how to help except to say the code is mighty strange, what does the <> do for you? but to get your code to print nicely in a node you should use CODE tags, see Writeup Formatting Tips.

    $nx = 2; $ny = 4; $SqlStatement = "execute sp_test $nx, $ny"; if ( $dbLang->Sql($SqlStatement) ) { print( "\n----\nSQL Error: " . $dbLang->Error()); print( "SQL statement = \'$SqlStatement\'\n----"); <>; exit; }

    "sometimes when you make a request for the head you don't
    want the big, fat body...don't you go snickering."
                                             -- Nathan Torkington UoP2K a.k.a gnat

Re: SQL Stored Procs
by roberto (Acolyte) on Nov 10, 2000 at 05:30 UTC
    So you would like to use a perl variable to get a sql variable reference? God Luck! :-)
    if you whant to use stored procedures consult the manual for DBD::Your_Database and see if and how they are supported.
    se this example from DBD::Oracle for some hints
    (by the way i think "4" is not a valid identifier in sql :-))