1. Check out our companion app, Forums for Android! Download from Google Play

foreign key for sql lite

Discussion in 'Application Development' started by cowboy, Mar 22, 2010.

  1. cowboy

    cowboy New Member
    Thread Starter
    5

    Mar 22, 2010
    4
    0
    5
    Hello every one! I have some problem with my SQL request. I am trying to create tables like this :
    Code (Text):
    1.  myDB.execSQL("CREATE TABLE IF NOT EXISTS "
    2.               + categories
    3.               + " (category_id PRIMARY KEY,parent_id INT,FOREIGN KEY(parent_id) REFERENCES categories(category_id),name text,amount float);");
    4.       myDB.execSQL("CREATE TABLE IF NOT EXISTS "
    5.               + accounts
    6.               + " (account_id PRIMARY KEY, name text);");
    It is compiled ok. But then i tried to run it on emulator the app has dropped with error :
    APPLICATION HAS STOPPED UNEXPECTADLY.

    And i ve finded error occur in the FOREIGN KEY. WHAT problem?
     

    Advertisement

  2. kiranuday43

    kiranuday43 Member
    15

    Mar 3, 2010
    20
    0
    15
    FOREIGN_KEY is used between the two tables,,,I found that you are referencing the attribute in the same table,,,and two attributes name should be same,,
     

Share This Page

Loading...