RE: [dbi] prepared insert syntax error on exec
From: Andy Law (andy.law_at_bbsrc.ac.uk)
Date: 10/15/03
- Next message: shildreth_at_emsphone.com: "Has anyone seen this."
- Previous message: Gary Stainburn: "Re: [dbi] prepared insert syntax error on exec"
- Maybe in reply to: Martin J. Evans: "RE: [dbi] prepared insert syntax error on exec"
- Next in thread: Gary Stainburn: "Re: [dbi] prepared insert syntax error on exec"
- Reply: Gary Stainburn: "Re: [dbi] prepared insert syntax error on exec"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
To: "'dbi-users@perl.org'" <dbi-users@perl.org> Date: Wed, 15 Oct 2003 13:43:49 +0100
> I could be wrong but I didn't think you could use parameters
> to change the SQL
> which you appear to be doing by using ? where a column name
> is expected.
In which case, why is the prepare statement not failing?
Gary:
Will the following not work?
my ($fieldName) = 'nsmacc';
my ($stmt) = sprintf( "insert into names (nid, ncname, %s) values (?, ?, ?);", $fieldName);
my $cinh = $dbh->prepare( $stmt);
$cinh->execute( 1, 'test name', 'ACC01');
Later,
Andy
-------------
Yada, yada, yada...
The information contained in this e-mail (including any attachments) is confidential and is intended for the use of the addressee only. The opinions expressed within this e-mail (including any attachments) are the opinions of the sender and do not necessarily constitute those of Roslin Institute (Edinburgh) ("the Institute") unless specifically stated by a sender who is duly authorised to do so on behalf of the Institute.
> -----Original Message-----
> From: Martin J. Evans [mailto:martin@easysoft.com]
> Sent: 15 October 2003 12:44
> To: dbi-users@perl.org
> Subject: RE: [dbi] prepared insert syntax error on exec
>
>
> I could be wrong but I didn't think you could use parameters
> to change the SQL
> which you appear to be doing by using ? where a column name
> is expected.
>
> Martin
> --
> Martin J. Evans
> Easysoft Ltd, UK
> Development
>
> On 15-Oct-2003 Gary Stainburn wrote:
> > Hi folks,
> >
> > can anyone see why this isn't working:
> >
> > my $cinh=$dbh->prepare("insert into names (nid, ncname, ?)
> values (?, ?,
> > ?);");
> > $cinh->execute('nsmacc',1,'test name','ACC01');
> >
> > produces the error message:
> >
> > ERROR: parser: parse error at or near "'"
> >
> > nid is an int4 primary key
> > ncname is a varchar(50) company name
> > nsmacc is a varchar(5) account number field
> >
> > --
> > Gary Stainburn
> >
> > This email does not contain private or confidential material as it
> > may be snooped on by interested government parties for unknown
> > and undisclosed purposes - Regulation of Investigatory
> Powers Act, 2000
>
- Next message: shildreth_at_emsphone.com: "Has anyone seen this."
- Previous message: Gary Stainburn: "Re: [dbi] prepared insert syntax error on exec"
- Maybe in reply to: Martin J. Evans: "RE: [dbi] prepared insert syntax error on exec"
- Next in thread: Gary Stainburn: "Re: [dbi] prepared insert syntax error on exec"
- Reply: Gary Stainburn: "Re: [dbi] prepared insert syntax error on exec"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|