Checking, if a Database exists

Ruslan Zasukhin sunshine at public.kherson.ua
Thu Nov 20 04:21:10 CST 2008


On 11/20/08 12:08 PM, "Stefan Von Torklus" <stefanvt at gmx.de> wrote:

> hello,
> 
> I have a strange problem.
> I create a database, the file exists. And on shutdown I close/flush the
> database.
> 
> The next start I expected, that the get_Exists()-Method of I_Disk_Location
> notices, that
> the database already exists. But it always say, that it does not.
> 
> I_Disk_Location* pLocation = CreateDiskLocation(filename);
> if(pLocation->get_Exists()) {
>     //open -> never!
> } else {
>    //create -> always! :-(
> }
> 
> Do I missunderstood this Method?
> I don't want to use some system dependent/Non-Valentina method for this. And
> I'm sure, there is a way,
> but I can't find a suitable method for it in the valentina-interfaces
> header...
> 
> Would be glad, if someone may point me to the right direction...

This is one of our tests:
    although I see this is test of SQL command CREATE DATABASE

void Test_VSQL_CreateDatabase( void ) throw()
{
    TEST_NAME( "Test_VSQL_CreateDatabase" );

    try
    {
        I_SqlDatabase_Ptr pSqlDb = Test_Persistent_Database_Prepare();

        I_Database_Ptr pDb = CreateDatabase();
        pDb->put_Location( FBL::CreateDiskLocation( "db1" ) );
        DO_TEST_EQ( pDb->get_Exists(), false );

        pSqlDb->SqlExecute( "CREATE DATABASE if not exists db1 " );

        DO_TEST_EQ( pDb->get_Exists(), true );
    }
    TEST_CATCH

    {
        I_SqlDatabase_Ptr pSqlDb = Test_Persistent_Database_Prepare();
        Test_VSQL_Database_CleanUp( pSqlDb );

        // Clean up.
        I_Database_Ptr pDb = CreateDatabase();
        pDb->put_Location( FBL::CreateDiskLocation( "db1" ) );
        try
        {
            pDb->ThrowOut();
        }
        catch(...)
        {          
        }
    }
}



-- 
Best regards,

Ruslan Zasukhin
VP Engineering and New Technology
Paradigma Software, Inc

Valentina - Joining Worlds of Information
http://www.paradigmasoft.com

[I feel the need: the need for speed]



More information about the Valentina mailing list