CSS Selector Browser Support

October 28, 2008 | 3 Comments

As many web developers know, CSS support is highly varied amongst browsers. I often find myself hunting for which selectors are more heavily supported. As such, I thought I’d post a direct link to a quality resource here so I wouldn’t have to hunt anywhere besides on BorkWeb.

Here’s some decent resources:

Oracle 10g: Using The Returning Clause With ADOdb

October 21, 2008 | 1 Comment

Plymouth State University uses Oracle heavily due to its Student Information System of choice - SungardHE Banner. As such, I play around in Oracle a lot (sometimes a lot more than I'd like) and I occasionally find functionality that seems more cumbersome than it should.

One such item is selecting the last inserted value on an auto-incrementing column.

Historically, when you are inserting into a table with auto incrementing values (via a sequence) you have always been able to grab the last value with a simple SELECT statement (line 22):

SQL:
  1. -- setup a table
  2. CREATE TABLE bork (id INTEGER NOT NULL PRIMARY KEY, DATA VARCHAR2(10) NOT NULL);
  3.  
  4. -- create the sequence
  5. CREATE SEQUENCE sq_bork INCREMENT BY 1 START WITH 1;
  6.  
  7. -- create a trigger for auto-incrementing the sequence'
  8. CREATE OR REPLACE TRIGGER tr_sq_bork
  9. BEFORE INSERT
  10. ON bork
  11. REFERENCING NEW AS NEW
  12. FOR EACH ROW
  13. BEGIN
  14. SELECT sq_bork.NEXTVAL INTO :NEW.id FROM DUAL;
  15. END;
  16. /
  17.  
  18. -- insert a record into the table
  19. INSERT INTO bork (name) VALUES ('Matt');
  20.  
  21. -- retrieve last inserted id
  22. SELECT sq_bork.CURRVAL FROM dual;

As you see there, two statements must be executed to get that new id. The INSERT and the SELECT. Well, as of Oracle 10g you can utilize the RETURNING clause like so:

SQL:
  1. INSERT INTO bork (name) VALUES ('Matt') RETURNING id INTO i_id;

That statement inserts a record into "bork" and returns the value of "id" into the "i_id" variable. Pretty sexy and all with one DML statement. Here's what we do at Plymouth to utilize the RETURNING clause with the PHP library ADOdb:

PHP:
  1. <?php
  2. //do your database object initialization here:
  3. //$db = new ADONewConnection...
  4.  
  5. $sql = "BEGIN INSERT INTO bork (data) VALUES ('Matt') RETURNING id INTO :i_id; END;";
  6. $stmt = $db->PrepareSP($sql);
  7. $db->OutParameter($stmt, $inserted_id, 'i_id');
  8. $db->Execute($stmt);
  9. ?>

Yup. 4 lines of PHP but only 1 statement sent to the database! I'd take the extra lines any day over the latency of data retrieval.