I've written this example script to illustrate what I'm attempting to do:

#my @col = ("machine","runas"); #my @val = ("bar","faa"); my $col = "machine"; my $val = "bar"; my $dbName = "fooDB.db"; #Create DB connection my $dbh = DBI->connect( # connect to your database, create if "dbi:SQLite:dbname=$dbName", # DSN: dbi, driver, database file "", # no user "", # no password { RaiseError => 1 }, # complain if something goes wrong ) or die $DBI::errstr; #Create Table $dbh->do('create table schedules (schedId INTEGER PRIMARY KEY, schedName TEXT, machine TEXT, runas TEXT, owner TEXT)' ); #Insert 1 row my $sth = $dbh->prepare_cached("INSERT into schedules (schedName) valu +es ('foo')") or die "Couldn't prepare statement: " . $dbh->errstr; $sth->execute() or die "Couldn't execute statement: " . $sth->errstr; #Get row ID my $rowId = $dbh->func('last_insert_rowid'); #Do an update with mutiple placeholders my $sth1 = $dbh->prepare_cached("UPDATE schedules SET ? = ? WHERE sche +dId = ?") or die "Couldn't prepare statement: " . $dbh->errstr; #Try with bind_param_array #$sth1->bind_param_array(1, @col); #$sth1->bind_param_array(2, @val); #$sth1->bind_param_array(3, $rowId); # scalar will be reused for each +row #$sth1->execute_array() $sth1->execute($col,$val,$rowId) or die "Couldn't execute statement: " . $sth->errstr;

No matter how I use this, with bind_param_array or with straight scalars, I get the same error:

DBD::SQLite::db prepare_cached failed: near "?": syntax error at ./foo +.pl line 37. DBD::SQLite::db prepare_cached failed: near "?": syntax error at ./foo +.pl line 37.

In reply to Re^2: Using prepared_cache with placholders by herda05
in thread Using prepared_cache with placholders by herda05

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.