Page 1 of 1

Dynamic SQL ErrorSQL error code = -303 - string right truncation

Posted: Wed 19 Jun 2013 00:34
by inageib
Hi,
I use FireBird 2.5.1 and I got strange error when I tried to select a stored procedure. I used the component TIBCSQL with this code:

Code: Select all

  TIBCSQL.SQL.Text := 'Select f_id, o_log from myproc (0)';

  TIBCSQL.Params.CreateParam(ftInteger, 'p1', ptOutPut);
  TIBCSQL.Params.CreateParam(ftString, 'p2', ptOutPut);

  TIBCSQL.Prepare;
  TIBCSQL.Execute;

  while TIBCSQL.ExecuteNext do begin //<<------ error -303 here
      memo1.Lines.Add(TIBCSQL.ParamByName('p2').AsString); 

  end;
  TIBCSQL.UnPrepare;
  TIBCSQL.SQL.Clear;
And I get this error when I use ExecuteNext as described with the comment above
Dynamic SQL ErrorSQL error code = -303
arithmetic exception, numeric overflow, or string truncation
string right truncation.
MyProc script (it is still a template test for something bigger)

Code: Select all

create or alter procedure myproc (
    inp_ID smallint)
returns (
    f_ID smallint,
    O_LOG varchar(100) character set WIN1252)
as
begin
  select f_ID from mytable1
    where f2_ID = 127
    into :f_id;

  o_log = 'st 1';

  select f2 from mytable2
    where f3_id = 33
    into :o_log;

  suspend;
end
I tried to call myproc inside IBExpert like that

Code: Select all

Select f_id, o_log from myproc (0)
and it work successfully

looking for your urgent replay to be able to continue my work.

Thanks

Re: Dynamic SQL ErrorSQL error code = -303 - string right truncation

Posted: Wed 19 Jun 2013 14:30
by AndreyZ
Please specify the script to create the mytable1 and mytable2 tables.

Re: Dynamic SQL ErrorSQL error code = -303 - string right truncation

Posted: Wed 19 Jun 2013 16:41
by inageib
script:

Code: Select all

CREATE TABLE mytable1(
    f_ID               SMALLINT NOT NULL,
    f2_ID              SMALLINT NOT NULL
);

Code: Select all

CREATE TABLE mytable2(
    f1_ID               SMALLINT NOT NULL,
    f3_id              SMALLINT NOT NULL,
    f2                 VARCHAR(8) CHARACTER SET WIN1252 NOT NULL
);

Re: Dynamic SQL ErrorSQL error code = -303 - string right truncation

Posted: Thu 20 Jun 2013 06:55
by AndreyZ
To avoid the problem, you should assign the correct size to the p2 parameter before preparing TIBCSQL. Here is a code example:

Code: Select all

TIBCSQL.Params.CreateParam(ftInteger, 'p1', ptOutPut);
TIBCSQL.Params.CreateParam(ftString, 'p2', ptOutPut);
TIBCSQL.ParamByName('p2').Size := 100;

TIBCSQL.Prepare;
TIBCSQL.Execute;

Re: Dynamic SQL ErrorSQL error code = -303 - string right truncation

Posted: Mon 24 Jun 2013 03:50
by inageib
Many Thanks

Re: Dynamic SQL ErrorSQL error code = -303 - string right truncation

Posted: Tue 25 Jun 2013 06:02
by AndreyZ
If any other questions come up, please contact us.