Icon View Thread

The following is the text of the current message along with any replies.
Messages 1 to 2 of 2 total
Thread some weird #1011 error I'm getting
Wed, Jan 25 2012 7:18 AMPermanent Link

Lucian

Hi,

I'm having problems with this code and I'm stuck. I have a stored boolean function, declared as:

CREATE FUNCTION "uspHasFlag" (
IN "Value" INTEGER,
IN "Flag" INTEGER)
RETURNS BOOLEAN
...........

than, this gets called from another stored procedure with (a piece of) code like:

Form 1:
 SET sqlCheckFlag =
   'uspHasFlag(SELECT Flags FROM apartamente WHERE (apartamente.AptNo=tabel.AptNo) AND (apartamente.ScaraID=?), ?)';

 PREPARE AuxStatement FROM
   'SELECT Sum(Nrp) NrpCuContor, Sum('+ColumnConsum+') ConsumDeclarat '+
   'FROM tabel '+
   'JOIN consumuri ON (consumuri.ScaraID=tabel.ScaraID) AND (consumuri.AptNo=tabel.AptNo) '+
   'JOIN apartamente ON (apartamente.ScaraID=tabel.ScaraID) AND (apartamente.AptNo=tabel.AptNo) AND ' +
   sqlCheckFlag + ' WHERE (ScaraID=?) AND (Perioada=?) NOJOINOPTIMIZE';
 OPEN AuxCursor USING ScaraID, Flag, ScaraID, Perioada;

Now, the code above works fine WHEN this is used:
Form 2:
 SET sqlCheckFlag =
   'uspHasFlag(SELECT Flags FROM apartamente WHERE (apartamente.AptNo=tabel.AptNo), ?)';

but it craps when the first form is used. I am getting: #1011 An error occurred with the value uspHasFlag(SELECT Flags FROM apartamente WHERE (apartamente.AptNo=tabel.AptNo) AND (apartamente.ScaraID=?), ?) (The value would result in truncation))

I don't understand the error. Since the second approach works fine, I was expecting that adding another filter will make the SELECT even more restrictive ... so, I don't understand the error.
Wed, Jan 25 2012 7:53 AMPermanent Link

Lucian

Forget about it. The variable was declared as VARCHAR(100) and obviously didn't fit Smile
Lucian
Image