Hi,

I have migrated from MySQL to PostgreSQL. I am running on WindowsXP SP3, 
C++Builder6, PostgreSQL9.2, pgExpress4.6(database driver)
I have the following scenarion. If my applications starts up, it will test if a 
certain table exists within the database. If not, it will create the table, 
else it will not re-create the table. This worked fine when I used MySQL, but 
with PostgreSQL not. The first time that I run the application, I do not get an 
error and the table is created. The second time I run the application, the 
application gives an error that the table already exists. This means that my 
method of testing if the table does exist, does not work with PostgreSQL, with 
the following message: ERROR: relation "querybackup" already exists
My code is as follows:

void __fastcall TfrmMain::FormCreate(TObject *Sender)
{
  int errorCode;
  TStringList *tableList = new TStringList;
  frmDataModule->eyeConnection->GetTableNames(tableList);

  // create queryBackup table if does not exist
  AnsiString SQL = "CREATE TABLE queryBackup( queryName VARCHAR(30) PRIMARY 
KEY,query VARCHAR(10000))";
  if( tableList->IndexOf("queryBackup") < 0 )
    errorCode = frmDataModule->eyeConnection->ExecuteDirect(SQL);
}

Thanks for the time.

Charl


                                          

Reply via email to