Skip to content

Instantly share code, notes, and snippets.

@rkitover
Created February 5, 2012 12:47
Show Gist options
  • Save rkitover/1745358 to your computer and use it in GitHub Desktop.
Save rkitover/1745358 to your computer and use it in GitHub Desktop.
Oracle LOBs ReWork Stage 1: LOB Writes
- test deprecated Oracle LOB types such as LONG as well
- steal code from ASE for insert(bulk)/update LOB handling:
- insert:
- throw on lack of PK/UK
- replace LOB binds with \'EMPTY_BLOB()' or \'EMPTY_CLOB()'
- start txn
- do insert
- save $pk_uk
- insert_lobs($pk_uk, $lobs)
- commit
- insert_bulk:
- mostly the same as insert
- if the PKs/UKs are provided, save them and call insert_lobs() for each
PK/UK, or pass them in as a range, whichever is more efficient in the
circumstance
- if the PKs/UKs are unavailable, throw, as they cannot be determined
- update:
- replace LOB binds with \'EMPTY_BLOB()' or \'EMPTY_CLOB()'
- start txn
- do update
- insert_lobs($where, $lobs)
- commit
- insert_lobs:
- local *$self::_dbh_sth = sub { ->prepare($sql, { ora_auto_lob => 0 }) };
- select $where FOR UPDATE (assume in txn)
- for each row
- get LOB locators
- for each LOB locator
- get chunk size
- write data from $lobs in chunk sizes
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment