Stories
Slash Boxes
Comments
NOTE: use Perl; is on undef hiatus. You can read content, but you can't post it. More info will be forthcoming forthcomingly.

All the Perl that's Practical to Extract and Report

The Fine Print: The following comments are owned by whoever posted them. We are not responsible for them in any way.
 Full
 Abbreviated
 Hidden
More | Login | Reply
Loading... please wait.
  • Paging (Score:3, Informative)

    I presume you've already done this [perl.org], since you mentioned nesting queries three levels deep.

    Learn from how we do it in Perl. Got useful functionality that looks ugly, even hacking the language? Encapsulate it in a module. Abstract out the parameters you need (lower bound, upper bound, maybe table name and where clause if you want to use dynamic SQL), then stick it in a stored procedure.

    Oracle PL/SQL Best Practices [oreilly.com] says:

    • SQL-04: Put single-row fetches inside functions; never hardcode a query in your b
    --
    J. David works really hard, has a passion for writing good software, and knows many of the world's best Perl programmers
    • Re:Paging (Score:3, Informative)

      by jdavidb (1361) on 2003.02.13 15:52 (#17002) Homepage Journal

      Hmm, even better, from the beginning of the chapter:

      SQL-00: Establish and follow clear rules for how to write SQL in your application.

      • Never repeat a SQL statement.
      • Encapsulate all SQL statements behind a procedural interface (usually a package).
      • Write your code assuming that the underlying data structures will change.
      • Take advantage of PL/SQL-specific enhancements for SQL.

      Okay, not all of that was relevant here, but the point was, once you've written the triple-nested select, encapsulate so from now on you can use a page.next50entries routine.

      --
      J. David works really hard, has a passion for writing good software, and knows many of the world's best Perl programmers