Page 1 of 1

UniScript multi commands

Posted: Sun 27 Nov 2011 19:01
by oz8hp
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;

Posted: Mon 28 Nov 2011 11:21
by AlexP
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} ');
....

Posted: Mon 28 Nov 2011 17:57
by oz8hp
Result is

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

(That is the E.Message)

Posted: Tue 29 Nov 2011 09:04
by oz8hp
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)

Posted: Tue 29 Nov 2011 11:29
by AlexP
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.

Posted: Tue 29 Nov 2011 11:42
by oz8hp
OK - that sounds great