Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??
Hmmmm...this seems to be eluding me I have your suggestions in my code below:
#---SQL to change the column data for ($count = 0; $count < $EasySetDataCount; $count++) { #------Put quotes around data if needed $QuotedNewEasySetDataName = $dbh->quote($NewEasySetDataNames[$count]); $QuotedEasySetDataName = $dbh->quote($EasySetDataNames[$count]); #------Create SQL statement $sqlStatement = "UPDATE ".$ChosenEasySetTableName." SET ".$ChosenEasyS +etColumnName." = ".$NewEasySetDataNames[$count]." WHERE ".$ChosenEasy +SetColumnName." = ".$EasySetDataNames[$count]; #------print it out for debugging print $sqlStatement; #------prepare and execute $sqlCmd = $dbh->prepare( $sqlStatement ); $sqlCmd->execute() or die "SQL Error: $DBI::errstr\n"; }
And the run results...
Uncaught exception from user code: SQL Error: [Microsoft][ODBC SQL Server Driver][SQL Server]Inva +lid column name 'Other'. (SQL-42S22) [Microsoft][ODBC SQL Server Driver][SQL Server]Statement(s) could not +be prepared. (SQL-42000)(DBD: st_execute/SQLExecute err=-1) at C:\temp\EasySetRenameTool.pl line 155 Issuing rollback() for database handle being DESTROY'd without explici +t disconnect() at C:\temp\EasySetRenameTool.pl line 155, <STDIN> line + 5. UPDATE AI_ESP SET Race = red WHERE Race = Other
Note the lack of quotes in the Printed SQL at the end around RED and OTHER.
As I've only submitted a code snippet, line 155 refers to the $sqlCmd->execute(); line
If I manually put single quotes into the SQL it works. Or if I leave the quotes off and the dataset is numeric it works.
Do you believe in miracles? Yes!

In reply to Re^2: Database Insert Depending on Data Type by Olaf
in thread Database Insert Depending on Data Type by Olaf

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



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others sharing their wisdom with the Monastery: (4)
As of 2024-03-28 22:41 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found