Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
PerlMonks  

Re: Is there a module to generate SQL queries?

by andreychek (Parson)
on Oct 25, 2001 at 03:26 UTC ( #121314=note: print w/ replies, xml ) Need Help??


in reply to Is there a module to generate SQL queries?

I think DBIx::Recordset may do what you're looking for.

What it does is allow you to construction you SQL statements using a hash, with the hash keys mapping to field names, and the hash values mapping to the data in those fields. There is an article that appeared on perl.com that provides some examples of what all can be done with DBI::Recordset. Copying one of their examples, this seems to do what you are desiring:

DBIx::Recordset->Insert({%formdata,%dsn});

It can't get too much easier then that :-) However, the article also gives other examples of some pretty nifty things you can do with that module.

Additionally, to be fair to all sides, chromatic published an article in response to the one I linked above describing how you can use DBI to do similar tasks, and how best to make use of DBI's featureset.

I've never used it before, but I did just notice DBIx::SearchBuilder was uploaded to CPAN. It claims to assist in generating SELECT statements. Good luck!
-Eric


Comment on Re: Is there a module to generate SQL queries?
Download Code
Re: Re: Is there a module to generate SQL queries?
by rrwo (Friar) on Oct 25, 2001 at 06:03 UTC

    Thanks, but DBIx::RecordSet is definitely what I'm not looking for. DBIx::SearchBuilder looks nice, but like the former it does too much.

    I just want to create the SQL query, and then pass the parameters to the bindings. But I still want a statement handle to do what I will with.

    An aside: DBIx::SearchBuilder seems poorly documented, and specific to certain databases.

    Gripe: I can't stand it when there are modules that try to do everything (A+B+C), when I need a module to do A or B only, because I'm trying to do A+B+D instead. I do wish module authors would break up their modules into modules with distinct useful functions (i.e., SQL statement generation, statement handle searches, and then maybe a recordset add-on as all separate modules). It forces one to write portions of this from scratch! (Guess I'll E-mail the author about this....)

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others taking refuge in the Monastery: (6)
As of 2014-10-22 05:49 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    For retirement, I am banking on:










    Results (113 votes), past polls