Kindness it is ...

Your statement only has one bind variable (?).  The other "bind
variable" is actually a Perl variable.  Your execute will fail because
of this.

However, there is another issue.  You cannot substitute bind variables
in this manner.  Your attempt to dynamically build column names will
fail.  You will need to use 'EXECUTE IMMEDIATE' to perform this type of
action.

The PL/SQL documents and the Pro*C documents can give you light on how
this might be accomplished.  This type of coding may be beyond the
capabilities of DBD::Oracle (at least, I have not looked into this) and
you might need to resort to using OCI::Oracle to get this level of
control.

On another note, I as a DBA am horrified to see this type of coding
practice.  Building dynamic SQL, especially in a high transaction
environment, will wreak havoc on your instance's SGA.  This type of
application coding is the number one way to keep an application from
scaling.

Just something to think about.

--
Ron Reidy
Lead DBA
Array BioPharma, Inc.

-----Original Message-----
From: Berlage, Steve [mailto:[EMAIL PROTECTED] 
Sent: Thursday, November 09, 2006 3:37 PM
To: [email protected]
Subject: Bind variable question


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 :)




Thanks,




Steve



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.

This electronic message transmission is a PRIVATE communication which contains
information which may be confidential or privileged. The information is 
intended 
to be for the use of the individual or entity named above. If you are not the 
intended recipient, please be aware that any disclosure, copying, distribution 
or use of the contents of this information is prohibited. Please notify the
sender  of the delivery error by replying to this message, or notify us by
telephone (877-633-2436, ext. 0), and then delete it from your system.

Reply via email to