UniScript multi commands

Discussion of open issues, suggestions and bugs regarding UniDAC (Universal Data Access Components) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
oz8hp
Posts: 151
Joined: Mon 18 Feb 2008 13:28
Location: Denmark
Contact:

UniScript multi commands

Post by oz8hp » Sun 27 Nov 2011 19:01

I use the following UniScript for renaming a table - it works OK for MySQL and SQLite but the MS Access doesn't run. If I remove the 'DROP TABLE..' it runs but I then have double tables. Any input to a method to use?

procedure TUniDAC.TableRename(const aOldTable, aNewTable: string);
begin
try
With frmDBConn.uniScript Do
try
begin
SQL.Clear;
SQL.Add(' {IF Access} ');
SQL.Add(' SELECT * INTO ' + aNewTable + ' FROM ' + aOldTable);
SQL.Add(' DROP TABLE ' + aOldTable);
SQL.Add(' {ELSE} ');
SQL.Add(' ALTER TABLE ' + aOldTable);
SQL.Add(' RENAME TO ' + aNewTable);
SQL.Add(' {ENDIF} ');
SQL.Add(' ;');
Execute
end;
except
on E:exception do
Logfile.Database('TUniDAC.TableRename: ' + E.Message);
end;
finally
end;
end;

AlexP
Devart Team
Posts: 5530
Joined: Tue 10 Aug 2010 11:35

Post by AlexP » Mon 28 Nov 2011 11:21

Hello,

To solve this problem you need to separate SELECT and DROP operators by semicolon:

Code: Select all

....
SQL.Add(' {IF Access} '); 
SQL.Add(' SELECT * INTO ' + aNewTable + ' FROM ' + aOldTable +' ; ');
SQL.Add(' DROP TABLE ' + aOldTable); 
SQL.Add(' {ELSE} ');
....

oz8hp
Posts: 151
Joined: Mon 18 Feb 2008 13:28
Location: Denmark
Contact:

Post by oz8hp » Mon 28 Nov 2011 17:57

Result is

28-11-2011 18:56:28 # TUniDAC.TableRename: {if} statement not completed

(That is the E.Message)

oz8hp
Posts: 151
Joined: Mon 18 Feb 2008 13:28
Location: Denmark
Contact:

Post by oz8hp » Tue 29 Nov 2011 09:04

After trying an update of UniDac to 4.1.3 I get another errormessage
(The update gave me the same problem as in http://www.devart.com/forums/viewtopic.php?t=22676 - removed UniDac, run CCleaner, restart, reinstall, restart = looks like working)

29-11-2011 10:00:38 # TUniDAC.TableRename: Invalid value: 1 for option ExtendedAnsiSQL
(Found the solution for that = ExtendedAnsiSQL changed from Integer to Boolean)

AlexP
Devart Team
Posts: 5530
Joined: Tue 10 Aug 2010 11:35

Post by AlexP » Tue 29 Nov 2011 11:29

Hello,

Code: Select all

28-11-2011 18:56:28 # TUniDAC.TableRename: {if} statement not completed 
We've reproduced the problem with macros and will try to fix it in the next product version.

Code: Select all

29-11-2011 10:00:38 # TUniDAC.TableRename: Invalid value: 1 for option ExtendedAnsiSQL
To solve this problem, you need to change the value of the ExtendedAnsiSQL property from 1 to True in the *.dfm file.

oz8hp
Posts: 151
Joined: Mon 18 Feb 2008 13:28
Location: Denmark
Contact:

Post by oz8hp » Tue 29 Nov 2011 11:42

OK - that sounds great

Post Reply