sub __select_recordset{ my $loc_select = shift; #SQL SELECT clause my $loc_from = shift; #SQL FROM clause including join, if any my $loc_where = shift; #SQL WHERE clause my $loc_order = shift; #SQL ORDER BY clause my $loc_sth ; #Statement handle my $loc_sql_string; # Complete SQL string without ";" # # Removes leading and training whitespace from parameters. # if (__trim($loc_where) ne "" ){ $loc_sql_string = "select ".__trim($loc_select)." from "._ +_trim($loc_from)." where ".__trim($loc_where)." order by ".__trim($lo +c_order); } else { $loc_sql_string = "select ".__trim($loc_select)." from ". +__trim($loc_from)." order by ".__trim($loc_order); } $loc_sth=$gl_dbh->prepare($loc_sql_string) or die "Can't prepare s +ql statement" . DBI->errstr; $loc_sth->execute() or die "Can't execute sql statement" . DBI->er +rstr; return $loc_sth; }
I have a few comments:
1. In Perl there is normally not a good reason for using double underscore before a sub name. I am curious as to why you are doing that?
2. Your preamble to select_recordset() could be shorter:
sub select_record_set { my ($SQL_select_clause, #I just named the vars according to $SQL_from_clause, #your comment code $SQL_where_clause, #pick new names if you like $SQL_order_by_clause, #pick a name that renders #the #comment useless ) = @_; my $statement_handle = (); #not sure that you need these my $sql_string = (); #vars # I get lost here.... # prepare(), execute() # for that matter, if you are passing in an SQL statement, # why do you need the $SQL vars above? Prepare the statement and # then run it. }
I will defer to SQL DB Monks. I don't understand how your code is supposed to work.

In reply to Re: Application Error by Marshall
in thread Application Error by Steve_BZ

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



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.