Note that there are some explanatory texts on larger screens.

plurals
  1. POcreating a foreign key in sqlite database
    primarykey
    data
    text
    <p>i need to create a foreign key to map my tables. Basically this foreign is a primary key of a table. but the insert statement is creting an issue. Its an SQLite database. the table with the primary key is</p> <pre><code>db.execSQL("CREATE TABLE IF NOT EXISTS " + Main + "(ROWID integer primary key autoincrement NOT NULL,appln_date VARCHAR,appln_no VARCHAR,rupees VARCHAR,tenure VARCHAR,asset VARCHAR);"); </code></pre> <p>the table with the foreign key is </p> <pre><code>db.execSQL("CREATE TABLE IF NOT EXISTS " + Applicant + "(AppID integer primary key autoincrement, " + "app_salutation VARCHAR,app_fname VARCHAR,app_mname VARCHAR,app_lname VARCHAR,app_door VARCHAR,app_street VARCHAR,app_building VARCHAR,app_area VARCHAR,app_post VARCHAR,app_tehsil VARCHAR,app_state VARCHAR,app_landmark VARCHAR,ROWID integer References "+Main+"(ROWID));"); </code></pre> <p>the insert statement is </p> <pre><code>openOrCreateDatabase(); createappinfo(); String insertString = "insert into " + Applicant + " Values("; String inString = ""; for (int i =0; i &lt; data.size(); i++) { inString = inString + "\"" + data.get(i) + "\","; } inString = inString.substring(0, inString.length() - 1); int row=db.rawQuery("select * from "+Main+";" ,null).getCount()+1; insertString = insertString + row+"," +inString + ");"; System.out.println("** insert value ** " + insertString); db.execSQL(insertString); closeDatabase(); </code></pre> <p>but this code is generating an error..</p> <pre><code>04-25 11:43:57.422: E/SQLiteLog(17825): (1) table applicanttable has 14 columns but 13 values were supplied </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload