CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Intermediate:
Help with DBI execute statement

 



Ben
Deleted

May 26, 2000, 1:45 AM

Post #1 of 4 (719 views)
Help with DBI execute statement Can't Post

I am trying to execute an SQL statement to a MS Access database, using a variable obtained from an Environmental variable Query String. The page the script is started from is a dynamically built page of data retrieved by another script. The two execute statements seem to be almost the same (excepting variables) to my eyes, but one works and the other doesn't. The error message returned is as follows;

DBD::ODBC::st execute failed: [Microsoft][ODBC Microsoft Access Driver] Too few parameters. Expected 7. (SQL-07001)(DBD: st_execute/SQLExecute err=-1) at clickmor.pl line 30. Couldn't execute statement: [Microsoft][ODBC Microsoft Access Driver] Too few parameters. Expected 7. (SQL-07001)(DBD: st_execute/SQLExecute err=-1).

The code sample is as follows;

$ID = $ENV{QUERY_STRING};
$sqlstate = "SELECT IDCode, aaaa, dd, ee, ff
FROM xxxx, yyyy, zzzz
WHERE IDCode = ? AND ff = 1 AND x.dd = y.dd etc...
my $sth = $dbh->prepare($sqlstate);
$sth->execute ($ID);

The actual select statement (Excuse me for not showing it all) contains almost forty elements. I had miss-typed one element in the SELECT statement, and by adding one extra letter, the error message returned with "expected 7" (see above) where before it had been "Expected 6".

This is a very frustrating problem as I cannot see what is being done incorrectly even though I compare it to the previous example I have that works.

Please HELP!!! (and Thank you to anyone that does...)


dws
Deleted

May 31, 2000, 10:07 AM

Post #2 of 4 (719 views)
Re: Help with DBI execute statement [In reply to] Can't Post

This is hard to diagnose without the complete select statement. The error message suggests that you're not supplying the right number of bindings for placeholders in the query, but your select shows one placeholder and one bound value.

Are you really listing tables as xxxx and then says x.dd instead of xxxx.dd?


Ben
Deleted

Jun 1, 2000, 8:35 AM

Post #3 of 4 (719 views)
Re: Help with DBI execute statement [In reply to] Can't Post

The full SQL statement with code is as follows;

$sqlstat = "SELECT M.IDCode, Name, Address1, Address2, T.Townname, T.Postcode, Type, Ratingstars, Telephone, Fax, Email, WebsiteURL, URLStatus, AdvanceDescript, Picture, Directions, Pricesinglefrom, Pricesingleto, Pricedoublefrom, Pricedoubleto, Pricextarriffrom, Pricextarriffto, Roomnumbers, Maxperson, Roomphone, TV, Movies, Pool/Spa, Dining,
NoChildren, Pets, Nonsmoke, Disabledaccess, Aircon/Heating, Cooking, Conference, PayVISA, PayAE, PayMC, PayBC, PayEFTPOS, PayMP, PayDC, PayJC, R.Region, State, Cutterbar
FROM Postcode_Townname T, Main M, Post_region P, Region R
WHERE M.IDCode = ? AND Advstatus = 1
AND M.CodeNo = T.CodeNo AND T.Postcode = P.Postcode AND P.Region = R.Region";

my $sth = $dbh->prepare($sqlstat)
$sth->execute($ID);



dws
Deleted

Jun 1, 2000, 11:32 AM

Post #4 of 4 (719 views)
Re: Help with DBI execute statement [In reply to] Can't Post

Could 'Pool/Spa' and 'Aircon/Heating' be part of the problem? Access (stupidly) allows slashes in field names, though they might be mistaken for division by some other part of the pipeline. What happens if you take those out of the query?


 
 


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives