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.
  • by Thos Davis (6347) on 2005.10.20 9:31 (#44036)

    While it still requires that you type the query correctly once, views are portable across relational databases (finally even MySQL as of 5.0)

    CREATE VIEW recipe_ingredient_list AS
      SELECT r.id, i.name
      FROM   ingredients i, recipe_ingredient ri, recipes r
      WHERE  r.id = ri.recipe_id
        AND  i.id = ri.ingredient_id

    so that you could use this query:

    SELECT name
    FROM   recipe_ingredient_list
    WHERE  id = ?

    And if you use PostgreSQL as the backend (some other RDBMSes have similar support, but MySQL does not), you can even make the view an updatable view by creating rules that will add appropriate entries to the base table whenever you send an INSERT, UPDATE, or DELETE instruction. And PostgreSQL will let you write the rules in Perl.

    • Aside from the "write rules in Perl" part, we actually use "updateable" views with Postgres (and SQLite) all the time where I work. It's very handy.