Showing posts with label loop. Show all posts
Showing posts with label loop. Show all posts

Monday, March 26, 2012

How to create html form using loop?

Hello

Maybe someone has faced such a problem?

It's simple to create html form, when a table has few fields. But there are more than 200 fields in my tables! So, a way like below becomes unpleasant :) .

CREATE OR REPLACE PROCEDURE pr_name
(
id1 in varchar2 default null,
id2 in char default null
)
IS
begin
<...>
htp.bodyopen;
htp.p('<FORM>');
htp.tableOpen;
htp.p(' <TR><TD>NAME=id1 VALUE='||id1||'></TD>
<TD>NAME=id2 VALUE='||id2||'></TD></TR> ');
htp.bodyclose;
<...>
end;
/

I had an idea to put this : <TD>NAME=id1 VALUE='||id1||'>
in the loop. But then i cannot find how to define VALUE!

of course, i can put the name of parameters in varray. So, NAME it's not a problem longer: NAME=my_varray(i). But the VALUE is still a headache!

I will appreciate any suggestion.
Thanks.Make use of the possibilitys of cursors. Read the data from your table into a cursor and then loop the cursor. There's a specific cursorloop (a kind of for loop). Something like ...

CURSOR <cursorname> IS
SELECT <blabla>
FROM <blabla>;

put the cursor in the DECLARE part of the code. Now you can loop the cursor like this:

FOR <name> IN <cursorname> LOOP
htp.print( <name>.<column selected in table>);
END LOOP;