ADOdb

Database Abstraction Layer for PHP

User Tools

Site Tools


v5:database:oracle

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
v5:database:oracle [2022/07/13 02:57] – [oci8] mnewnhamv5:database:oracle [2023/01/25 04:40] (current) – [Auto-Increment Column] mnewnham
Line 92: Line 92:
 ==== Auto-Increment Column ==== ==== Auto-Increment Column ====
 [[v5:dictionary:column_attributes#AUTO or AUTOINCREMENT|Auto-increment]] support for Oracle databases is implemented by creating an on-insert trigger that retrieves a sequence number from a sequence //**SEQ_ + table name **//. This is done by default. [[v5:dictionary:column_attributes#AUTO or AUTOINCREMENT|Auto-increment]] support for Oracle databases is implemented by creating an on-insert trigger that retrieves a sequence number from a sequence //**SEQ_ + table name **//. This is done by default.
 +
 +If you have long table names then the generated trigger name can exceed the maximum allowed length. To prevent this, use the class variable ''useCompactAutoIncrements''. This will change the trigger name to a generated CRC value of the name. 
 +=== Example using the table name "customer_delivery_address" ===
 +By default, the trigger name would be SEQ_CUSTOMER_DELIVERY_ADDRESS which exceeds the 16 character name for sequences. By setting ''$db->useCompactAutoIncrements=true'', the sequence name is changed to ''SEQ_401703491''
 +
 +=== Accessing the trigger in your code ===
 +<code php>
 +
 +$db->useCompactAutoIncrements=true;
 +
 +$tab = 'customer_delivery_address';
 +$tab = sprintf('SEQ_%u',crc32(strtolower($tab)));
 +
 +print $tab; //prints SEQ_401703491
 +
 +</code>
 +
 ----------------------------------- -----------------------------------
 ==== Session Mode ==== ==== Session Mode ====
v5/database/oracle.1657673823.txt.gz · Last modified: 2022/07/13 02:57 by mnewnham