please help, urgent! [message #2770] |
Mon, 12 August 2002 10:15 |
keane
Messages: 23 Registered: June 2002
|
Junior Member |
|
|
hi, i have a table with several columns now, i want to write a function so that the user can input any number of columns of that table, then the function will return a string containing the values of those columns.
table tab(col_1 number(2), col_2 number(2), col_3 number(3))
suppose it contains two rows initiallly
tab(1, 2, 3)(7, 8, 9)
i suppose the function is like this
the user input col_1, it returns 1#7#
the user input col_2, it returns 2#8#
the user input col_3, it returns 3#9#
i don't know how to write the function, can you help?
keane
|
|
|
Re: please help, urgent! [message #2801 is a reply to message #2770] |
Wed, 14 August 2002 02:49 |
santosh
Messages: 85 Registered: October 2000
|
Member |
|
|
hi keane,
If you are not aware of howmany columns are there in the table or what are the names for columns you can use user_tab_columns table this gives info abt table columns and data type as well as length.
You can give the choice to user to select particular column from the table by using two procedures as follows
create or replace procedure columnselect (tname char) as
cursor c is select column_name from tname;
begin
dbms_output.put_line('table '||tname||' has columns as follows');
for i in c loop
dbms_output.put_line(i.column_name);
end loop;
end;
create or replace procedure columnvalues(cname char,tname char) as
cursor c is select cname from tname;
begin
dbms_output.put_line('cname');
for i in c loop
dbms_output.put_line(i.cname);
end loop;
end;
|
|
|