4

I'm trying to attach one SQLite database to another on BlackBerry using SQLite ATTACH DATABASE command.

Database d1, d2;
Statement st;

URI dbURI1 = URI.create("file:///SDCard/Databases/SQLiteExample/MyTestDatabase1.db") 
if (DatabaseFactory.exists(dbURI1)) {
    d1 = DatabaseFactory.open(dbURI1);
} else {
    d1 = DatabaseFactory.create(dbURI1);
    st = d1.createStatement("CREATE TABLE 'People' ( 'Name' TEXT, 'Age' INTEGER )");

    st.prepare();
    st.execute();
    st.close();
}

URI dbURI2 = URI.create("file:///SDCard/Databases/SQLiteExample/MyTestDatabase2.db");
if (DatabaseFactory.exists(dbURI2)) {
    d2 = DatabaseFactory.open(dbURI2);
} else {
    d2 = DatabaseFactory.create(dbURI2);
    st = d2.createStatement("CREATE TABLE 'People2' ('Name2' TEXT, 'Age2' INTEGER )");

    st.prepare();
    st.execute();
    st.close();
    d2.close();
}

st = d1.createStatement("ATTACH DATABASE '/SDCard/Databases/SQLiteExample/MyTestDatabase2.db' as SECOND_TABLE");
st.prepare(); //THROWS AN EXCEPTION "SQL logic error or missing database"
st.execute();
st.close();

I'm getting an Exception ATTACH DATABASE /SDCard/Databases/SQLiteExample/MyTestDatabase2.db' as SECOND_TABLE: SQLlogic error or missing database when it tries to prepare statement for "Attach Database" command.

Is it possible to use ATTACH DATABASE command with BlackBerry SQLite API?

Thanks.

Misha Narinsky
  • 677
  • 1
  • 10
  • 24

2 Answers2

2

No, the BlackBerry implementation of SQLite does not support ATTACH DATABASE. See the BlackBerry documentation "Working with SQLite databases" for confirmation.

Michael Donohue
  • 11,776
  • 5
  • 31
  • 44
Eric Giguere
  • 3,495
  • 15
  • 11
0

RIM has added Attach/Detach Database commands to their BlackBerry OS 7.0 API:
BlackBerry 7.0 API Docs

Misha Narinsky
  • 677
  • 1
  • 10
  • 24