If I understand what you are wanting to do, why not just have the file in
the ACTION arguement of the FORM tag first perform the search against the
database to see if the string is unique (SELECT COUNT(*) FROM $database
WHERE $column = $value) , then based on the results of that search (which
will be either 0 if it does not exist, or 1 if it does) call one of two
subroutines within that perl file. One of the subroutines contains the HTML
to inform the user that the value is not unique, and also containing a link
to return to the input form page. The second subroutine is called if no
identical value appears in the database, and this second subroutine contains
the insert to the database, and the HTML to inform the user that the
contents of the form have been successfully input to the database.
If you prefer your option 1 (Probably would be my preference), then perform
the same search on the database, and based on the results ( 0 or 1) of that
count search, either insert as the value stands, or append something onto
the end. However, if this is done, you might want to plan for the
possibility that many duplicates of the input value could be input, and
build your routine to handle it.
Steve Howard
-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]
Sent: Sunday, April 22, 2001 2:59 AM
To: [EMAIL PROTECTED]; [EMAIL PROTECTED];
[EMAIL PROTECTED]
Cc: [EMAIL PROTECTED]
Subject: Force unique input to field from web form into Oracle primary
key field...
Help???
This must be a common thing to do but have not seen an example to
reference.
Must create a web input form dialogue box ( dbi/oracle/CGI module )
which allows user to input a string. String will be placed in
table if it is unique. String must be unique since it
is to be placed into a primary key field. How would one force
or promt the user to enter a unique string by either:
1.) appending some characters onto the string before being inserted
into database ( in case there is an identicle string in the table
already - meaning the database requires a search for that string
on the table in question before each insert )
OR
2.) gracefully, have the form respond to user that the string is already in
the database (meaning a search must happen once the string is entered
form
the form before attempting to place it into database. User must then
pick a new
string if search comes back positive. Or user could then use the
string
already found in the database as his form input ( upon being alerted
after selecting the already present string). At that point the string
is
not inserted into database but used nonetheless as part of the users
choice" to then do other operations with it.
OR
3.) any idea is welcome similar to or combining ideas from 1) & 2).