Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.tools -> Re: Oracle/PHP Question

Re: Oracle/PHP Question

From: Kari Pannila <Xkartsa_at_ougf.fi>
Date: 2000/04/20
Message-ID: <38FECFB7.1C7FFB31@ougf.fi>#1/1

Hi

Look at a tutorial at: http://www.awtrey.com/support/dbeweb/

There is an example for Oracle too:
http://www.awtrey.com/files/php/guest_oracle.txt

Main points are here:

This is the SQL statement to create the database required for this application.

CREATE TABLE GUESTS (

  GUEST_ID       NUMBER (4)    NOT NULL,
  GUEST_NAME     VARCHAR2 (50),
  GUEST_EMAIL    VARCHAR2 (50),
  GUEST_TIME     DATE,
  GUEST_MESSAGE  VARCHAR2 (2000),

  PRIMARY KEY ( GUEST_ID )
) ;

CREATE SEQUENCE GUEST_ID_SEQ
  START WITH 0
  INCREMENT BY 1
  MINVALUE 0
  NOCACHE
  NOCYCLE ; <?

    ////////////////////////////////

    // This is the meat of the query that updates the guests table
    ////////////////////////////////

$query = "INSERT INTO guests ";
$query .= "(guest_id, guest_name, ";
$query .= "guest_email, guest_time, guest_message) ";
$query .=

"values(guest_id_seq.nextval,'$name','$email',SYSDATE,'$message')";
////////////////////////////////

// This is where we connect first time to the database
////////////////////////////////

$c1 = ocilogon("scott","tiger","dbougf");

   $stmt = ociparse($c1,$query);
    OCIexecute($stmt,OCI_DEFAULT);
    OCIFreeStatement($stmt);
    OCICommit;
?>

Kari

(Mr.) Kari Pannila
Oracle DBA (OCP)
TietoEnator Corp - Telecom

Delete X to get a correct mail address ( X is only for the SPAMMERS ).

phurley_at_austin.rr.com wrote:

> Does anyone have suggestions regarding this question:
>
> Oracle auto sequence insert.  Using PHP and Oracle, I would like to be
> able to insert a row and have the sequence automatically inserted with
> directly referring to sequencename.nextval in the insert.
>
> How can I go about setting up the table/trigger/whatever is needed to
> automatically insert the next sequence, much like AutoNumber in access
> and identity in SQL server.  Also, how would I retrieve the inserted
> id after the insert, to use it as a foreign key and such for another
> table.
>
> Thanks,
>
> ph.
Received on Thu Apr 20 2000 - 00:00:00 CDT

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US