-2

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?

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
शेखर
  • 17,412
  • 13
  • 61
  • 117

2 Answers2

0

You can just use a select statement:

SELECT '<HTML TAG>' || column_name || '</ HTML TAG>' from table_name;
Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Luke Liu
  • 298
  • 1
  • 7
0

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>';
Community
  • 1
  • 1
शेखर
  • 17,412
  • 13
  • 61
  • 117