Dynamically populating variables [message #433241] |
Mon, 30 November 2009 23:26  |
rishi1979
Messages: 36 Registered: November 2006
|
Member |
|
|
Hi,
I had table temp in which there are 10 records.I had a database package in which there are ten variables var1,var2,var3...var10.
My requirement is that i want the first record from the table temp to be shown in the first variable like.
var1 := 1;--first record of table temp
var2 := 2;--second record of table temp
var2 := 3;..
one method which i had used is by creating a pl/sql table and then putting the values from the table temp in it and then calling the pl/sql table in the packgae like.
var1 := tab(1);
var2 := tab(2);
Is there any other way of doing this also.as i dont want to hard code the values.
Thanks in advance
|
|
|
Re: Dynamically populating variables [message #433243 is a reply to message #433241] |
Mon, 30 November 2009 23:36   |
 |
BlackSwan
Messages: 26766 Registered: January 2009 Location: SoCal
|
Senior Member |
|
|
>My requirement is that i want the first record from the table temp to be shown in the first variable like.
Rows in a table are like balls in a basket.
How do you identify the "first" ball in the basket.
Rows in a table have NO inherent order!
Your requirement is totally meaningless.
>var1 := 1;--first record of table temp
A record could many different data type fields.
EXACTLY how do you assign a whole record to a single variable?
Please provide reproducible test case which includes all possible datatypes in Oracle.
[Updated on: Mon, 30 November 2009 23:50] Report message to a moderator
|
|
|
Re: Dynamically populating variables [message #433267 is a reply to message #433243] |
Tue, 01 December 2009 02:36   |
rishi1979
Messages: 36 Registered: November 2006
|
Member |
|
|
the record's are in one column of the table not all the records from the table .sorry for not making it clear .Ten record from one column of the table .it doesn't matter in which order they are coming but once fetched they should display like var1 := 1,
var2:=2 means each single record should display in seperate variable it dosent matter in which order .
|
|
|
Re: Dynamically populating variables [message #433272 is a reply to message #433241] |
Tue, 01 December 2009 03:12  |
JRowbottom
Messages: 5933 Registered: June 2006 Location: Sunny North Yorkshire, ho...
|
Senior Member |
|
|
Loading the records into a table is the best solution that you're going to get.
To be honest, I wouldn't unload them into the 10 variables - I'd just keep them in the plsql table and pass that around.
|
|
|