DBD::ODBC and placeholders

From: Brian Roy (mister.roy_at_gmail.com)
Date: 12/04/04


Date: Sat, 4 Dec 2004 16:42:22 -0600
To: dbi-users@perl.org

Hello,

I was under the impression that placeholders would work in ODBC. I was
hoping this was the case as I don't want to rewrite my code that works
under mySQL. I'm trying to insert into MS SQL server with the same
statements. Please let me know if there is something I'm missing here.

sub sqinsert () {
        my ($names, $formdata) = @_;
        my $fields = join(', ', @$names);
        my $places = join(', ', ('?') x @$names);
        my $sql = "INSERT into $table ($fields) values ($places)";
        $sth = $dbh->prepare($sql);
        $sth->execute(@$formdata) || die $dbh->errstr;;
        $sth->finish();
        }

This is what I receive when I watch profiler on the SQL server. The
?'s get populated but they are with '@P's. I'm not sure how/why this
is happening.

INSERT into queue_stats (qdate, qtime, callid, queue, exten, qevent,
qholdtime, qcalltime, qorigposition) values (@P1, @P2, @P3, @P4, @P5,
@P6, @P7, @P8, @P9)

Anyone have any experience with this or know what I might be doing wrong?

Thanks,

Brian



Relevant Pages

  • Re: DBD::ODBC and placeholders
    ... > I was under the impression that placeholders would work in ODBC. ... > hoping this was the case as I don't want to rewrite my code that works ... > This is what I receive when I watch profiler on the SQL server. ...
    (perl.dbi.users)
  • SQL Server ODBC Driver Ignores Authentication Setting
    ... set their ODBC connections with SQL Server Authentication, ... Microsoft Data Access Components 2.6 RTM, ... authentication to log into the database. ...
    (microsoft.public.sqlserver.security)
  • Re: Linking tables access - sql server 2005
    ... Another advantage of this method is that you don't need an ODBC setting on the local computer, ... Create a linked table to SQL Server without using a DSN ... Name of the table that you are linking to on the SQL Server database ... Function AttachDSNLessTable(stLocalTableName As String, stRemoteTableName As String, stServer As String, stDatabase As String, Optional stUsername As ...
    (microsoft.public.access.adp.sqlserver)
  • RE: [ODBC SQL Server Driver][Shared Memory]ConnectionWrite (send()
    ... the ODBC source using named pipe, but I don't know how to enable named pipes ... If it is not working I am going to use ado to connect to sql server. ... Microsoft Online Community Support ...
    (microsoft.public.sqlserver.connect)
  • Re: [PHP] ODBC and long text fields
    ... We've a PHP app that uses ODBC to talk to a MS SQL server. ... The internal code for a query is ...
    (php.general)