It's getting late here and my brain is fried, so I am casting this problem out to the monks to help me if possible.
I am writing a DBD::ANYDATA sql script (below) which I want to update the "wins" field in an existing table. I presently get the following error:
Execution ERROR: No such column 'JUDOKA.WINS' called from /nfs/cust/4/7/3/judoco/e-judo/simulate.cgi at 197.
The segment of code in question is:
# Use DBI to connect to the judoka_csv datafile
my $dbh = DBI->connect('dbi:AnyData(RaiseError=>1):'); #
+tell DBI we want to use the Anydata module in ./MyLibs
$dbh->func( 'judoka', 'CSV', 'data/judoka_csv', 'ad_catal
+og'); # Connect to the users_csv data file
# select from the datafile the id for the user ID from th
+e array paased from the previous sub routine
my $sql_query = "SELECT * FROM judoka WHERE judoka_id = ?
+"; # this is the SQL command we want to execute
my $sql_params = ($winner); # Th
+eese are the parameteres we will use in the SQL command above
print $query->p("$sql_query\n[$sql_params]\n") if $DEBUG;
+ # if we are in debug mode print the SQL statement
my $sth = $dbh->prepare( $sql_query );
+ # prepare the SQL command
$sth->execute( $sql_params );
+# excecute the SQL using our parameters
my @winner_data = $sth->fetchrow_array; # this line takes
+ the results of the select and puts it in the array called RESULTS
$dbh->disconnect(); # we are done with the datbase for no
+w, so disconnect from it (MAY NOT BE NECESSARY)
print $query->p("result = ", @winner_data)if $DEBUG;
+ # Prints the result of our SQL command if we are in debug
# grab the number of wins and then add one to it and inse
+rt back into the DB
my $wins = $winner_data + 1;
print $query->p("winner =",$winner," and Wins = ", $wins)
my $sql_insert ="UPDATE judoka SET wins = ? WHERE judoka_
+id = ?";
my @sql_insert_params = ($wins,$winner);
print $query->p("$sql_insert\n[@sql_insert_params]\n") if
+ $DEBUG; # if we are in debug mode print the SQL stat
$sth = $dbh->prepare( $sql_insert );
+# prepare the SQL command
$sth->execute( @sql_insert_params );
+ # excecute the SQL using our parameters
Please forgive the messy code and what is no doubt a simple problem!
Kia Kaha, Kia Toa, Kia Manawanui!
Be Strong, Be Brave, Be perservering!
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.
| & || & |
| < || < |
| > || > |
| [ || [ |
| ] || ] ||