Icon View Thread

The following is the text of the current message along with any replies.
Messages 1 to 3 of 3 total
Thread best way to convert ansi-db to unicode
Mon, May 27 2013 8:54 AMPermanent Link

Gruetzmacher

hello,
i am sure someone had this problem before ... and yes: i searched old threads Smile
so: is there a more convenient way than to export all the tables and import it into the new (unicode-)db?
i would like to use the db-data with elevate webbuilder which (unfortunately) only works for unicode ...

is there something else to consider, when using delphi xe2, apart from changing the edb-source path?

thank you in advance
Thu, May 30 2013 12:59 PMPermanent Link

Tim Young [Elevate Software]

Elevate Software, Inc.

Avatar

Email timyoung@elevatesoft.com

Hendrik,

<< i am sure someone had this problem before ... and yes: i searched old
threads Smile
so: is there a more convenient way than to export all the tables and import
it into the new (unicode-)db? i would like to use the db-data with elevate
webbuilder which (unfortunately) only works for unicode ... >>

That's really the only way.  However, these scripts will automate the
process for you:

exportdb.sql:

SCRIPT
BEGIN
  DECLARE StoreStmt STATEMENT;
  DECLARE TablesCursor CURSOR FOR TablesStmt;
  DECLARE TableName VARCHAR;
  DECLARE CurTable INTEGER;

  PREPARE StoreStmt FROM 'SELECT * FROM Configuration.Stores WHERE Name='+
                          QUOTEDSTR('Export_'+CURRENT_DATABASE());
  EXECUTE StoreStmt;

  IF (ROWSAFFECTED(StoreStmt)=0) THEN
     EXECUTE IMMEDIATE 'CREATE STORE
'+QUOTEDSTR('Export_'+CURRENT_DATABASE(),'"')+
                       ' AS LOCAL PATH
'+QUOTEDSTR('c:\'+'Export_'+CURRENT_DATABASE());
  END IF;

  PREPARE TablesStmt FROM 'SELECT * FROM Information.Tables';
  OPEN TablesCursor;

  IF (ROWCOUNT(TablesCursor) > 0) THEN

     FETCH FIRST FROM TablesCursor ('Name') INTO TableName;

     SET CurTable=1;

     WHILE NOT EOF(TablesCursor) DO
        SET STATUS MESSAGE TO 'Exporting table
'+QUOTEDSTR(TableName,'"')+'...';
        EXECUTE IMMEDIATE 'EXPORT TABLE '+QUOTEDSTR(TableName,'"')+
                          ' TO '+QUOTEDSTR(TableName+'.csv','"')+
                          ' IN STORE
'+QUOTEDSTR('Export_'+CURRENT_DATABASE(),'"')+
                          ' ENCODING UNICODE';
        FETCH NEXT FROM TablesCursor ('Name') INTO TableName;
        SET CurTable=(CurTable+1);
        SET PROGRESS TO ((CurTable/ROWCOUNT(TablesCursor))*100);
     END WHILE;

  END IF;

  SET STATUS MESSAGE TO 'Export complete';

END

importdb.sql:

SCRIPT
BEGIN
  DECLARE StoreStmt STATEMENT;
  DECLARE FilesCursor CURSOR FOR FilesStmt;
  DECLARE FileName VARCHAR;
  DECLARE CurFile INTEGER;

  PREPARE StoreStmt FROM 'SELECT * FROM Configuration.Stores WHERE Name='+
                          QUOTEDSTR('Import_'+CURRENT_DATABASE());
  EXECUTE StoreStmt;

  IF (ROWSAFFECTED(StoreStmt)=0) THEN
     EXECUTE IMMEDIATE 'CREATE STORE
'+QUOTEDSTR('Import_'+CURRENT_DATABASE(),'"')+
                       ' AS LOCAL PATH
'+QUOTEDSTR('c:\'+'Export_'+CURRENT_DATABASE());
  END IF;

  EXECUTE IMMEDIATE 'SET FILES STORE TO
'+QUOTEDSTR('Import_'+CURRENT_DATABASE(),'"');

  PREPARE FilesStmt FROM 'SELECT * FROM Configuration.Files';
  OPEN FilesCursor;

  IF (ROWCOUNT(FilesCursor) > 0) THEN

     FETCH FIRST FROM FilesCursor ('Name') INTO FileName;

     SET CurFile=1;

     WHILE NOT EOF(FilesCursor) DO
        SET STATUS MESSAGE TO 'Importing file
'+QUOTEDSTR(FileName,'"')+'...';
        EXECUTE IMMEDIATE 'IMPORT TABLE
'+QUOTEDSTR(LEFT(FileName,(POS('.',FileName)-1)),'"')+
                          ' FROM '+QUOTEDSTR(FileName,'"')+
                          ' IN STORE
'+QUOTEDSTR('Import_'+CURRENT_DATABASE(),'"')+
                          ' ENCODING UNICODE';
        FETCH NEXT FROM FilesCursor ('Name') INTO FileName;
        SET CurFile=(CurFile+1);
        SET PROGRESS TO ((CurFile/ROWCOUNT(FilesCursor))*100);
     END WHILE;

  END IF;

  SET STATUS MESSAGE TO 'Import complete';

END

<< is there something else to consider, when using delphi xe2, apart from
changing the edb-source path? >>

No, XE2 should work just fine in the same way that past versions have
worked.  I've worked out all of the "kinks" in the XE2 implementation. Wink

Tim Young
Elevate Software
www.elevatesoft.com

Thu, May 30 2013 2:30 PMPermanent Link

Gruetzmacher

this is very kind of you tim!
thanks a lot
Image