SPUG: bind_param and stored procedure

Martin Korb mkorb at versuslaw.com
Mon Jul 15 11:38:30 CDT 2002


I get the following error message  when I use bind_param on the following stored procedure called within a perl
script. 
Syntax error near @P1. Can not execute......
here is the code snippet:
my $sql_set_identity_shopper = "EXEC dt_IdentityOnOff(?,?)";
my $sth_set_identity_shopper = $dbh_7->prepare($sql_set_identity_shopper);
$sth_set_identity_shopper->bind_param(1,"tblshopper");
$sth_set_identity_shopper->bind_param(2,"on");
$sth_set_identity_shopper->execute() or die "can not execute $!";

When I do not specify the order (which I really shouldn't have to) I get a different but also fatal error:
Can't bind unknown placeholder 'tblshopper'
here is the code snippet: 
my $sql_set_identity_shopper = "EXEC dt_IdentityOnOff(?,?)";
my $sth_set_identity_shopper = $dbh_7->prepare($sql_set_identity_shopper);
$sth_set_identity_shopper->bind_param("tblshopper","on");
$sth_set_identity_shopper->execute() or die "can not execute $!";

SQL 7.0 Stored Procedure: 
CREATE PROCEDURE dt_identityOnOff
  @tablename varchar(64),
  @action varchar(3)
as
if @tablename = 'tblshopper'
begin 
  if @action = 'on'
      set identity_insert tblshopper on
  else
    set identity_insert tblshopper off
end
else
begin
  if @action = 'on' 
    set identity_insert tblfirms on
  else
    set identity_insert tblfirms off
end

Any suggestion on what I am overlooking. 
Thanks 

Martin

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.pm.org/archives/spug-list/attachments/20020715/015bd12e/attachment.htm


More information about the spug-list mailing list