I want to write a query by which I can iterate through the rows of a table and then I want a HTML un-ordered list from this query and keep in a local variable for further use.
Will I have to use a cursor? Where can I start?
I want to write a query by which I can iterate through the rows of a table and then I want a HTML un-ordered list from this query and keep in a local variable for further use.
Will I have to use a cursor? Where can I start?
You can just use a select
statement:
SELECT '<HTML TAG>' || column_name || '</ HTML TAG>' from table_name;
I found out the solution by googling.
I saw the solution in a Stack Overflow post.
I have created a type as follows:
TYPE MyRec IS RECORD (ANSWERCODE VARCHAR2(20),
SERIALNO NUMBER,
OSCODE varchar2(10),
Osname varchar2(150),
channel_code varchar2(10),
channel_name varchar2(100),
answerdescription VARCHAR2(500),
question_code VARCHAR2(20),
question varchar2(250),
STATUS varchar2(20),
ANSWERSTATUS varchar2(10),
IMAGEPATH varchar2(4000),
MODELVIEW varchar2(100),
MODEL_VIEW varchar2(10),
MAKENAME varchar2(100),
MODELNAME varchar2(100));
rec MyRec;
v_refcurosr SYS_REFCURSOR;
And then call the procedure since my procedure was a cursor that was containing all these fields.
v_answerstep:='<ol>';
pkg_answer.PROC_GET_ANSWER('QUESTION',V_QUESTIONCODE,V_PROVIDERCODE,Ip_UserID,v_refcurosr) ;
LOOP
FETCH v_refcurosr INTO rec;
EXIT WHEN v_refcurosr%NOTFOUND;
v_answerstep:=v_answerstep||'<li>'|| rec.answerdescription|| '</li>';
END LOOP;
v_answerstep:=v_answerstep||'</ol>';