Re: Reading a row into a Row variable (SPL)
Posted in 1998
Topics: Stored Procedures & SPL, Data Types & Schema Design, Platform-Specific Issues, Jobs, Consulting & Announcements
Mauricio Hernandez wrote:
> Hello,
>
> I am trying to read an entire row into a Row variable within a
> function. Here is a simplified version of the function:
>
> create function scan()
> returning integer;>
> DEFINE r Table_t; -- Table_t is the row type of "Table"
> DEFINE Aid INTEGER;
>
> FOREACH cursorA FOR
> SELECT * INTO r FROM Table>
> LET Aid = r.mps_urid;
>
> return Aid with resume;
>
> end foreach
> end function;
>
> The problem is that when I run the function, the server complains as
> follows:
>
> 720: Number of columns in FOREACH SELECT does not match number of
> variables.>
> The problem seems to be that '*' is (correctly) interpreted as all the
> attributes of Table and the system seems to be expected as many
> variables as attributes in Table after INTO.
>
> Is there a way to select all attributes into a row variable?
>
> I am running the Universal Server, 9.12.UC1 on Solaris 2.5.1.
>
> Thanks,
> Mauricio
> --
> Mauricio A. Hernandez
> http://www.cs.columbia.edu/~mauricio
Why don't you just select the field mps_urid from the table "table_t"?
If you have a created the table "table_t" with 1 field as a composite
data type then that makes things a little harder but not too hard.
Example
create row type ref_r (
ref_no integer,
ref_desc varchar(20));
create table table_t (
compo_row ref_r);
create function scan(rl_ref ref_r)
returning integer;
return rl_ref.ref_no;
end function;
SELECT scan(compo_row)
FROM table_t
Hope it helps !
David
--
David Thompson (+44171 721 6808)
Salomon Smith Barney (London)
Email : mailto:david.thompson@ssmb.com
Internet : http://www.smithbarney.com