RE: Bind variable question




Thanks guys!
I got it to work by using an array and dropping the "\".

Ron,
I should have mentioned that I'm using MySQL, so I don't think SGA will
be an issue. I will keep your warning in mind though.

Thanks again all.

Steve

-----Original Message-----
From: Jonathan Leffler [mailto:jonathan.leffler@xxxxxxxxx]
Sent: Thursday, November 09, 2006 10:52 PM
To: Berlage, Steve
Cc: dbi-users@xxxxxxxx
Subject: 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."


Confidentiality Notice: The material in this e-mail is intended only for the use of the individual to whom it is addressed and may contain information that is confidential, privileged, and exempt from disclosure under applicable law. If you are not the intended recipient, be advised that the unauthorized use, disclosure, copying, distribution, or the taking of any action in reliance on this information is strictly prohibited. If you have received this e-mail in error, please immediately notify us at 866-335-3289 to arrange for the return of this material to us. Thank You.
.



Relevant Pages

  • Help in French|Spanish|German translation.
    ... I am also an author of User-defined string functions. ... WORDTRANEX (cSearched, cArExpressionSought | cExpressionSough, ... each string of the array is searched ... If the parameter nArStartOccurrence is -1 or omitted, the replacement starts ...
    (microsoft.public.fox.helpwanted)
  • 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: Structure conversion from C++ to VB-2008?
    ... One of the most important structures is AmiVar structure. ... point number, the array of floating point numbers, a string or IDispatch ... Dim 13012679 as Integer ...
    (microsoft.public.dotnet.languages.vb)
  • Structure conversion from C++ to VB-2008?
    ... One of the most important structures is AmiVar structure. ... point number, the array of floating point numbers, a string or IDispatch ... Dim 13012679 as Integer ...
    (microsoft.public.dotnet.languages.vb)