[Solar-talk] AutoIncrements in Oracle Adaptor

Kilbride, James P. James.Kilbride at gd-ais.com
Wed Feb 13 09:52:23 CST 2008


All,

So I'm just about done, maybe, I think, possibly, with an oracle adaptor
for solar. The last thing on my list is autoincrement. What I'm thinking
of doing is overloading the createTable function to do the following:

    public function createTable($table, $cols)
    {
        $this->_cache->deleteAll();
        $stmt = $this->_sqlCreateTable($table, $cols);
        $this->query($stmt);
        foreach ($cols as $name => $info) {
        	if($info['autoinc']){
	
$this->_createSequence($table.$name."_sequence", 1);
	   			$trigger = "  CREATE OR REPLACE TRIGGER
\"TRG_INSERT_$table$name\" 
    BEFORE INSERT
    ON $table
    REFERENCING NEW AS NEW
    FOR EACH ROW
    BEGIN
        SELECT $table$name"."_sequence.NEXTVAL INTO :NEW.$name FROM
dual;
    END;
    
/
ALTER TRIGGER \"TRG_INSERT_$table$name\" ENABLE;";
	   			$this->query($trigger);
        	}
    	}
    }

So, what do people think about this method of doing the table creation
and forcing the autocreations into oracle?

James Kilbride

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mailman-mail3.webfaction.com/pipermail/solar-talk/attachments/20080213/3d30d203/attachment.html


More information about the Solar-talk mailing list