Subject Re: IBO and Arrays
Author Alan J Davies
Hi Jason
I have just downloaded IBO 4 with the latest files date 22/04/2002. I guess
this is the most recent version. I am using Interbase 6 and Firebird 1 on a
number of different projects. and will standardise on Firebird in
the next few months.
I have installed IBO on a test workstation because I particularly want to
check array handling and its been recommended by a number of good sources.
I'm quite happy with FB/IB and run a number of systems using stored
procedures wherever possible.
Before I get the hook right down my throat, can I ask a fairly
straightforward question?
How do I process arrays in stored procedures?
Using your own example:-

CREATE PROCEDURE a_test
(
/*
////////// Can this be done with Interbase ??????
If so, how is it constructed?
*/
a_id integer,
a_chars CHAR(10) [],
a_integers Integer ,
a_floats
)
AS

Begin
Insert into arrays(
Id, CharArray, IntegerArray, RealArray)
Values(
:a_id, :a_Chars, a_integers, a_floats)
end


If you look at this live example you can see why I am interested - the
duplication of the colours and quantities is tedious - and they are passed
as parametes in array format from Delphi6. And this is only 1 of 4 similar,
but different SPs
......
Params.ParamValues['SQty1']:=Silver_Qty[0];
Params.ParamValues['SQty2']:=Silver_Qty[1];
Params.ParamValues['SQty3']:=Silver_Qty[2];
......
ExecProc;

If I could use
Params.ParamValues['SilverQtyArray']:=Silver_Qty;
Params.ParamValues['SilverColourArray']:=Silver_Col;
that would be great.

COMMIT WORK;
SET AUTODDL OFF;
SET TERM ^ ;

/* Stored procedures */

CREATE PROCEDURE ORDITEMS_INSERT
(
ACCOUNT_NMBR CHAR(5),
ORDER_NMBR CHAR(8),
CALL_NMBR CHAR(15),
PART_NMBR_SILVER CHAR(15),
PART_NMBR_GOLD CHAR(15),
ENTRYTIME TIMESTAMP,
LINEPRICE NUMERIC(9, 2),
SILVERPRICE NUMERIC(9, 2),
GOLDPRICE NUMERIC(9, 2),
EUROPRICE NUMERIC(9, 2),
FFPRICE NUMERIC(9, 2),
DISCOUNT NUMERIC(9, 2),
DESC1 CHAR(25),
DESC2 CHAR(25),
SQTY1 SMALLINT,
SQTY2 SMALLINT,
SQTY3 SMALLINT,
SQTY4 SMALLINT,
SQTY5 SMALLINT,
SQTY6 SMALLINT,
SQTY7 SMALLINT,
SQTY8 SMALLINT,
SQTY9 SMALLINT,
SILVERTOTAL SMALLINT,
SCOL1 CHAR(10),
SCOL2 CHAR(10),
SCOL3 CHAR(10),
SCOL4 CHAR(10),
SCOL5 CHAR(10),
SCOL6 CHAR(10),
SCOL7 CHAR(10),
SCOL8 CHAR(10),
SCOL9 CHAR(10),
GQTY1 SMALLINT,
GQTY2 SMALLINT,
GQTY3 SMALLINT,
GQTY4 SMALLINT,
GQTY5 SMALLINT,
GQTY6 SMALLINT,
GQTY7 SMALLINT,
GQTY8 SMALLINT,
GQTY9 SMALLINT,
GOLDTOTAL SMALLINT,
GCOL1 CHAR(10),
GCOL2 CHAR(10),
GCOL3 CHAR(10),
GCOL4 CHAR(10),
GCOL5 CHAR(10),
GCOL6 CHAR(10),
GCOL7 CHAR(10),
GCOL8 CHAR(10),
GCOL9 CHAR(10)
)
AS
Begin
if (:SilverTotal<>0) then begin
Insert into OrdItems(
Acno,Ordno,EntryTime,Partno,Desc1,Desc2,CallNo,
LinePrice,Discount,Sell_Price,EuroPrice,FFPrice,
ORD_QTY1, ORD_QTY2, ORD_QTY3, ORD_QTY4, ORD_QTY5, ORD_QTY6, ORD_QTY7,
ORD_QTY8, ORD_QTY9, ORD_TOT,
COLOUR1, COLOUR2, COLOUR3, COLOUR4, COLOUR5, COLOUR6, COLOUR7, COLOUR8,
COLOUR9
)
Values(

:Account_Nmbr,:Order_Nmbr,:EntryTime,:Part_Nmbr_Silver,:Desc1,:Desc2,:Call_
Nmbr,
:LinePrice,:Discount,:SilverPrice,:EuroPrice,:FFPrice,
:SQty1, :SQty2, :SQty3, :SQty4, :SQty5, :SQty6, :SQty7, :SQty8, :SQty9,
:SilverTotal,
:SCol1, :SCol2, :SCol3, :SCol4, :SCol5, :SCol6, :SCol7, :SCol8, :SCol9
);
end
if (:GoldTotal<>0) then begin
Insert into OrdItems(
Acno,Ordno,EntryTime,Partno,Desc1,Desc2,CallNo,
LinePrice,Discount,Sell_Price,EuroPrice,FFPrice,
ORD_QTY1, ORD_QTY2, ORD_QTY3, ORD_QTY4, ORD_QTY5, ORD_QTY6, ORD_QTY7,
ORD_QTY8, ORD_QTY9, ORD_TOT,
COLOUR1, COLOUR2, COLOUR3, COLOUR4, COLOUR5, COLOUR6, COLOUR7, COLOUR8,
COLOUR9
)
Values(

:Account_Nmbr,:Order_Nmbr,:EntryTime,:Part_Nmbr_Gold,:Desc1,:Desc2,:Call_Nm
br,
:LinePrice,:Discount,:GoldPrice,:EuroPrice,:FFPrice,
:GQty1, :GQty2, :GQty3, :GQty4, :GQty5, :GQty6, :GQty7, :GQty8, :GQty9,
:GoldTotal,
:GCol1, :GCol2, :GCol3, :GCol4, :GCol5, :GCol6, :GCol7, :GCol8, :GCol9
);
end
end
^

SET TERM ; ^
COMMIT WORK;
SET AUTODDL ON;

I have run your example program to get/put array slices and that is ok. In
a server-based situation, however, I want to do the work on the server with
an SP wherever posssible.
Can this be done, and if so could you please indicate how.
I hope I've made myself clear, and also that this is the sort of question
you don't mind responding to. If not, I apologise in advance.
Regards
Alan Davies
Warwick, UK