SQL/Perl DBI question

cliftonite

Diamond Member
Jul 15, 2001
6,899
63
91
Writing a script that reads a log file and parses some data from it.(this part works) Now I want to insert that data into a database that I created. The table design is:

XXX(PK) y1 y2 y3 y4 x1


Now there cant be more than one xxx, however for each xxx there can be different y. So if the table is empty then I can put in xxx and the first instance of y into y1. If xxx comes again then i want to avoid inserting it (to avoid sql error) and check if y =y1. If it is then I will be done, if not then put it in y2, etc. I am trying to implement the first part (avoid inserting xxx more than once) and am having some diffculties.





I have tried many variations of this but none seem to stop the xxx from being inserted multiple times. st execute failed: Duplicate entry 'sdfsd' for key 1 at ./test.cgi line 72 is the error i get :(




 

cliftonite

Diamond Member
Jul 15, 2001
6,899
63
91
Originally posted by: screw3d
Pardon the SQL noob.. but where is line 72?


$sql_statement = "INSERT into xXX (NPANXX, proxy, g1) values ('$xxx', '$proxy', ' $asdf');";
 

notfred

Lifer
Feb 12, 2001
38,241
4
0
Use the "attach code" feature and get something on here that I can actually read. The insert statement that is giving yo uthe problems isn't even in the code in the first post.
 

screw3d

Diamond Member
Nov 6, 2001
6,906
1
76
Did you enforce "UNIQUE" on XXX? I think this will prevent duplicate entries on the database end.. but you probably still have to fix your Perl code to prevent that in the first place.