Subject | Re: [IBO] Real, super Newbie question |
---|---|
Author | Jörg Schiemann |
Post date | 2001-01-05T08:47:08Z |
Yes, you're right Svein.
I've tested it know and that way it works.
Thx,
Jörg
I've tested it know and that way it works.
Thx,
Jörg
----- Original Message -----
From: "Svein Erling Tysvær" <svein.erling.tysvaer@...>
To: <IBObjects@egroups.com>
Sent: Friday, January 05, 2001 9:26 AM
Subject: Re: [IBO] Real, super Newbie question
Jörg,
P_BAR_PREFIX is a string containing characters and cannot be cast to an
integer. But you can change the procedure to
CREATE PROCEDURE SP_GEN_DUMMY_ITEM(P_CATEGORY_ID INTEGER, P_DESCRIPTION
VARCHAR(50), P_BAR_PREFIX VARCHAR(5), P_COUNT INTEGER) AS
DECLARE VARIABLE i INTEGER;
BEGIN
i = 1;
WHILE ( i <= :P_COUNT ) DO BEGIN
INSERT INTO ITEM(ID_CATEGORY, DESCRIPTION, BARCODE, COST_PRICE,
CURR_VALUE)
VALUES( :P_CATEGORY_ID,
( :P_DESCRIPTION || ' ' || :i ),
( :P_BAR_PREFIX || cast(( :P_CATEGORY_ID * ( 100000 + :i ) +
:i *
10000 + :i * 10 + :P_CATEGORY_ID ) as Integer) ),
( :i * 121 + :P_CATEGORY_ID * 10 + :i ),
( :i * 59 ) );
i = i + 1;
END /* WHILE */
END !!
Jason,
if you correct this in Tutorial1 I guess this will eliminate problems for
newbies.
Set
At 09:08 05.01.2001 +0100, you wrote:
>> > -----Original Message-----
>> > From: Jörg Schiemann [mailto:schimmi@...]
>> > Sent: Jueves 4 de Enero de 2001 6:46
>> >
>> > For some reason IB6 insists to add '.0000000000' to all calculations of
>> > barcode when using
>> >
>> > ( :P_BAR_PREFIX || ( :P_CATEGORY_ID * ( 100000 + :i ) + :i * 10000 + :i
>*
>> > 10 + :P_CATEGORY_ID ) ),
>> >
>> > in the SP_GEN_DUMMY_ITEM procedure. I haven't got a clue why why it
>> > transforms integers this way, but Jason or Helen might know.
>>
>> I never have seen SP_GEN_DUMMY_ITEM but if some of the values causes the
>> resul to be a numeric with some scale, there's a chance IB will add
zeroes
>> when converting to string, so maybe a cast to numeric with scale 0 could
>> help. Also, I don't know if we are talking about dialect 1 or 3, so I
>can't
>> say more.
>>
>> C.
>>
>
>It is dialect 1 and the SP is:
>
>CREATE PROCEDURE SP_GEN_DUMMY_ITEM(P_CATEGORY_ID INTEGER, P_DESCRIPTION
>VARCHAR(50), P_BAR_PREFIX VARCHAR(5), P_COUNT INTEGER) AS
> DECLARE VARIABLE i INTEGER;
>BEGIN
> i = 1;
> WHILE ( i <= :P_COUNT ) DO BEGIN
> INSERT INTO ITEM(ID_CATEGORY, DESCRIPTION, BARCODE, COST_PRICE,
>CURR_VALUE)
> VALUES( :P_CATEGORY_ID,
> ( :P_DESCRIPTION || ' ' || :i ),
> ( :P_BAR_PREFIX || ( :P_CATEGORY_ID * ( 100000 + :i ) + :i *
>10000 + :i * 10 + :P_CATEGORY_ID ) ),
> ( :i * 121 + :P_CATEGORY_ID * 10 + :i ),
> ( :i * 59 ) );
> i = i + 1;
> END /* WHILE */
>END !!
>
>I think I've to cast P_BAR_PREFIX to an integer like CAST(P_BAR_PREFIX AS
>INTEGER) AS BAR_PREFIX
>but I don't know how a cast to mumeric with scale 0 looks like.
>Can you show me?
>
>TIA
>Jörg