diff options
-rw-r--r-- | db_demo/db.c | 8 | ||||
-rw-r--r-- | db_demo/db_demo.ncb | bin | 887808 -> 887808 bytes | |||
-rw-r--r-- | db_demo/db_demo.suo | bin | 19968 -> 19968 bytes | |||
-rw-r--r-- | db_demo/main.c | 22 |
4 files changed, 27 insertions, 3 deletions
diff --git a/db_demo/db.c b/db_demo/db.c index 3a58c3f..ea82019 100644 --- a/db_demo/db.c +++ b/db_demo/db.c @@ -31,7 +31,7 @@ static int db_set_error(const char *f_pError) static void db_raise_warning(void)
{
- printf("Database exception!\n");
+// printf("Database exception!\n");
printf("%s", g_pError);
} // db_raise_warning
@@ -164,6 +164,8 @@ int db_output(void) }
}
+ printf("\n");
+
// print column names
for (i = 0; i < l_iNFields; i++)
{
@@ -215,6 +217,8 @@ int db_output(void) printf("\n");
}
+ printf("\nResults: %d\n\n", l_iNTuples);
+
return DB_OK;
} // db_output
@@ -251,7 +255,7 @@ int db_execute(const char* f_pQuery) }
else
{
- printf("%s\n", l_pCmdStatus);
+ printf("\n%s\n\n", l_pCmdStatus);
}
return DB_OK;
diff --git a/db_demo/db_demo.ncb b/db_demo/db_demo.ncb Binary files differindex 5f33877..8215619 100644 --- a/db_demo/db_demo.ncb +++ b/db_demo/db_demo.ncb diff --git a/db_demo/db_demo.suo b/db_demo/db_demo.suo Binary files differindex 9cb28c4..a05627e 100644 --- a/db_demo/db_demo.suo +++ b/db_demo/db_demo.suo diff --git a/db_demo/main.c b/db_demo/main.c index 37286f1..2120be9 100644 --- a/db_demo/main.c +++ b/db_demo/main.c @@ -1,9 +1,29 @@ +#include <stdio.h> +#include <stdlib.h> +#include <string.h> #include "db.h" +// prints a new line +void newline(void) { printf("%s> ", DBNAME); } + int main(int argc, char *argv[]) { + char string[1024]; + + printf("type exit and hit <enter> to quit the program...\n\n"); + db_init(); - db_execute("SELECT * FROM testicle ORDER BY teller"); + newline(); + + // parse user input + while (gets(string)) + { + if (!strcmp(string, "exit")) exit(0); + else if (!strcmp(string, "")) {} + else db_execute(string); + newline(); + } + db_close(); return 0; |