Icon View Thread

The following is the text of the current message along with any replies.
Messages 1 to 2 of 2 total
Thread Fetch [Orientation] from <CursorName> (Column_Array) Into (Dest_Array);
Sun, Dec 15 2013 11:46 PMPermanent Link

Barry

I'd like the fetch statement be able to use an array for the column names like "_vColNames", and another array for the target, like "_vFloatTargets".

This would make it much easier to construct Fetch statements without having to specify every INTO variable (if the variables are all the same type).

Simple Example:

Declare _vColNames VarChar(30) array[10] default NULL;
Declare _vFloatTargets Float Array[10] default NULL;

set _vColNames[1] = 'Col1';
set _vColNames[2] = 'Col2';
....
....

Fetch First from DBCursor (_vColNames) into _vFloatTargets;

A lot of my tables have rows full of Float values and to specify each one of them in every Fetch statement is a real pain.

We could even get fancier and use something like this:

Fetch First from DBCursor (_vColNames) into _CustName, _CustId, _vFloatTargets, _vIntTargets, _VendorId;

The first two column values get put into _CustName and _CustId, then the next 10 values get put into the array _vFloatTargets and the next 10 values get put into the array _vIntTargets, then the last element of _vColNames gets put into _VendorId.

So the cardinality of the array _vColNames must match the cardinality in the destination arrays and the number of scalar destination variables. So if v_FloatTargets and _vIntTargets have 10 elements each, we have 20 + 3 or 23 destination variables to fill. This means the _vColNames array would have 23 column names to match the destination variables.

This would allow us to write Fetch statements that aren't dependent on a fixed number of hard coded variables. We could even pass the column names and column types as parameters to a procedure and the procedure could shape the array elements at run time for the Fetch statement.

What do you think?

Barry
Tue, Dec 17 2013 9:44 AMPermanent Link

Tim Young [Elevate Software]

Elevate Software, Inc.

Avatar

Email timyoung@elevatesoft.com

Barry,

<< I'd like the fetch statement be able to use an array for the column names
like "_vColNames", and another array for the target, like "_vFloatTargets".
>>

Noted.

Tim Young
Elevate Software
www.elevatesoft.com
Image