1. db_insert/db_create_table/db_select_table
- Posted by rubis at fem.unicamp.br Jun 15, 2002
- 453 views
I just discovered that the command (db_create_table) didn't set the current table in a euphoria database as it says in the database.htm document. It needs the command db_select_table before any db_insert, or else I will get a missing variable key_pointer. As I lost some hours trying to discover what was going wrong, I think this is a good idea to share. This does not work: include database.e integer db db=db_create("banana.edb",DB_LOCK_NO) db= db_open("banana.edb",DB_LOCK_NO) db_create_table("table") db_insert(x1,x2) but this works: include database.e integer db db=db_create("banana.edb",DB_LOCK_NO) db= db_open("banana.edb",DB_LOCK_NO) db_create_table("table") db_select_table("table") db_insert(x1,x2) Please, correct me if I'm wrong. bye Rubens
2. Re: db_insert/db_create_table/db_select_table
- Posted by Robert Craig <rds at RapidEuphoria.com> Jun 15, 2002
- 483 views
Rubens writes: > I just discovered that the command (db_create_table) didn't > set the current > table in a euphoria database as it says in the database.htm document. It > needs the command db_select_table before any db_insert, or else I will get > a missing variable key_pointer. > ... > db=db_create("banana.edb",DB_LOCK_NO) > db= db_open("banana.edb",DB_LOCK_NO) > db_create_table("table") > db_insert(x1,x2) Most of the db_ routines return an error code that you are not checking. I suspect that the table "table" already existed when you called db_create_table. In this case db_create_table will return the code DB_EXISTS_ALREADY, and it will not change the current table. Also, I think it's better if you try db_open() before you try db_create(). If the database already exists, you just want to open it, not create it again. Furthermore, after successfully creating a database, you needn't (and shouldn't) open it. Regards, Rob Craig Rapid Deployment Software http://www.RapidEuphoria.com