LIST collection type usage
Posted in 2012
Topics: Data Types & Schema Design
All,
IDS11.50FC8.
It seems LIST collection type would be the only option of us to store
a list of values of a parameter(column).
We could hardly find good examples about how to use LIST collection
type. For example, for a particular row of a table, how to add a
element to its column(of LIST type)......? What we can only find about
LIST usages is the following paragraph, which is apparently not enough
for users to learn to use it....
Any suggestions? Alternative? or ...??
Thanks,
Frank
Insert into a LIST
If the collection is a LIST, you can add the new element at a specific
point in the LIST or at the end of the LIST. As with a SET or MULTISET, you
must first define a collection variable and select a collection from the
database into the collection variable.
The following figure shows the statements you need to define a collection
variable and select a LIST from the *numbers* table into the collection
variable.
Figure 1. Defining a collection variable and selecting a LIST.
DEFINE e_coll LIST(INTEGER NOT NULL);
SELECT evens INTO e_coll FROM numbers
WHERE id = 99;
At this point, the value of *e_coll* might be LIST {2,4,6,8,10}. Because *
e_coll* holds a LIST, each element has a numbered position in the list. To
add an element at a specific point in a LIST, add an AT *position* clause
to the INSERT statement, as the following figure shows.
Figure 2. Add an element at a specific point in a LIST.
INSERT AT 3 INTO TABLE(e_coll) VALUES(12);
Now the LIST in *e_coll* has the elements {2,4,12,6,8,10}, in that order.
The value you enter for the *position* in the AT clause can be a number or
a variable, but it must have an INTEGER or SMALLINT data type. You cannot
use a letter, floating-point number, decimal value, or expression.
*Parent topic:* Insert elements into a collection
variable<http://publib.boulder.ibm.com/infocenter/idshelp/v115/topic/com.ibm.sql
t.doc/ids_sqt_475.htm>
--0016e6d975b88b465504b67098db
Frank:
LIST, SET and MULTISET are all forms of a COLLECTION. The
major differences are listed below.
SET
must contain unique values and no order
MULTISET
can contain duplicate values and no order
LIST
can contain duplicate values with order
If you look in the manual for COLLECTIONS then you will find lots of
information and examples. The info center stopped at 500 items when I
queried on collections
John F. Miller III
STSM, Embedability Architect
miller3@us.ibm.com
503-578-5645
IBM Informix Dynamic Server (IDS)
(Embedded image moved to file: pic11949.gif)
ids-bounces@iiug.org wrote on 01/13/2012 02:43:43 PM:
> From: "FRANK" <yunyaoqu@gmail.com>
> To: ids@iiug.org
> Date: 01/13/2012 02:44 PM
> Subject: LIST collection type usage [25932]
> Sent by: ids-bounces@iiug.org
>
> All,
>
> IDS11.50FC8.
>
> It seems LIST collection type would be the only option of us to store
> a list of values of a parameter(column).
> We could hardly find good examples about how to use LIST collection
> type. For example, for a particular row of a table, how to add a
> element to its column(of LIST type)......? What we can only find about
> LIST usages is the following paragraph, which is apparently not enough
> for users to learn to use it....
>
> Any suggestions? Alternative? or ...??
>
> Thanks,
> Frank
>
> Insert into a LIST>
> If the collection is a LIST, you can add the new element at a specific
> point in the LIST or at the end of the LIST. As with a SET or MULTISET,
you
> must first define a collection variable and select a collection from the
> database into the collection variable.
> The following figure shows the statements you need to define a collection
> variable and select a LIST from the *numbers* table into the collection
> variable.
> Figure 1. Defining a collection variable and selecting a LIST.
>
> DEFINE e_coll LIST(INTEGER NOT NULL);
>
> SELECT evens INTO e_coll FROM numbers
>
> WHERE id = 99;
>
> At this point, the value of *e_coll* might be LIST {2,4,6,8,10}. Because
*
> e_coll* holds a LIST, each element has a numbered position in the list.
To
> add an element at a specific point in a LIST, add an AT *position* clause
> to the INSERT statement, as the following figure shows.
> Figure 2. Add an element at a specific point in a LIST.
>
> INSERT AT 3 INTO TABLE(e_coll) VALUES(12);
>
> Now the LIST in *e_coll* has the elements {2,4,12,6,8,10}, in that order.
>
> The value you enter for the *position* in the AT clause can be a number
or
> a variable, but it must have an INTEGER or SMALLINT data type. You cannot
> use a letter, floating-point number, decimal value, or expression.
> *Parent topic:* Insert elements into a collection
>
> variable<http://publib.boulder.ibm.com/infocenter/idshelp/v115/
> topic/com.ibm.sqlt.doc/ids_sqt_475.htm>
>
> --0016e6d975b88b465504b67098db
>
>
>
*******************************************************************************
> Forum Note: Use "Reply" to post a response in the discussion forum.
>
Thanks a LOT, John!!
Have a great weekend!!
Frank
On Fri, Jan 13, 2012 at 6:03 PM, John Miller iii <miller3@us.ibm.com> wrote:
> Frank:
>
> LIST, SET and MULTISET are all forms of a COLLECTION. The
> major differences are listed below.
>
> SET
>
> must contain unique values and no order
> MULTISET
>
> can contain duplicate values and no order
> LIST
>
> can contain duplicate values with order
>
> If you look in the manual for COLLECTIONS then you will find lots of
> information and examples. The info center stopped at 500 items when I
> queried on collections
>
> John F. Miller III
> STSM, Embedability Architect
> miller3@us.ibm.com
> 503-578-5645
> IBM Informix Dynamic Server (IDS)
> (Embedded image moved to file: pic11949.gif)
>
> ids-bounces@iiug.org wrote on 01/13/2012 02:43:43 PM:
>
> > From: "FRANK" <yunyaoqu@gmail.com>
> > To: ids@iiug.org
> > Date: 01/13/2012 02:44 PM
> > Subject: LIST collection type usage [25932]
> > Sent by: ids-bounces@iiug.org
> >
> > All,
> >
> > IDS11.50FC8.
> >
> > It seems LIST collection type would be the only option of us to store
> > a list of values of a parameter(column).
> > We could hardly find good examples about how to use LIST collection
> > type. For example, for a particular row of a table, how to add a
> > element to its column(of LIST type)......? What we can only find about
> > LIST usages is the following paragraph, which is apparently not enough
> > for users to learn to use it....
> >
> > Any suggestions? Alternative? or ...??
> >
> > Thanks,
> > Frank
> >
> > Insert into a LIST> >
> > If the collection is a LIST, you can add the new element at a specific
> > point in the LIST or at the end of the LIST. As with a SET or MULTISET,
> you
> > must first define a collection variable and select a collection from the
> > database into the collection variable.
> > The following figure shows the statements you need to define a collection
>
> > variable and select a LIST from the *numbers* table into the collection
> > variable.
> > Figure 1. Defining a collection variable and selecting a LIST.
> >
> > DEFINE e_coll LIST(INTEGER NOT NULL);
> >
> > SELECT evens INTO e_coll FROM numbers
> >
> > WHERE id = 99;
> >
> > At this point, the value of *e_coll* might be LIST {2,4,6,8,10}. Because
> *
> > e_coll* holds a LIST, each element has a numbered position in the list.
> To
> > add an element at a specific point in a LIST, add an AT *position* clause
>
> > to the INSERT statement, as the following figure shows.
> > Figure 2. Add an element at a specific point in a LIST.
> >
> > INSERT AT 3 INTO TABLE(e_coll) VALUES(12);
> >
> > Now the LIST in *e_coll* has the elements {2,4,12,6,8,10}, in that order.
>
> >
> > The value you enter for the *position* in the AT clause can be a number
> or
> > a variable, but it must have an INTEGER or SMALLINT data type. You cannot
>
> > use a letter, floating-point number, decimal value, or expression.
> > *Parent topic:* Insert elements into a collection
> >
> > variable<http://publib.boulder.ibm.com/infocenter/idshelp/v115/
> > topic/com.ibm.sqlt.doc/ids_sqt_475.htm>
> >
> > --0016e6d975b88b465504b67098db
> >
> >
> >
>
>
>
*******************************************************************************
>
> > Forum Note: Use "Reply" to post a response in the discussion forum.
> >
>
>
>
>
*******************************************************************************
> Forum Note: Use "Reply" to post a response in the discussion forum.
>
>
--e89a8f3ba9e1c20ec404b670f126
create table tab_with_list( one serial, two list(int), ...)
Art
Art S. Kagel
Advanced DataTools (www.advancedatatools.com)
Blog: http://informix-myview.blogspot.com/
Disclaimer: Please keep in mind that my own opinions are my own opinions
and do not reflect on my employer, Advanced DataTools, the IIUG, nor any
other organization with which I am associated either explicitly,
implicitly, or by inference. Neither do those opinions reflect those of
other individuals affiliated with any entity with which I am affiliated nor
those of the entities themselves.
On Fri, Jan 13, 2012 at 5:43 PM, FRANK <yunyaoqu@gmail.com> wrote:
> All,
>
> IDS11.50FC8.
>
> It seems LIST collection type would be the only option of us to store
> a list of values of a parameter(column).
> We could hardly find good examples about how to use LIST collection
> type. For example, for a particular row of a table, how to add a
> element to its column(of LIST type)......? What we can only find about
> LIST usages is the following paragraph, which is apparently not enough
> for users to learn to use it....
>
> Any suggestions? Alternative? or ...??
>
> Thanks,
> Frank
>
> Insert into a LIST>
> If the collection is a LIST, you can add the new element at a specific
> point in the LIST or at the end of the LIST. As with a SET or MULTISET, you
> must first define a collection variable and select a collection from the
> database into the collection variable.
> The following figure shows the statements you need to define a collection
> variable and select a LIST from the *numbers* table into the collection
> variable.
> Figure 1. Defining a collection variable and selecting a LIST.
>
> DEFINE e_coll LIST(INTEGER NOT NULL);
>
> SELECT evens INTO e_coll FROM numbers
>
> WHERE id = 99;
>
> At this point, the value of *e_coll* might be LIST {2,4,6,8,10}. Because *
> e_coll* holds a LIST, each element has a numbered position in the list. To
> add an element at a specific point in a LIST, add an AT *position* clause
> to the INSERT statement, as the following figure shows.
> Figure 2. Add an element at a specific point in a LIST.
>
> INSERT AT 3 INTO TABLE(e_coll) VALUES(12);
>
> Now the LIST in *e_coll* has the elements {2,4,12,6,8,10}, in that order.
>
> The value you enter for the *position* in the AT clause can be a number or
> a variable, but it must have an INTEGER or SMALLINT data type. You cannot
> use a letter, floating-point number, decimal value, or expression.
> *Parent topic:* Insert elements into a collection
>
> variable<
>
http://publib.boulder.ibm.com/infocenter/idshelp/v115/topic/com.ibm.sqlt.doc/ids
_sqt_475.htm
> >
>
> --0016e6d975b88b465504b67098db
>
>
>
>
*******************************************************************************
> Forum Note: Use "Reply" to post a response in the discussion forum.
>
>
--14dae934097d0b34db04b685497d