|
Posted by My Pet Programmer on 12/23/07 06:35
Steve said:
> "Betikci Boris" <pardust@gmail.com> wrote in message
> news:c4a99ce2-fed1-4c4b-b6c1-b27167e23bd9@1g2000hsl.googlegroups.com...
> On Dec 21, 2:57 am, "tes...@hotmail.com" <tes...@hotmail.com> wrote:
>> I have my PHP inserting into Oracle 9i.
>> But how do I prevent duplicate record entries?
>>
>> I only have 3 fields in the insert in the action page:
>>
>> CODE
>> <?php
>> $c=OCILogon("scott", "tiger", "orcl");
>> if ( ! $c ) {
>> echo "Unable to connect: " . var_dump( OCIError() );
>> die();
>> }
>>
>> $s = OCIParse($c, "INSERT INTO personTable
>> (firstname,lastname,emailaddress) VALUES
>> ($_POST[firstname],'$_POST[lastname]','$_POST[emailaddress]'");
>> OCIExecute($s, OCI_DEFAULT);
>> echo "Record successfully entered";
>> ?>
>>
>> How do I prevent duplicate record info and show the user they entered
>> duplicate info.
I'm no Oracle guru, but don't they have primary keys? Hell, if all you
want is to prevent dupes, make all three fields a combined key.
http://download-uk.oracle.com/docs/cd/B10501_01/server.920/a96524/c22integ.htm#1975
Or you could do a select count(*) (However oracle phrases it) where the
fields match.
~A!
Navigation:
[Reply to this message]
|