#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Sep 2017
    Posts
    4
    Rep Power
    0

    dynamic sqql error in while


    Hello,
    i get following error in a while procedure:
    SQL Error [335544634] [42000]: Dynamic SQL Error; SQL error code = -104; Token unknown - line 1, column 1; BEGIN [SQLState:42000, ISC error code:335544634]
    Dynamic SQL Error; SQL error code = -104; Token unknown - line 1, column 1; BEGIN [SQLState:42000, ISC error code:335544634]
    org.firebirdsql.jdbc.FBSQLExceptionInfo: Dynamic SQL Error

    Code:
    DECLARE VARIABLE  i1 int;
    BEGIN
    i1 = 1;
    while (i1 < 1000) do
    BEGIN
    insert into TBTEST (VARCHAR1) values (i1);
    i1 = i1 + 1;
    end
    END
    Can You tell me why?
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Sep 2006
    Location
    Plovdiv. Bulgaria
    Posts
    242
    Rep Power
    17
    The only error I can see is missing ":" prefix for the I1 variable in the INSERT statement. I've created a simple stored procedure with your code and it works.
  4. #3
  5. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2017
    Posts
    4
    Rep Power
    0
    in statments select, update and delete. you need use ":" for variables.
  6. #4
  7. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Sep 2017
    Posts
    4
    Rep Power
    0
    Did this but still I get the error?!
    Code:
    DECLARE VARIABLE  i1 int;
    BEGIN
    	i1 = 1;
    	while (i1 < 100000) do
    	BEGIN
    		insert into TBTEST (VARCHAR1) values (:i1);
    		i1 = i1 + 1;
    	end
    END
    SQL Error [335544634] [42000]: Dynamic SQL Error; SQL error code = -104; Token unknown - line 1, column 1; BEGIN [SQLState:42000, ISC error code:335544634]
    Dynamic SQL Error; SQL error code = -104; Token unknown - line 1, column 1; BEGIN [SQLState:42000, ISC error code:335544634]
    org.firebirdsql.jdbc.FBSQLExceptionInfo: Dynamic SQL Error
  8. #5
  9. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2017
    Posts
    4
    Rep Power
    0
    are you tried create a statement sql ? or a trigger or stored procedure ?

    sorry for my english.
    i'm starting learning.
  10. #6
  11. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Sep 2017
    Posts
    4
    Rep Power
    0
    Hi,
    it's just a statement so far
  12. #7
  13. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2017
    Posts
    4
    Rep Power
    0
    in statement not possible uses begin end, while and declare variables.

    search for "execute block" in web or create a stored procedure
  14. #8
  15. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Sep 2017
    Posts
    4
    Rep Power
    0
    Sorry but it is still not working??
    I try to execute this simple one
    Code:
    execute block
    as
    declare i int = 0;
    begin
      while (i < 128) do
      begin
        insert into TBTEST values (:i);
        i = i + 1;
      end
    end
    but I still get the error:
    Engine Error (code = 335544569):
    Dynamic SQL Error.
    SQL error code = -104.
    Token unknown - line 1, column 1.
    end.

    SQL Error (code = -104):
    Invalid token.

IMN logo majestic logo threadwatch logo seochat tools logo