dbTalk Databases Forums  

Re: Inserting into a set of rows in an SPL

comp.databases.informix comp.databases.informix


Discuss Re: Inserting into a set of rows in an SPL in the comp.databases.informix forum.



Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old   
Richard Harnden
 
Posts: n/a

Default Re: Inserting into a set of rows in an SPL - 06-26-2003 , 05:55 AM







Adam Williams wrote in message ...
Quote:
I have a "matrix" of values I need to pass between stored procedures for
various queries.

I can create a LIST type, insert values, return it, query the result,
etc... so long as the list/set has only one value.

If I try to LIST (ROW (...) NOT NULL) I can't figure out how to insert
values into it. I haven't unearthed any example, which makes me wonder
if it is even possible.

For example

DEFINE MULTISET (ROW ( oem_code char(4),
captive float,
noncaptive float
) NOT NULL );
You need to give it a name:

DEFINE matrix MULTISET(...);

Quote:
FOREACH select oem_code, captive_price, non_captive_price
into v_oem_code, v_captive, v_noncaptive
from cust_price
where company_code = i_company_id
and cust_price_code in ('DEFAUL', i_customer_id)

{{{{ HOW DO I INSERT VALUES INTO THE SET? }}}}
INSERT INTO TABLE(matrix) VALUES ( ROW(v_oem_code, v_captive,
v_nocaptive) );

Quote:
END FOREACH;

RETURN matrix;

If I try a simple INSERT INTO TABLE(matrix) VALUES (v_oem_code,
v_captive, v_noncaptive), but I get a wrong number of values error. I'm
thinking I need some funny casting type syntax.
Yes, you're trying to insert 3 values when it only expects 1 row (of 3
values).

You don't need to cast provided that v_oem_code is a char(4) and
v_[non|0]captive are floats.

--
RH





Reply With Quote
Reply




Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.