Oracle Auto_Increment Error

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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

--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [PHP Users]     [Postgresql Discussion]     [Kernel Newbies]     [Postgresql]     [Yosemite News]

  Powered by Linux