C++Builder table exist

Поиск
Список
Период
Сортировка
От Charl Roux
Тема C++Builder table exist
Дата
Msg-id DUB103-W643C88CC74C4BF90FD7FEB85E30@phx.gbl
обсуждение исходный текст
Ответы Re: C++Builder table exist  (Raymond O'Donnell <rod@iol.ie>)
Список pgsql-general
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


В списке pgsql-general по дате отправления:

Предыдущее
От: Alban Hertroys
Дата:
Сообщение: Re: table spaces
Следующее
От: Raymond O'Donnell
Дата:
Сообщение: Re: C++Builder table exist