multiple databases: DB->open EINVAL error

Hello,

I tried to create a single file containing many databases.
Creating environnement then handle works well but opening the
database gives me an EINVAL error.

The documentation say that I must set up many things:

-locking
-pool
-page size
-encryption and checksum
-byte order
etc...


Could you tell me how to setu up the environnement and what customizations
are realy required to build multiple database in a single files.

Thank you

------------------
OS: Linux slackware

intmailAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

fridomCEO/ProgrammerCommented:
How about posting some code which shows your problem. I simply wrote the following:
#include <db.h>
#include <string.h>
#include <stdlib.h>

char *st1_db_name = "st1_db";
char *st2_db_name = "st2_db";
static char *db_name = "test.db";
static DB *hDb1, *hDb2;


int main(void){
  int i_rval;
  i_rval =  db_create(&hDb1, NULL, 0);
  if (0 != i_rval){
    fprintf(stderr, "could not create Database handle, giving up\n");
    goto clean;
  }
  i_rval = db_create(&hDb2, NULL, 0);
  if (0 != i_rval){
    fprintf(stderr, "could not create Database handle, giving up\n");
    goto clean;
  }
  /* open the first databse in file db_name */
  i_rval = hDb1->open(hDb1, NULL, db_name, st1_db_name, DB_HASH, DB_CREATE, 0);
  if (0 != i_rval){
    hDb2->err(hDb2, i_rval, "DB err");
    goto clean;
  }
  /* open the second database in the same file db_name */
  i_rval = hDb2->open(hDb2, NULL, db_name, st2_db_name, DB_HASH, DB_CREATE, 0);
  if (0 != i_rval){
    hDb2->err(hDb2, i_rval, "DB_ERR");
    goto clean;
  }
 
 
  /* cleanung up omitted */
     


 
  return 0;  
 clean:    
  fprintf(stderr, "Something went wrong, giving up\n");
  if (hDb1) hDb1->close(hDb1, 0);
  if (hDb2) hDb2->close(hDb2, 0);

}


And that simply has worked. So you see there are to database handles but they are just in one file. Now I can use the handles as I like.

Regards
Friedrich

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
intmailAuthor Commented:
Hi fridom,

The issue was solved but another appears: ->put function gives me an error that I can not match with any specified in docs. I will post you this next time.
fridomCEO/ProgrammerCommented:
I can not see the reason for that I posted code which shows how to do that. This solves the mentioned problem
"The issue was solved...."

So I answered the question. Deleting would be unfair IMHO.

Friedrich
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Databases

From novice to tech pro — start learning today.