Re: Bind variable question



On 11/9/06, Berlage, Steve <Steve.Berlage@xxxxxxxxxxx> wrote:


Here is what I am trying to do:

$UPDATE_COMPANY_STRING = "ccompStreet = ?";

$UPDATE_COMPANY_VALUE_STRING = "\$tmpccompStreet";



$sql="UPDATE clientcomp SET $UPDATE_COMPANY_STRING WHERE ccompid = ?";

$sthUpdate = $dbh->prepare($sql);

$sthUpdate->execute($UPDATE_COMPANY_VALUE_STRING, $tmpstcompid);



Obviously there are many more fields that _may_ be added to the 2
variables that are in all caps (I only showed 1 for simplicity). I only
add the fields that need to be updated to those 2 variables. It does
what I expect it to do except for the last line. I want the
$UPDATE_COMPANY_VALUE_STRING to be expanded to the actual string it
contains before the "execute" is run. I've tried a bunch of different
ways to make it happen - all to no avail. I either get errors or end up
with "$tmpccompStreet" in the database (instead of the value that
$tmpccompStreet contains).

Hopefully it's clear what I'm trying to accomplish here. Please be kind
- I'm relatively new to pl/sql :)



I think you have the wrong data structure for the value string - what you
need is an array of values, with the ccompid value at the end and the other
values in sequence. So, build the SQL statement one item at a time and add
the corresponding value to an array.

You then pass the array to the $sth->execute() call.

--
Jonathan Leffler <jonathan.leffler@xxxxxxxxx> #include <disclaimer.h>
Guardian of DBD::Informix - v2005.02 - http://dbi.perl.org
"I don't suffer from insanity - I enjoy every minute of it."


Relevant Pages

  • Re: Shuffle an array of integers.
    ... > I changed the type of Ballenbak array from int to String. ... I'm reasonably sure that the shuffle probably relies on the ... Steve W. Jackson ...
    (comp.lang.java.programmer)
  • Re: Newbie String Questions
    ... use the concat method rather than the + operator. ... The Javadocs for String indicate that the language has special support ... a String constructor with that array. ... Steve W. Jackson ...
    (comp.lang.java.programmer)
  • Re: passing a string to a dll
    ... Joe, I really appreciate you taking the time to demonstrate this. ... sure how I would implement indexing it for random alphanumeric codes. ... I might handle the array. ... I actually have been wondering if I could use a second string ...
    (microsoft.public.vc.mfc)
  • Re: passing a string to a dll
    ... I might handle the array. ... I actually have been wondering if I could use a second string ... look at insertion cost, organization cost, and search cost. ...
    (microsoft.public.vc.mfc)
  • Re: Array Type Mismatch
    ... Dim resultAs String ... I am still somewhat confused as to why nothing is stored in the array. ... Public Function TextBoxGetLine(....arguments... ...
    (microsoft.public.access.formscoding)