Oracle Auto_Increment Error

From: Date: Tue, 14 Oct 2003 19:27:51 +0000
Subject: Oracle Auto_Increment Error
References: 1 2 3 4  Groups: php.db 
Request: Send a blank email to php-db+get-31002@lists.php.net to get a copy of this message
Hello, BACKGROUND: I'm able to create tables in oracle, populate fields in oracle tables, select, retrieve and update fields in oracle. So I know my connection code is working. PROBLEM: I'm working with PHP and PEAR and I'm trying to create an auto_increment field in an oracle database table. The table has 3 fields and they are id, firstName, and lastName. Below I have included my code for creating, sequencing and triggering the table. I'm also including my insert statement which is currently creating an error. All I get is "DB Error: unknown error". Can anyone please tell me why this error is being generated? CODE: //################ // This will create table //################ $sql = "CREATE TABLE test (id INT NOT NULL PRIMARY KEY, firstName VARCHAR(255) NOT NULL, lastName VARCHAR(255) NOT NULL)"; $result = $db->query($sql); if (DB::isError($result)) { die ($result->getMessage()); } //######## // sequence //######## $sql = "CREATE SEQUENCE test_seq start with 1 increment by 1 nomaxvalue"; $result = $db->query($sql); if (DB::isError($result)) { die ($result->getMessage()); } //############ // trigger //############ $sql = "CREATE TRIGGER test_trigger before insert on test for each row begin select test_seq.nextval into :new.id from dual"; $result = $db->query($sql); if (DB::isError($result)) { die ($result->getMessage()); } //######### // insert //######### $sql = "INSERT INTO test (firstName,lastName) VALUES ('Roger', 'Dodger')"; $result = $db->query($sql); if (DB::isError($result)) { die ($result->getMessage()); } Thanks in advance, Roger

« previous php.db (#31002) next »