Note that there are some explanatory texts on larger screens.

plurals
  1. POSQLite with Ansi C and xCode
    primarykey
    data
    text
    <p>I'm starting from the bottom-up to learn iPad development after 15 years with Cold Fusion. I'm getting comfortable with Ansi C and xCode, but am stumped taking the next step with SQLite. </p> <p>I've built a database (Airports.sqlite) with razorSQL and installed it in the same directory as main.c where I've also installed the amalgamated sqlite3.h and sqlite3.h files.</p> <p>Everything compiles OK, but I get the following message when I Run...</p> <p>Error in select statement select Length from Runways order by Length desc limit 5 [no such table: Runways].</p> <p>The database definitely has the Runways table in it. Can someone set me straight? Here's the code:</p> <hr> <pre><code>#include &lt;stdio.h&gt; #include &lt;stdlib.h&gt; #include &lt;string.h&gt; #include "sqlite3.h" #include "weightbalance.h" sqlite3* db; int first_row; int select_callback(void *p_data, int num_fields, char **p_fields, char **p_col_names) { int i; int *p_rn = (int*)p_data; if (first_row) { first_row = 0; for(i=0; i &lt; num_fields; i++) { printf("%20s", p_col_names[i]); } printf("\n"); for(i=0; i&lt; num_fields*20; i++) { printf("="); } printf("\n"); } (*p_rn)++; for(i=0; i &lt; num_fields; i++) { printf("%20s", p_fields[i]); } printf("\n"); return 0; } void select_stmt(const char* stmt) { char *errmsg; int ret; int nrecs = 0; first_row = 1; ret = sqlite3_exec(db, stmt, select_callback, &amp;nrecs, &amp;errmsg); if(ret!=SQLITE_OK) { printf("Error in select statement %s [%s].\n", stmt, errmsg); } else { printf("\n %d records returned.\n", nrecs); } } void sql_stmt(const char* stmt) { char *errmsg; int ret; ret = sqlite3_exec(db, stmt, 0, 0, &amp;errmsg); if(ret != SQLITE_OK) { printf("Error in statement: %s [%s].\n", stmt, errmsg); } } int main() { sqlite3_open("Airports.sqlite", &amp;db); if(db == 0) { printf("Could not open database."); return 1; } printf("\nSelecting Airports with the longest runways.\n\n"); select_stmt("select Length from Runways order by Length desc limit 5"); sqlite3_close(db); return 0; } </code></pre>
    singulars
    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.
 

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