...

View Full Version : Finding out if a constraint name already exists



ConfusedOfLife
11-01-2002, 11:46 PM
I make a new rule like :

create rule myName
as @whatever ......


But if I wana have a script that correctly works whenever that I call it, I have to find out if myName already exists and if it does, I drop it by drop rule command, but how can I find out if a rule/default/constraint name already exists?

Íkii
11-02-2002, 12:04 PM
You might need to give a tad more information, namely the class actions that you are using.

At a guess, you want to make sure username12 hasn't already been taken?
If so... one way is to set the 'username' field in mysql to unique and test the mysql_affected_rows after the insert.

$input = mysql_query("INSERT INTO `table`(username) VALUES('$username')");
if(mysql_affected_rows == 0) {echo 'username already taken';}

Flytyped so syntax might be dodgy - should get the idea across though.

ConfusedOfLife
11-03-2002, 08:54 PM
Thanx but I didn't mean that! maybe what I'm asking isn't mySQL and it's just simple sql, but I just wana have the list of all my rules or constraints, those that I defined myself.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum