1. Database.e; db_select(); Can't make it work...

I got a program that have 2 ".edb" files, and I'm trying to use db_select()
to switch between the three.

When the program starts, it checks to see if the 2 files exists, and if they
don't - it creates them using the db_create().

Now, I thought that when using db_create() - this also acts as db_open() and
keeps those databases open, and that I'm then able to use db_select() to
switch between them.

Example;

<EuCode>
  sequence jStatus
  jStatus = {}
  --
  jStatus &= db_select("c:\\Metadata.edb")
  jStatus &= db_create_table("TBL_DOCUMENTS")
  --
  jStatus &= db_select("c:\\System.edb")
  jStatus &= db_create_table("IDX_DOCUMENTS")
  jStatus &= db_select_table("SYS_HEADINGS")
  jStatus &= db_insert("TBL_DOCUMENTS", "STR_DOC_NO", "STR_DOC_TITLE")
  jStatus &= db_select_table("SYS_AUTONUMBER")
  jStatus &= db_insert("TBL_DOCUMENTS", {"DOC" & "#", 1})
  --
  jStatus &= db_select("c:\\Metadata.edb")
  jStatus &= db_select_table("TBL_DOCUMENTS")
</EuCode>


What happens here is that 2 tables are created in "Metadata.edb", but
the intention was that "TBL_DOCUMENTS" is created in "Metadata.edb",
and "IDX_DOCUMENTS" is created in "System.edb"..

Can anyone spot what I'm doing wrong?

Kenneth / ZNorQ

new topic     » topic index » view message » categorize

2. Re: Database.e; db_select(); Can't make it work...

>I got a program that have 2 ".edb" files, and I'm trying to use db_select()
>to switch between the three.

I meant between the TWO, ofcourse...

Kenneth / ZNorQ

new topic     » goto parent     » topic index » view message » categorize

3. Re: Database.e; db_select(); Can't make it work...

ZNorQ wrote:
> 
> I got a program that have 2 ".edb" files, and I'm trying to use db_select()
> to switch between the three.
> 
> When the program starts, it checks to see if the 2 files exists, and if they
> don't - it creates them using the db_create().
> 
> Now, I thought that when using db_create() - this also acts as db_open() and
> keeps those databases open, and that I'm then able to use db_select() to
> switch between them.
> 
> Example;
> 
> <font color="#330033"><EuCode></font>
> <font color="#FF00FF">  sequence </font><font color="#330033">jStatus</font>
> <font color="#330033">  jStatus = {}</font>
> <font color="#FF0055">  --</font>
> <font color="#330033">  jStatus &= db_select(</font><font
> color="#00A033">"c:\\Metadata.edb"</font><font color="#330033">)</font>
> <font color="#330033">  jStatus &= db_create_table(</font><font
> color="#00A033">"TBL_DOCUMENTS"</font><font color="#330033">)</font>
> <font color="#FF0055">  --</font>
> <font color="#330033">  jStatus &= db_select(</font><font
> color="#00A033">"c:\\System.edb"</font><font color="#330033">)</font>
> <font color="#330033">  jStatus &= db_create_table(</font><font
> color="#00A033">"IDX_DOCUMENTS"</font><font color="#330033">)</font>
> <font color="#330033">  jStatus &= db_select_table(</font><font
> color="#00A033">"SYS_HEADINGS"</font><font color="#330033">)</font>
> <font color="#330033">  jStatus &= db_insert(</font><font
> color="#00A033">"TBL_DOCUMENTS"</font><font color="#330033">, </font><font
> color="#00A033">"STR_DOC_NO"</font><font color="#330033">, </font><font
> color="#00A033">"STR_DOC_TITLE"</font><font color="#330033">)</font>
> <font color="#330033">  jStatus &= db_select_table(</font><font
> color="#00A033">"SYS_AUTONUMBER"</font><font color="#330033">)</font>
> <font color="#330033">  jStatus &= db_insert(</font><font
> color="#00A033">"TBL_DOCUMENTS"</font><font color="#330033">, </font><font
> color="#993333">{</font><font color="#00A033">"DOC" </font><font
> color="#330033">& </font><font color="#00A033">"#"</font><font color="#330033">,
> 1</font><font color="#993333">}</font><font color="#330033">)</font>
> <font color="#FF0055">  --</font>
> <font color="#330033">  jStatus &= db_select(</font><font
> color="#00A033">"c:\\Metadata.edb"</font><font color="#330033">)</font>
> <font color="#330033">  jStatus &= db_select_table(</font><font
> color="#00A033">"TBL_DOCUMENTS"</font><font color="#330033">)</font>
> <font color="#330033"></EuCode></font>
> 
> 
> What happens here is that 2 tables are created in "Metadata.edb", but
> the intention was that "TBL_DOCUMENTS" is created in "Metadata.edb",
> and "IDX_DOCUMENTS" is created in "System.edb"..
> 
> Can anyone spot what I'm doing wrong?
> 
> Kenneth / ZNorQ

Ah, forget it people. I just realized that I was missing the path variable
in my original code.. Geeez...

Regards Kenneth / ZNorQ

new topic     » goto parent     » topic index » view message » categorize

4. Re: Database.e; db_select(); Can't make it work...

ZNorQ wrote:
> 
> I got a program that have 2 ".edb" files, and I'm trying to use db_select()
> to switch between the three.
> 
> When the program starts, it checks to see if the 2 files exists, and if they
> don't - it creates them using the db_create().
> 
> Now, I thought that when using db_create() - this also acts as db_open() and
> keeps those databases open, and that I'm then able to use db_select() to
> switch between them.
> 
> Example;
> 
> <font color="#330033"><EuCode></font>
> <font color="#FF00FF">  sequence </font><font color="#330033">jStatus</font>
> <font color="#330033">  jStatus = {}</font>
> <font color="#FF0055">  --</font>
> <font color="#330033">  jStatus &= db_select(</font><font
> color="#00A033">"c:\\Metadata.edb"</font><font color="#330033">)</font>
> <font color="#330033">  jStatus &= db_create_table(</font><font
> color="#00A033">"TBL_DOCUMENTS"</font><font color="#330033">)</font>
> <font color="#FF0055">  --</font>
> <font color="#330033">  jStatus &= db_select(</font><font
> color="#00A033">"c:\\System.edb"</font><font color="#330033">)</font>
> <font color="#330033">  jStatus &= db_create_table(</font><font
> color="#00A033">"IDX_DOCUMENTS"</font><font color="#330033">)</font>
> <font color="#330033">  jStatus &= db_select_table(</font><font
> color="#00A033">"SYS_HEADINGS"</font><font color="#330033">)</font>
> <font color="#330033">  jStatus &= db_insert(</font><font
> color="#00A033">"TBL_DOCUMENTS"</font><font color="#330033">, </font><font
> color="#00A033">"STR_DOC_NO"</font><font color="#330033">, </font><font
> color="#00A033">"STR_DOC_TITLE"</font><font color="#330033">)</font>
> <font color="#330033">  jStatus &= db_select_table(</font><font
> color="#00A033">"SYS_AUTONUMBER"</font><font color="#330033">)</font>
> <font color="#330033">  jStatus &= db_insert(</font><font
> color="#00A033">"TBL_DOCUMENTS"</font><font color="#330033">, </font><font
> color="#993333">{</font><font color="#00A033">"DOC" </font><font
> color="#330033">& </font><font color="#00A033">"#"</font><font color="#330033">,
> 1</font><font color="#993333">}</font><font color="#330033">)</font>
> <font color="#FF0055">  --</font>
> <font color="#330033">  jStatus &= db_select(</font><font
> color="#00A033">"c:\\Metadata.edb"</font><font color="#330033">)</font>
> <font color="#330033">  jStatus &= db_select_table(</font><font
> color="#00A033">"TBL_DOCUMENTS"</font><font color="#330033">)</font>
> <font color="#330033"></EuCode></font>
> 
> 
> What happens here is that 2 tables are created in "Metadata.edb", but
> the intention was that "TBL_DOCUMENTS" is created in "Metadata.edb",
> and "IDX_DOCUMENTS" is created in "System.edb"..
> 
> Can anyone spot what I'm doing wrong?
> 
> Kenneth / ZNorQ

Are you sure you succesfully opened the two databases? The doc for 
db_select() says a database must be opened (using db_create() or db_open())
in order for db_select to succeed.
Also note that db_select_table(), likewise, doesn't create a table if it
 doesn't exist, but does nothing instead, returning the DB_OPEN_FAIL
 error code.
By the way, trying to run your code sippet gave me an error on the first
 db_insert() statement, as it has 3 arguments instead of 2.

Running this code gave me the result you expected:
include database.e
  ?db_create("Metadata.edb",DB_LOCK_NO)
  ?db_create("System.edb",DB_LOCK_NO)
  ?db_select("Metadata.edb")
  ?db_create_table("TBL_DOCUMENTS")
  --
  ?db_select("System.edb")
  ?db_create_table("IDX_DOCUMENTS")
  ?db_select_table("SYS_HEADINGS")
  ?db_insert("TBL_DOCUMENTS", {"STR_DOC_NO", "STR_DOC_TITLE"})
  ?db_select_table("SYS_AUTONUMBER")
  ?db_insert("TBL_DOCUMENTS", {"DOC" & "#", 1})
   --
  ?db_select("c:\\Metadata.edb")
  ?db_select_table("TBL_DOCUMENTS")
?machine_func(26,0)


Of course you'll have to replace the ?s by "jStatus &= ". I did so to
 see which operations failed and what the db_table_list() were.
CChris

new topic     » goto parent     » topic index » view message » categorize

5. Re: Database.e; db_select(); Can't make it work...

CChris wrote:
> 
> ZNorQ wrote:
> > 
> > I got a program that have 2 ".edb" files, and I'm trying to use db_select()
> > to switch between the three.
> > 
> > When the program starts, it checks to see if the 2 files exists, and if they
> > don't - it creates them using the db_create().
> > 
> > Now, I thought that when using db_create() - this also acts as db_open() and
> > keeps those databases open, and that I'm then able to use db_select() to
> > switch between them.
> > 
> > Example;
> > 
> <font color="#330033">> <font color=</font><font
> color="#00A033">"#330033"</font><font color="#330033">><EuCode></font></font>
> <font color="#330033">> <font color=</font><font
> color="#00A033">"#FF00FF"</font><font color="#330033">>  </font><font
> color="#FF00FF">sequence </font><font color="#330033"></font><font
> color=</font><font color="#00A033">"#330033"</font><font
> color="#330033">>jStatus</font></font>
> <font color="#330033">> <font color=</font><font
> color="#00A033">"#330033"</font><font color="#330033">>  jStatus =
> {}</font></font>
> <font color="#330033">> <font color=</font><font
> color="#00A033">"#FF0055"</font><font color="#330033">>  </font><font
> color="#FF0055">--</font></font>
> <font color="#330033">> <font color=</font><font
> color="#00A033">"#330033"</font><font color="#330033">>  jStatus &=
> db_select(</font><font color=</font><font color="#00A033">"#00A033"</font><font
> color="#330033">></font><font color="#00A033">"c:\\Metadata.edb"</font><font
> color="#330033"></font><font
> color=</font><font color="#00A033">"#330033"</font><font
> color="#330033">>)</font></font>
> <font color="#330033">> <font color=</font><font
> color="#00A033">"#330033"</font><font color="#330033">>  jStatus &=
> db_create_table(</font><font color=</font><font
> color="#00A033">"#00A033"</font><font color="#330033">></font><font
> color="#00A033">"TBL_DOCUMENTS"</font><font color="#330033"></font><font
> color=</font><font color="#00A033">"#330033"</font><font
> color="#330033">>)</font></font>
> <font color="#330033">> <font color=</font><font
> color="#00A033">"#FF0055"</font><font color="#330033">>  </font><font
> color="#FF0055">--</font></font>
> <font color="#330033">> <font color=</font><font
> color="#00A033">"#330033"</font><font color="#330033">>  jStatus &=
> db_select(</font><font color=</font><font color="#00A033">"#00A033"</font><font
> color="#330033">></font><font color="#00A033">"c:\\System.edb"</font><font
> color="#330033"></font><font
> color=</font><font color="#00A033">"#330033"</font><font
> color="#330033">>)</font></font>
> <font color="#330033">> <font color=</font><font
> color="#00A033">"#330033"</font><font color="#330033">>  jStatus &=
> db_create_table(</font><font color=</font><font
> color="#00A033">"#00A033"</font><font color="#330033">></font><font
> color="#00A033">"IDX_DOCUMENTS"</font><font color="#330033"></font><font
> color=</font><font color="#00A033">"#330033"</font><font
> color="#330033">>)</font></font>
> <font color="#330033">> <font color=</font><font
> color="#00A033">"#330033"</font><font color="#330033">>  jStatus &=
> db_select_table(</font><font color=</font><font
> color="#00A033">"#00A033"</font><font color="#330033">></font><font
> color="#00A033">"SYS_HEADINGS"</font><font color="#330033"></font><font
> color=</font><font color="#00A033">"#330033"</font><font
> color="#330033">>)</font></font>
> <font color="#330033">> <font color=</font><font
> color="#00A033">"#330033"</font><font color="#330033">>  jStatus &=
> db_insert(</font><font color=</font><font color="#00A033">"#00A033"</font><font
> color="#330033">></font><font color="#00A033">"TBL_DOCUMENTS"</font><font
> color="#330033"></font><font
> color=</font><font color="#00A033">"#330033"</font><font color="#330033">>,
> </font><font color=</font><font color="#00A033">"#00A033"</font><font
> color="#330033">></font><font color="#00A033">"STR_DOC_NO"</font><font
> color="#330033"></font><font color=</font><font
> color="#00A033">"#330033"</font><font color="#330033">>,
> </font><font color=</font><font color="#00A033">"#00A033"</font><font
> color="#330033">></font><font color="#00A033">"STR_DOC_TITLE"</font><font
> color="#330033"></font><font color=</font><font
> color="#00A033">"#330033"</font><font color="#330033">>)</font></font>
> <font color="#330033">> <font color=</font><font
> color="#00A033">"#330033"</font><font color="#330033">>  jStatus &=
> db_select_table(</font><font color=</font><font
> color="#00A033">"#00A033"</font><font color="#330033">></font><font
> color="#00A033">"SYS_AUTONUMBER"</font><font color="#330033"></font><font
> color=</font><font color="#00A033">"#330033"</font><font
> color="#330033">>)</font></font>
> <font color="#330033">> <font color=</font><font
> color="#00A033">"#330033"</font><font color="#330033">>  jStatus &=
> db_insert(</font><font color=</font><font color="#00A033">"#00A033"</font><font
> color="#330033">></font><font color="#00A033">"TBL_DOCUMENTS"</font><font
> color="#330033"></font><font color=</font><font
> color="#00A033">"#330033"</font><font color="#330033">>,
> </font><font color=</font><font color="#00A033">"#993333"</font><font
> color="#330033">></font><font color="#993333">{</font><font
> color="#330033"></font><font color=</font><font
> color="#00A033">"#00A033"</font><font color="#330033">></font><font
> color="#00A033">"DOC" </font><font color="#330033"></font><font
> color=</font><font color="#00A033">"#330033"</font><font color="#330033">>&
> </font><font color=</font><font color="#00A033">"#00A033"</font><font
> color="#330033">></font><font color="#00A033">"#"</font><font
> color="#330033"></font><font color=</font><font
> color="#00A033">"#330033"</font><font color="#330033">>, 1</font><font
> color=</font><font color="#00A033">"#993333"</font><font
> color="#330033">></font><font color="#993333">}</font><font
> color="#330033"></font><font
> color=</font><font color="#00A033">"#330033"</font><font
> color="#330033">>)</font></font>
> <font color="#330033">> <font color=</font><font
> color="#00A033">"#FF0055"</font><font color="#330033">>  </font><font
> color="#FF0055">--</font></font>
> <font color="#330033">> <font color=</font><font
> color="#00A033">"#330033"</font><font color="#330033">>  jStatus &=
> db_select(</font><font color=</font><font color="#00A033">"#00A033"</font><font
> color="#330033">></font><font color="#00A033">"c:\\Metadata.edb"</font><font
> color="#330033"></font><font
> color=</font><font color="#00A033">"#330033"</font><font
> color="#330033">>)</font></font>
> <font color="#330033">> <font color=</font><font
> color="#00A033">"#330033"</font><font color="#330033">>  jStatus &=
> db_select_table(</font><font color=</font><font
> color="#00A033">"#00A033"</font><font color="#330033">></font><font
> color="#00A033">"TBL_DOCUMENTS"</font><font color="#330033"></font><font
> color=</font><font color="#00A033">"#330033"</font><font
> color="#330033">>)</font></font>
> <font color="#330033">> <font color=</font><font
> color="#00A033">"#330033"</font><font color="#330033">></EuCode></font></font>
> > 
> > 
> > What happens here is that 2 tables are created in "Metadata.edb", but
> > the intention was that "TBL_DOCUMENTS" is created in "Metadata.edb",
> > and "IDX_DOCUMENTS" is created in "System.edb"..
> > 
> > Can anyone spot what I'm doing wrong?
> > 
> > Kenneth / ZNorQ
> 
> Are you sure you succesfully opened the two databases? The doc for 
> db_select() says a database must be opened (using db_create() or db_open())
> in order for db_select to succeed.
> Also note that db_select_table(), likewise, doesn't create a table if it
>  doesn't exist, but does nothing instead, returning the DB_OPEN_FAIL
>  error code.
> By the way, trying to run your code sippet gave me an error on the first
>  db_insert() statement, as it has 3 arguments instead of 2.
> 
> Running this code gave me the result you expected:
> }}}
<eucode>
> include database.e   
>   ?db_create("Metadata.edb",DB_LOCK_NO)
>   ?db_create("System.edb",DB_LOCK_NO)
>   ?db_select("Metadata.edb")
>   ?db_create_table("TBL_DOCUMENTS")
>   --
>   ?db_select("System.edb")
>   ?db_create_table("IDX_DOCUMENTS")
>   ?db_select_table("SYS_HEADINGS")
>   ?db_insert("TBL_DOCUMENTS", {"STR_DOC_NO", "STR_DOC_TITLE"})
>   ?db_select_table("SYS_AUTONUMBER")
>   ?db_insert("TBL_DOCUMENTS", {"DOC" & "#", 1})
>    --
>   ?db_select("c:\\Metadata.edb")
>   ?db_select_table("TBL_DOCUMENTS")
> ?machine_func(26,0)
> </eucode>
{{{

> 
> Of course you'll have to replace the ?s by "jStatus &= ". I did so to
>  see which operations failed and what the db_table_list() were.
> CChris

Hey CChris,

Well, I found out what I've done wrong, and that error wasn't at all 
reflected in my example. I used two variables - one for path and one
each for the files, ie. 
  sDIRECOTY = "c:\mydatabase\",
  sSYSTEM   = "System.edb",
  SMETA     = "Metadata.edb".

I was so sure I hadn't done anything wrong, but left out the fact that
I just used the filename, and forgot to include the path reference;

xIO = db_select(sSYSTEM)    --->> WRONG!
xIO = db_select(sDIRECTORY & sSYSTEM) -->> RIGHT!

Anyway, thanks for your response.

Kenneth aka ZNorQ

new topic     » goto parent     » topic index » view message » categorize

Search



Quick Links

User menu

Not signed in.

Misc Menu