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

Re^3: SQL error

by Anonymous Monk
on Aug 13, 2004 at 13:48 UTC ( [id://382669]=note: print w/replies, xml ) Need Help??


in reply to Re^2: SQL error
in thread SQL error

The over all goal is to grab certain information out of the database and export to ms word. Right now i am exporting to txt. Do yall know a why to export to MS Word?

Replies are listed 'Best First'.
Re^4: SQL error
by bassplayer (Monsignor) on Aug 13, 2004 at 15:07 UTC
    For creating MS Word documents on a Windows machine, look into the Win32::OLE module. There are plenty of code examples, in the documentation (mostly Excel but can easily be converted), on this site (try a Super Search), or via the all knowing google.

    bassplayer

Re^4: SQL error
by Anonymous Monk on Aug 13, 2004 at 13:53 UTC
    I bleive that is going to work thank you. But what is the reasoning for putting the q and the brackets.

      The q{} is irrelevant. The important change was the "FAIL" to 'FAIL'. I could have written it as

      $stg = $dbh->prepare( 'SELECT REFERENCE, REQUIREMENT FROM TestCasesOutput WHERE PassFail = + \'FAIL\'' );
      or
      $stg = $dbh->prepare( "SELECT REFERENCE, REQUIREMENT FROM TestCasesOutput WHERE PassFail = + 'FAIL'" );

      The problem was that only single quotes should be used to denote string literals in SQL. "Some Name" may be either a string or the name of a column or other object. Which is it depends on the database and its settings, but the later meaning is much more likely.

      I believe you got the misleading error message because Access tries to be helpfull and treats unknown column names as "query parameters". If you would run that query from within Access you'd get a popup dialog asking you to enter the value of "FAIL".

      Jenda
      Always code as if the guy who ends up maintaining your code will be a violent psychopath who knows where you live.
         -- Rick Osborne

      q{} treats the entire set of characters between the braces as single quoted. It's handy to use it for SQL because it removes the issue of getting confused and not closing all your quote marks in your SQL commands.

      So:

      q{This is a string} 'This is a string'
      are essentially the same thing.

      qq{}, incidentally, works the same way, only with double quotes

      Trek

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others cooling their heels in the Monastery: (5)
As of 2024-04-18 02:11 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found