Getting error 150 in sql and driving me mad

Discussion in 'Mac Programming' started by dukebound85, Jun 27, 2017.

  1. dukebound85 macrumors P6

    dukebound85

    Joined:
    Jul 17, 2005
    Location:
    5045 feet above sea level
    #1
    amyone know why I am getting this error? I can't seem to have the foreign key work
     

    Attached Files:

  2. chown33, Jun 27, 2017
    Last edited: Jun 27, 2017

    chown33 macrumors 604

    Joined:
    Aug 9, 2009
    #2
    Please copy and paste the complete actual text from the Terminal window.

    1. Your photo cuts off a significant part of the error message. Details are important in programming.

    2. Which SQL app or command-line tool is this appearing in? Again, details are important.

    3. The thread title says "error 150", but the picture shows "ERROR 1005" and "errno: 150". Those are different things.

    errno is an error variable, and the values it can take on are usually documented. See 'man 2 intro' (cmd to type in Terminal) for a discussion of errno and the typical system-provided values. 150 is well above that range, which suggests your SQL engine or app or tool is setting errno to that value. You'd have to refer to the programming manual to find out what an errno of 150 means. You might also find that the code in parens, i.e. HY1000, has some meaning for decoding the error.

    EDIT

    If you're using MySQL, try this syntax:
    FOREIGN KEY (PersonID) REFERENCES Persons(PersonID)

    Pulled from this page:
    https://www.w3schools.com/sql/sql_foreignkey.asp

    Found by googling: sql foreign key syntax


    If you're using sqliteN, it has the same syntax:
    https://sqlite.org/foreignkeys.html

    Found by googling: sqlite foreign key syntax
     

Share This Page