Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

Current version of code used to produce trace() results above in thread

by jerrygarciuh (Curate)
on Apr 15, 2002 at 13:21 UTC ( [id://159171]=note: print w/replies, xml ) Need Help??


in reply to DBI SQL Syntax Problem

Thx for looking!
jg
$sth = $dbh-> prepare("UPDATE $calendar_table SET year = ?, month = ?, day = ?, time_start = ?, time_end = ?, title = ?, location = ?, description = ?, category = ?, posted_by = ?, post_date = ?, b_time = ?, e_time = ?, WHERE year = ?, AND month = ?, AND day = ?, AND time_start = ?, AND time_end = ?, AND title = ?, "); $sth->bind_param(1, "$form_data{'year'}"); $sth->bind_param(2, "$form_data{'month'}"); $sth->bind_param(3, "$form_data{'day'}"); $sth->bind_param(4, "@start_time"); $sth->bind_param(5, "@end_time"); $sth->bind_param(6, "$form_data{'title'}"); $sth->bind_param(7, "$form_data{'location'}"); $sth->bind_param(8, "$form_data{'description'}"); $sth->bind_param(9, "$form_data{'category'}"); $sth->bind_param(10, "$form_data{'posted_by'}"); $sth->bind_param(11, "$form_data{'post_date'}"); $sth->bind_param(12, "$b_time"); $sth->bind_param(13, "$e_time"); $sth->bind_param(14, "$form_data{'old_year'}"); $sth->bind_param(15, "$form_data{'old_month'}"); $sth->bind_param(16, "$form_data{'old_day'}"); $sth->bind_param(17, "$form_data{'old_start_time'}"); $sth->bind_param(18, "$form_data{'old_end_time'}"); $sth->bind_param(19, "$form_data{'old_title'}"); $sth->execute();
_____________________________________________________
Think a race on a horse on a ball with a fish! TG
  • Comment on Current version of code used to produce trace() results above in thread
  • Download Code

Replies are listed 'Best First'.
Re: Current version of code used to produce trace() results above in thread
by Sidhekin (Priest) on Apr 15, 2002 at 13:32 UTC

    You want to lose the two trailing commas (SQL is so not Perl). Also, where you use AND (in the WHERE clause), you don't want commas at all.

    Any one of these SQL mistakes is a syntax error with any database server I ever tried.

    The Sidhekin
    print "Just another Perl ${\(trickster and hacker)},"

Re: Current version of code used to produce trace() results above in thread
by wardk (Deacon) on Apr 15, 2002 at 15:17 UTC
    In the above SQL you (still) have commas in your WHERE clause. the SQL below should be valid, assuming that the values you are binding conform to the column data types. (Note that the last comma after e_time set is invalid preceeding the WHERE.)

    One thing that works well for me when confronted by sql coding problems is to create the SQL standalone and execute it (for instance via SQLPlus (or mySQL equivalent)) until it's syntactically correct, then take that SQL and implement it. I suspect among other things, the '12:00 PM' has a problem with the space-PM, and time_end = '01:00 ' has issues with the trailing space (chomp?).

    $sth = $dbh-> prepare("UPDATE $calendar_table SET year = ?, month = ?, day = ?, time_start = ?, time_end = ?, title = ?, location = ?, description = ?, category = ?, posted_by = ?, post_date = ?, b_time = ?, e_time = ? WHERE year = ? AND month = ? AND day = ? AND time_start = ? AND time_end = ? AND title = ? ");

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://159171]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others chanting in the Monastery: (9)
As of 2024-04-16 08:43 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found