Martin Evans wrote:
[EMAIL PROTECTED] wrote:
Hello
I having trouble using placeholders (named and numerical), using
DBD::ODBC connecting to Teradata. I cant easily use ordinary '?', as I
refer to the same placeholder several times in the SQL. For example,
this is the statement I prepare (a contrived example):
INSERT INTO ATABLE
(COLA,COLB,COLC,COLD,COLE,COLF)
VALUES
(:1,:2,:3,:3,:4,:4);
This is the error I get when using numerical place-holders.
DBD::ODBC::st execute failed: [NCR][ODBC Teradata][Teradata Database]
There is a mismatch between the number of parameters specified and the
number of parameters required. (SQL-07001)(DBD: st_execute/SQLExecute
err=-1)
!!NOTE!! The above error is being returned by the database, not DBI. I
am sure I am calling with the correct number of ags, which means DBI
is stuffing up the call to Teradata. This is the error I would have
got if I passed the wrong number of args:
DBD::ODBC::st execute failed: called with 3 bind variables when 4 are
needed
I get a different error when using named placeholders (and yes im sure
the statement was prepared OK with a parm called :COLA):
Can't bind unknown placeholder ':COLA'
Help please, as Im stuck using DO which is very slow!
**********************************************************************
IMPORTANT: This e-mail is intended for the use of the addressee and
may contain information that is confidential, commercially valuable or
subject to legal or parliamentary privilege. If you are not the
intended recipient you are notified that any review, re-transmission,
disclosure, use or dissemination of this communication is strictly
prohibited by several Commonwealth Acts of Parliament. If you have
received this communication in error please notify the sender
immediately and delete all copies of this transmission together with
any attachments.
**********************************************************************
You can send me a level 15 trace of this happening with numerical
placeholders and I'll take a look.
Martin
Looking at this again I don't think DBD::ODBC will do as you expect. I'm
guessing you are doing something like:
$sth = $dbh->prepare(
'insert into x (a,b,c,d,e,f) values(:1,:2,:3,:3,:4,:4)');
$sth->execute('p','q','r','s');
I cannot see in the DBI pod anything which says this should work. If you
change the execute to:
$sth->execute('p','q','r','r','s','s')
it should work but I'd change your SQL to use ? for parameters anyway as
it is more portable and quicker in DBD::ODBC. Perhaps if Tim is
reading this he could clarify whether it was ever his intention that the
example above should work?
Martin
--
Martin J. Evans
Easysoft Limited
http://www.easysoft.com