TUniscript ExecuteFile - error

Discussion of open issues, suggestions and bugs regarding UniDAC (Universal Data Access Components) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
stevel
Posts: 125
Joined: Tue 02 Nov 2010 19:01

TUniscript ExecuteFile - error

Post by stevel » Tue 02 Nov 2010 19:12

Using Firebird database, TUniscript.ExecuteFile is giving this error:

Code: Select all

---------------------------
Debugger Exception Notification
---------------------------
Project datatransfer.exe raised exception class EIBCError with message '
Dynamic SQL Error
SQL error code = -104
Unexpected end of command - line 4, column 21'.
---------------------------
Break   Continue   Help   
---------------------------

The script file is as follows:

Code: Select all

 
execute block
as

declare trig char(31);
declare genr char(31);
declare reln char(31);

-- all triggers
declare curt cursor for
(select rdb$trigger_name from rdb$triggers
 where rdb$system_flag=0);

-- all generators
declare curg cursor for
  (select rdb$generator_name 
   from rdb$generators 
   where rdb$system_flag = 0);
  
-- all tables
declare cur cursor for 
  (select rdb$relation_name from rdb$relations
   where rdb$system_flag = 0 and rdb$view_blr is null
   and rdb$relation_name not in ('tblyesno', 
   'tblpaymentmethod', 
   'tblresourcetype'));
   
begin

  -- deactivate all triggers
  open curt;
  while (1=1) do
  begin
   fetch curt into trig;
   if (row_count = 0) then leave;
   execute statement 'alter trigger ' || trig || ' inactive';
   suspend;
  end 
  close curt;
  
  -- zero all generators
  open curg;
  while (1=1) do
  begin
   fetch curg into genr;
   if (row_count = 0) then leave;
   execute statement 'set generator ' || genr || ' to 0';
   suspend;
  end
  close curg;
  
  -- truncate all tables
  open cur;
  while (1=1) do
  begin
    fetch cur into reln ;
    if (row_count = 0) then leave;
   execute statement 'delete from ' || reln;
     suspend;
  end 
  close cur; 

  
end;
Last edited by stevel on Wed 03 Nov 2010 17:59, edited 1 time in total.

stevel
Posts: 125
Joined: Tue 02 Nov 2010 19:01

Post by stevel » Wed 03 Nov 2010 10:15

I managed to solve the problem:

In script file, add at beginning:

Code: Select all

SET TERM ^ ;
add at end:

Code: Select all

SET TERM ; ^
add after the last 'END':

Code: Select all

^
Thanks to EMS Soft's SQL Manager for Interbase/Firebird stored procedure design mode, I managed to see the delimiters for stored procedures scripts.
Cheerio,
Steve :?

AndreyZ

Post by AndreyZ » Wed 03 Nov 2010 13:16

Hello,

It is good to see that this problem was solved. Feel free to contact us if you have any further questions about UniDAC.

stevel
Posts: 125
Joined: Tue 02 Nov 2010 19:01

Post by stevel » Fri 05 Nov 2010 14:13

Andrey,

Just to come back to this issue.. it seems that the above script is not being executed as expected. After the script execution, the tables still contain data, triggers are still active and generators have not been reset to 0.

Is this because EXECUTE BLOCK is not supported? (or is this because there is some error with my script? can you tell?)


Regards,
Steve

stevel
Posts: 125
Joined: Tue 02 Nov 2010 19:01

Post by stevel » Sat 06 Nov 2010 11:23

Folks, I got it fixed. See:

http://stackoverflow.com/questions/4104 ... d-results

Regards,
SteveL

AndreyZ

Post by AndreyZ » Mon 08 Nov 2010 07:11

I am happy that this problem has been solved. If any other questions come up, please contact us.

Post Reply