Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
PerlMonks  

This might be just a Sql Server issue, but here goes...

by heigold1 (Acolyte)
on Feb 15, 2006 at 19:50 UTC ( [id://530489]=perlquestion: print w/replies, xml ) Need Help??

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

I'm getting a error which complains about an unknown placeholder. I don't know how to get around this, and I couldn't find any code examples. Any help is greatly appreciated.

Here is the code:

use DBI; use CGI; $sql = "exec CM_Gandalf_Balrog"; $db_handle = DBI->connect ('dbi:ODBC:SIMVIPERAS' , '00AIBUILD01', 'aibuild01#') or die "Couldn't connect to database: $DBI::errstr\n"; $statement = $db_handle->prepare($sql) or die "Couldn't prepare query '$sql': $DBI::errstr\n"; $statement->bind_param("p_frodo","AI Clues / BBE"); $statement->bind_param("p_legolas","AI Rel 05.12"); $statement->execute() or die "Couldn't execute query '$sql': $DBI::er +rstr\n";

I get the following error which I haven't been able to get around:

Can't bind unknown placeholder 'p_frodo' at D:\Brent\Perl\connect_to_v +iper_sql_server\objects_impacted_stored_proc.pl line 57.

Am I missing something in the bind call?

Any help is greatly appreciated,

Brent.

Edited by planetscape - changed bold tags to code tags

Replies are listed 'Best First'.
Re: This might be just a Sql Server issue, but here goes...
by davidrw (Prior) on Feb 15, 2006 at 20:02 UTC
    The first argument of bind_param needs to be a postive integer .. (see DBI docs) .. i suspect (i don't remember the syntax for exec offhand) you need something like:
    $sql = "exec CM_Gandalf_Balrog p_frodo = ?, p_legolas = ?"; my @bind = ( "AI Clues / BBE", "AI Rel 05.12" ); $statement = $db_handle->prepare($sql) or die "Couldn't prepare query +'$sql': $DBI::errstr\n"; $statement->execute(@bind) or die "Couldn't execute query '$sql': $DBI +::errstr\n";

    And if you still wanted to use bind_param, it would be something like this:
    $sql = "exec CM_Gandalf_Balrog p_frodo = ?, p_legolas = ?"; $statement = $db_handle->prepare($sql) or die "Couldn't prepare query +'$sql': $DBI::errstr\n"; $statement->bind_param(1,"AI Clues / BBE"); $statement->bind_param(2,"AI Rel 05.12"); $statement->execute() or die "Couldn't execute query '$sql': $DBI::err +str\n";
Re: This might be just a Sql Server issue, but here goes...
by brian_d_foy (Abbot) on Feb 15, 2006 at 20:05 UTC

    What are you trying to do? To bind a value to a placeholder, you need a statement that has placeholders in it. The first argument to bind_param() is the number of the placeholder and the second argument it the value to bind.

    --
    brian d foy <brian@stonehenge.com>
    Subscribe to The Perl Review

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://530489]
Approved by Corion
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others musing on the Monastery: (7)
As of 2024-04-23 11:41 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found