Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??

At this point, I've only used a combination of Tcl and SQL to query a database.
IMHO, I think it's irrelevant which languages you're using, things are really going to get confusing if you've got a mix of scripting, markup and SQL unless you format everything to the point of excess.

Have a look at Philip Greenspun's SQL for Web Nerds, particularly the style section.
It's all Oracle8i stuff, but it should apply to anything with SQL.

When I've coded scripts with large SQL queries, I often put the query into a string:

my $query = "SELECT post, post_time, user_id, post_id FROM my_table WHERE post_time > sysdate + 1 ORDER BY post_id;";
Then query the database with the command required (can't do it in Perl yet :-) with $query in that command instead of a lump of SQL and scripting/Perl mashed together.

Even if you don't like my idea of having the query seperate, or it's impossible, then just get used formatting the queries so that they stand out from the Perl and are readable as SQL.

Hope that helps,

BazB.

Update: Seems like a slight more Perl-y way of doing this might be to use HERE documents, as described in this node by steves.

Further update: fixed the link to SQL for Web Nerds


In reply to Re: dbi style questions (code, discussion) by BazB
in thread dbi style questions (code, discussion) by deprecated

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others having an uproarious good time at the Monastery: (5)
As of 2024-04-25 16:55 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found