Grygonos has asked for the wisdom of the Perl Monks concerning the following question:
Here is my code. I'm using MS-Access 97' unfortunately.
In my early DBI experience I had this problem occur and corrected it by changing the query to double quote the values... that was under MySQL (God I miss those days). Any possible remedies to this?
Thanks in advance, Gry
Ok here's my problem... the insert statement is inserting people's names in one field. Now if someone's name such as O'Sullivan occurs... then this piece of code will foobar because of the single quoting in the VALUES portion of the insert statement. However, when I try and double quote it... it tells me it expects 3 parameters.#Compile all records under a clients aliases foreach $alias (@aliases) { $query = "SELECT collection_information.[field1], "; $query .= "collection_information.[field2], collection_informat +ion.[name] "; $query .= "FROM collection_information WHERE CLIENT=\'" . $alia +s ."\'"; $sth = $dbh->prepare($query); $sth->execute(); #For each record returned while(my @record = $sth->fetchrow_array) { #Insert the record into the database $query = "INSERT INTO " . $client{'name'} ."_table "; $query .= "([field1],[field2],[name]) VALUES "; $query .= "(\'".$record[0]."\',\'".$record[1]."\',\'".$record[ +2]."\')"; $dbh->do($query); } $sth->finish(); }
In my early DBI experience I had this problem occur and corrected it by changing the query to double quote the values... that was under MySQL (God I miss those days). Any possible remedies to this?
Thanks in advance, Gry
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Quoting problem in DBI:ODBC
by hmerrill (Friar) on Jun 27, 2003 at 19:31 UTC | |
by Grygonos (Chaplain) on Jun 28, 2003 at 03:51 UTC | |
Re: Quoting problem in DBI:ODBC
by Grygonos (Chaplain) on Jun 27, 2003 at 15:19 UTC | |
by Seumas (Curate) on Jun 27, 2003 at 15:49 UTC |
Back to
Seekers of Perl Wisdom