Go Back   CodingForums.com > :: Server side development > MySQL

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 11-01-2002, 11:46 PM   PM User | #1
ConfusedOfLife
Regular Coder

 
Join Date: Jul 2002
Location: Iran
Posts: 695
Thanks: 0
Thanked 0 Times in 0 Posts
ConfusedOfLife is an unknown quantity at this point
Finding out if a constraint name already exists

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?
ConfusedOfLife is offline   Reply With Quote
Old 11-02-2002, 12:04 PM   PM User | #2
Ökii
Regular Coder

 
Join Date: Jun 2002
Location: UK
Posts: 577
Thanks: 0
Thanked 0 Times in 0 Posts
Ökii is an unknown quantity at this point
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.
__________________
Ökii - formerly pootergeist
teckis - take your time and it'll save you time.
Ökii is offline   Reply With Quote
Old 11-03-2002, 08:54 PM   PM User | #3
ConfusedOfLife
Regular Coder

 
Join Date: Jul 2002
Location: Iran
Posts: 695
Thanks: 0
Thanked 0 Times in 0 Posts
ConfusedOfLife is an unknown quantity at this point
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.
ConfusedOfLife is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 12:32 AM.


Advertisement
Log in to turn off these ads.