Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
PerlMonks  

Re: DBI SQL Query Question

by scain (Curate)
on Jan 11, 2002 at 23:03 UTC ( [id://138094]=note: print w/replies, xml ) Need Help??


in reply to DBI SQL Query Question

This is a guess, as I can't use placeholders with Freetds/MS SQL Server/DBI, but do you have a quote problem? Should the query line look like this instead:
$UniqueDay = "SELECT count(*) as COUNT, max(time) as MAX, min(time) as + MIN, attacksignature from np_data where month=\'?\' and day=\'?\' gr +oup by attacksignature order by COUNT desc";
At any rate, look at $unique_events_sth->errstr for more info

Scott

Replies are listed 'Best First'.
Re: Re: DBI SQL Query Question
by ehdonhon (Curate) on Jan 11, 2002 at 23:40 UTC

    DBI always auto quotes placeholders. Which can be annoying if you want to use a placeholder to represent what you are selecting and not what you are comparing.

    ## You can do this, and not worry about quoting: $query = "SELECT x, y, z from table where a = ?"; ## This doesn't work the way you think it does: $query = "SELECT ? from table where a = 'blah'";

    In the case of the second example above, if you provided "field1" to be bound to the placeholder, you would get: SELECT "field1" from table where a = 'blah', which means you would get a bunch of results that all say "field1".

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others pondering the Monastery: (4)
As of 2024-09-08 00:27 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?
    erzuuli‥ 🛈The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.