Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    Regular Coder
    Join Date
    Jul 2002
    Location
    Iran
    Posts
    695
    Thanks
    0
    Thanked 0 Times in 0 Posts

    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?

  • #2
    Regular Coder
    Join Date
    Jun 2002
    Location
    UK
    Posts
    577
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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.

  • #3
    Regular Coder
    Join Date
    Jul 2002
    Location
    Iran
    Posts
    695
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •