Skip to Main Content

DevOps, CI/CD and Automation

Announcement

For appeals, questions and feedback, please email oracle-forums_moderators_us@oracle.com

How to store the value a oracle sequence?

952056Sep 28 2012 — edited Oct 2 2012
Regards;

I have a Table with a ID column, this column is the Primary Key. I have a sequence for store the value of ID. The code what I use is the next:
(Other form send the value of fields)

$conn = oci_connect("USER","PASSWORD","SID");

for($i=1;$i<=$_POST["hdnLine"];$i++)
{

$strSQL = "INSERT INTO CAT_HOST_IP (ID_CAT_HOST_IP, HOST, IP, AUTORIZACION, COMENTARIOS)";
$strSQL .="VALUES ";
$strSQL .="(".S_CAT_HOST_IP.NEXTVAL.",'".$_POST["txtHost$i"]."', ";
$strSQL .="'".$_POST["txtIP$i"]."','".$_POST["txtAutorizacion$i"]."', ";
$strSQL .="'".$_POST["txtComentarios$i"]."') ";

echo $strSQL. "<br>\n";

$objParse = oci_parse($conn, $strSQL);
$objExecute = oci_execute($objParse, OCI_DEFAULT);
}
oci_close($conn);

When display $strSQL is this the result:

INSERT INTO CAT_HOST_IP (ID_CAT_HOST_IP, HOST, IP, AUTORIZACION, COMENTARIOS)VALUES (S_CAT_HOST_IPNEXTVAL,'HOST', 'IP','SI', 'Comentario')

I can't obtain the value of S_CAT_HOST_IPNEXTVAL. obviously the next message is displayed
Warning: oci_execute() [function.oci-execute]: ORA-00984: column not allowed here in C:\AppServ\www\Multiple_Insert_CatHost02.php on line 55

I hope can Help me. Thanks!
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Oct 30 2012
Added on Sep 28 2012
4 comments
2,687 views