|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
You don't need a fax machine to get faxes. Get a fax-to-email fax number from CallWave. Try it free.
|
|
#1
|
||||
|
||||
|
CFQUERY problem
I have a form where the user will enter a new record into a table. I have to check to make sure that the primary key they enter does not already exist in the table. My query looks as such so far, but is not working... any ideas?
Code:
<CFQUERY datasource="#DataSource#" name="blah">
IF #form.itemID# NOT IN(SELECT ItemID FROM MerchandiseOrder)
BEGIN
INSERT INTO Merchandise (col1...) VALUES ('col1'...)
END
</CFQUERY>
Anyone see a problem? This is SQL Server 2000 if it matters....
__________________
Reinventing the wheel again |
|
#2
|
||||
|
||||
|
Nevermind, wrong table name(s) used.... dumb error (as always)
|
|
#3
|
|||
|
|||
|
Just a heads up, it is TERRIBLE practice to allow for the updating of keys in the DB. You then have to forever rely on checking duplicates, cathcing errors, etc, etc..
|
|
#4
|
||||
|
||||
|
mtangorre, i'm sure you have something in mind, but i don't think it came out the way you wanted
keys do change, in real life and in databases there are ways to handle it for example, to prevent dupes, you use a unique constraint |
|
#5
|
||||
|
||||
|
mateoc15, if you are ever faced with how to prevent insertion of a duplicate, my advice is to let the database do the check, don't try to do it yourself, because in general if you do it yourself, your performance is cut in half
read this thread -- http://forums.devshed.com/showthrea...&threadid=82365 |
![]() |
| Viewing: Dev Shed Forums > Programming Languages - More > ColdFusion Development > CFQUERY problem |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|
|