vendredi 30 mai 2014

Oracle - Build select statements using values from a table


Vote count:

0




I have a complex need but i'll try to keep it simple and use my brain on an answer that fullfills my basic need.


I have a table, TABLE1, with 2 columns, ID(INTEGER), LVL_CNT(INTEGER) & CLOB_COLUMN(CLOB). CLOB_COLUMN will have a select statement. Following are the values held in each column to show an example.


ID = 1 LVL_CNT = 10 CLOB_COLUMN will have script as follows:



SELECT 'ID',
'Name',
'Description',
'Group',
'Level Count',
'Usage',
'Snapshot Date',
'Conformed Hierarchy',
'Level Name:',
'Level Name:',
'Level Name:',
'Level Name:',
'Level Name:',
'Level Name:',
'Level Name:',
'Level Name:',
'Level Name:',
'Level Name:
FROM dual;


Currently, I am writing the CLOB script manually but I would like to build it automatically to avoid writing it for all records. "'Level Name:'" is iterated 10 times because LVL_CNT = 10. If LVL_CNT = 5 then iterate "'Level Name:'" 5 times. How can I achieve this?



asked 45 secs ago






Aucun commentaire:

Enregistrer un commentaire