Dynamically select a complete set of results in a CLOB

Hello

Oracle 11g R2 11.2.0.3

IBM AIX

A developer came to me with a requirement to query a table based on an ID and have the whole read a clob.

It needs to be dynamic, since this code is a FK and may appear in several child tables. I've seen similar questions in the forum but none quite addressed my scenario.

A simple example is:

create table t1 (col1 number, col2 varchar2(50));

insert into t1 values (1,'Test record');
commit;

Here's where I need help.

(i) I select user_tab_columns where table_name = T1.

.. .but in reality I'll pass the name of the table as a parameter.

select column_name 
from user_tab_columns
where table_name = 'T1';

select *
from t1 where id=1;

(II) I need the output to be:

< col_name1 > = < col1_value >; < col_name2 > = < col2_value > etc...

for example

COL1 = 1; Col2 = 'Test in the folder '.

And I need that stored in the content of a CLOB for insertion in a CLOB field in an audit table.

Any help or pointers greatly appreciated. The key is that it should be dynamic that I do not know the composition of the table where the ID, so I must consult the DD.

Phil

You can do this with a query that uses DBMS_XMLGEN.getXML to generate all the data of a query filtered as XML, string flatten the XML into key / value pairs using some XQuery and XMLTable and then use listagg data flattened, to create the concatenated output like you need.  You could do the concatenation with XQuery, but I suspect that listagg is much more effective.

Be warned, Listagg has a length of 4000 characters limitation, so if your concatenation for a single line is beyond that, you can have problems.

Everything you do is change the query string in the call to DBMS_XMLGEN. GetXML. This request can then be used to just pump lines in a CLOB in the comic book.

with xml_test (object_value) as)

Select xmltype (DBMS_XMLGEN. GetXML ('select * from object where rownum)< 3'))="" from="">

),

xmlflatten like)

Select x.*

of xml_test t

XMLTable)

' for $i in $d/ROWSET / / ROW /(child::*)

Returns the element r

{

element node_group_id {fn:count($i/.._/_qui_precede-sibling_::_ligne)}

element node_name {name ($i)}

, element node_value {$i / text ()}

}'

from t.object_value as "d".

whole path in the form of node_group_id columns 'node_group_id '.

node_id for ordinalite

, node_name varchar2 (30) path 'nodeName.

, path of varchar2 (2000) node_value "node_value.

) x

)

Select node_group_id as rec_id, listagg(node_name||) e ='|| node_value, ';') in group data (order by node_id)

of xmlflatten

Node_group_id group

REC_ID DATA
0 OWNER = SYS; OBJECT_NAME = ORA$ BASE; OBJECT_ID = 133; OBJECT_TYPE EDITION; CREATED = 25 AUGUST 15; LAST_DDL_TIME = 25 AUGUST 15; TIMESTAMP = 2015-08 - 25:17:36:52; STATUS = VALID; TEMPORARY = N; GENERATED = N; SECONDARY = N; NAMESPACE = 64; SHARING = NONE; ORACLE_MAINTAINED = Y
1 OWNER = SYS; OBJECT_NAME = DOUBLE; OBJECT_ID = 142; DATA_OBJECT_ID = 142; OBJECT_TYPE = TABLE; CREATED = 25 AUGUST 15; LAST_DDL_TIME = 26 AUGUST 15; TIMESTAMP = 2015-08 - 25:17:36:52; STATUS = VALID; TEMPORARY = N; GENERATED = N; SECONDARY = N; NAMESPACE = 1; SHARING = METADATA LINK. ORACLE_MAINTAINED = Y

2 selected lines.

Tags: Database

Similar Questions

  • dynamic selection list hangs with php

    Hi all

    I can't get a list of dynamic selection of work in dreamweaver. It completely crashes whenever I try to add to my page. I found someone else in the forum who had the same problem, but no one ever answered. I've tried several things, including putting just the dynamic record and select on its own page with no other code in this regard. He always breaks DW. I also tried this coding myself by making a listmenu and change it so that the value of the option equals a value PHP echo. It crashed too much here. Does anyone have a piece of code with a selection list dynamic work that uses a recordset that I could look at? This way I can see where I am going wrong. All I'm trying to do is to get a simple drop-down menu select list of employee names, so anyone can choose their name for advice. This is a table, a set of records 2 fields (first and last name).

    Using DW CS3, php & MySQL, windows XP Pro

    Any help would be really appreciated!

    That's all! Thanks a lot for your help!

  • Failure to have Windows 7 Driver complete Set for Officejet 7780

    Given the fact that HP is a 'partner' with Microsoft and that he was intimately involved in the development of Windows 7, it is rather shameful on the part of HP for not having a driver complete set available for the Officejet 7780 (and other models as well) the day of the launch of Windows 7.  Is there any truth to the idea that started floating that this selective delay in full driver set development is linked to an effort to 'persuade' Windows 7 users to abandon their older HP printers (but very good condition) to the latest models of HP?  For example, the HP Officejet 8500 series most recent printer already has a set of driver Windows 7 released earlier, but the Officejet 7780 does not, even if there are great similarities between the functions and features of the two units of the IOA.  Is that the kind of selective lack of support that we consumers of HP printers should expect from HP in the future?  This seems similar to the well-documented straw in the Vista driver for the HP Officejet 7410, that caused the second page of the duplex to be upside, and HP was well aware of this problem, but refused to offer a software patch to fix it for almost 2 YEARS!

    Hi ImaDingBat

    I really regret this inconvenience. In order to not deprive to use certain features of the printer, HP has built in Win 7 drivers for nearly 700 HP printers including 7780 Officejet which provides the basic printing and scanning features. I do not understand the fact that it does not serve the purpose of the use of this product on Win 7. Here is the document that provides the ETA of the availability of the complete solution and steps to install the printer using built in solutions.

    http://support.HP.com/us-en/document/c01887433

    Thank you

    Naveen K

    HP Support Engineering Center

    Click on the yellow button of KUDOS to say thank you

    (Although employed by HP, I'm trying to solve problems with my will and my employer bears no responsibility for my answers)

  • You have reached the maximum of pages in this set of results of content. If you are looking for something specific, try applying a filter of content type or enter a search term.

    I get error frequently below.  In General, when you navigate on old posts on the forum SQL and PL/SQL, after reading a post, I click on the left arrow in my Firefox browser, which I expect to take me to the page of the posts that I had.  Instead, I get a page with no messages.  I then click on a forum page numbers in the upper right corner.  Sometimes brings back me to the page that displays the list of the posts that I had.  However, more often I get the below error.  So try to navigate from one position to another is desperately slow.  You can fix this?  Everybody brings a work around to be able to get from one station to another, or at least back to old messages without the error page?  This is a problem that happened before and after the upgrade.

    "You have reached the maximum of pages in this set of results of content. If you are looking for something specific, try applying a filter of content type or enter a search term. »

    Have you tried right-click (ctrl-click on Mac) and choose 'Open link in a new tab' instead? With all the dynamic html today browser back and before options are often dead still. If you open links in a new tab or window, you can simply close the window instead of using the back button. It may take awhile to get used to it, but there are some benefits, such as the loading of the pages in the background, and you do not lose the focus of the page where you. You can disable "when I open a link in a new tab, swtich it immediately." If I understand your problem, maybe it works better.

  • Query to get the data of the column and the metadata in the same set of results.

    Is it possible to build a query to get the values of the columns in a table and also be able to get some metadata (data type, data_length, data_precision, data_scale) for columns in the same set of results.

    If I use a join, have a common value to join on the two tables?

    you use a cross join, not requiring common values.

    create table T (n number, d date, v varchar2(30));
    insert into T values (1,sysdate,'ABC');
    commit;
    
    select C.column_name, c.data_type, c.data_length,
    case c.column_id
     when 1 then to_char(T.N)
     when 2 then to_char(T.D)
     when 3 then T.V
    end VALUE
    from USER_TAB_COLUMNS C, T
    where C.table_name='T'
    order by c.column_id;
    
  • Total amount and are rotating back in the same set of results

    I want to return a set of results in the following format:
    YEARMONTH Total ModelA ModelB ModelC
    200101    0     0      0      0
    200102    10    5      5      0
    200103    8     2      2      4
    where the total amount is the sum of the hours for all types of models grouped by yearmonth and columns of each model are the sum of hours per type of model grouped by yearmonth. I can get the correct results with the following query selects nested:
            select distinct yearmonth,
         sum(a.hours) as Total,
         (select sum(b.hours) from model_hours b
             where model = 'ModelA' and a.yearmonth = b.yearmonth) as ModelA,
            (select sum(b.hours) from model_hours b
             where model = 'ModelB' and a.yearmonth = b.yearmonth) as ModelB,
            (select sum(b.hours) from model_hours b
             where model = 'ModelC' and a.yearmonth = b.yearmonth) as ModelC
        from model_hours a
        group by yearmonth
        order by yearmonth
    I was curious to try use the pivot function in Oracle 11 to get the same results and I am able to get all the results, EXCEPT the total number of hours by using the following query:
        select * from (
             select yearmonth, hours, model
             from model_hours a
        )
        pivot
        ( 
             sum(hours)
             for model in ('ModelA', 'ModelB', 'ModelC')
        )
        order by yearmonth
    which returns this result:
    YEARMONTH  ModelA ModelB ModelC
    200101     0      0      0
    200102     5      5      0
    200103     2      2      4
    I was not able to understand how to get the sum of hours for all models, grouped by yearmonth, in this result set also. Is this possible? And if yes, isn't - that's likely to be more effective than selects it nested? This particular table has some 200K lines right now.

    Hello

    As far as I know, the Oracle 11 SELECT... PIVOT function only works on mutually exclusive groups.
    You can derive the total revolving data, like this:

    WITH        pivoted_data          AS
    (
         select  *
         from      (
                           select  yearmonth, hours, model
                    from    model_hours a
                  )
             pivot
              (
                      sum(hours)
                      for model in ( 'ModelA'     AS modela
                                   , 'ModelB'     AS modelb
                         , 'ModelC'     AS modelc
                         )
                  )
    )
    SELECT       yearmonth
    ,       modela + modelb + modelc     AS totla     -- may need chnaging if values can be NULL
    ,       modela, modelb, modec
    FROM       pivoted_data
    ORDER BY  yearmonth
    ;
    

    Published by: Frank Kulash, 26 March 2012 15:01

  • Comparing the 2 sets of results

    Hello

    I compare the 2 sets of results and determine if they are identical.

    Queries are:

    SELECT CARRIER_ID, ROUTE_POSITION
    OF ROUTE_WG_PHASE4

    SELECT CARRIER_ID, ROUTE_POSITION
    OF ROUTE_WG_PHASE3

    I tried to use less, but it does not work when the first result set has fewer than the second record.

    Oracle 10g

    Thank you

    In general, you can do something like

    (
    SELECT CARRIER_ID,ROUTE_POSITION , 'In 4 and not 3' desc
      FROM ROUTE_WG_PHASE4
    MINUS
    SELECT CARRIER_ID,ROUTE_POSITION , 'In 4 and not 3' desc
      FROM ROUTE_WG_PHASE3
    )
    UNION ALL
    (
    SELECT CARRIER_ID,ROUTE_POSITION , 'In 3 and not 4' desc
      FROM ROUTE_WG_PHASE3
    MINUS
    SELECT CARRIER_ID,ROUTE_POSITION , 'In 3 and not 4' desc
      FROM ROUTE_WG_PHASE4
    )
    

    According to the specificity of your data, you can also just add a COUNT (*) () to each query and a single NEGATIVE sign.

    Justin

  • How can I dynamically select the shared Variable API programming data type?

    I am trying to create a configuration of open connections of variable shared using the programming API. It seems to me that the cleanest way to do would be to put one "open and check" routine in a loop, then call it for each variable in the library.

    The question that I am running is that I have different types of data in my library (to help a server Modbus i/o and data types 'boolean' and 'single' in my library.) How can I dynamically select the data type of the shared variable API?

    See the attached snipit.

    Thank you

    What I ended up doing was doing a Subvi to open, read, write, and close each data type, I use the packaged in 4 polymorphic SubVIs (polymorphic Open, read, etc...)

    Now all I have to do I drop in the polymorphic Subvi and it switches automatically to the appropriate data type

  • Dynamic selection tabular list

    Hello, I am new to the PL/SQL and APEX.

    I want to create the dynamic selection list in a table based on another column in the same tabular form. But lack me of expression stop.

    Can someone tell me whats wrong with my code?

    Behold, my code

    SELECT ID, NILAI,

    APEX_ITEM. SELECT_LIST_FROM_QUERY (7, NILAI,'SELECT V.MEANING AS DISPLAY,)

    LOOKUP_CODE AS RETURN_V FROM apps.fnd_lookup_types_vl@SUCODEV T,

    Apps.fnd_lookup_values_vl@SUCODEV V where T.lookup_type = V.lookup_type and v.attribute_category =' |' SCI_TYPE_SELEKSI' | "and V.ATTRIBUTE1 =' |" BADAN |) SELECT_LIST_NILAI

    OF SCI_TABLE

    v.attribute_category is the search category in the database

    I want to make this dynamic selection list as V.ATTRIBUTE1 value is generated by another column named BADAN

    I'm sorry for the bad explanation

    I just edited my nickname of Lexover XD

    Thank you

    Post edited by: Lexover

    Post edited by: Lexover

    Hi guys, I found the error. Here's the correct code:

    SELECT ID, NILAI,

    APEX_ITEM. SELECT_LIST_FROM_QUERY (7, NILAI,'SELECT V.MEANING AS DISPLAY,)

    LOOKUP_CODE AS RETURN_V FROM apps.fnd_lookup_types_vl@SUCODEV T,

    Apps.fnd_lookup_values_vl@SUCODEV V where T.lookup_type = V.lookup_type and v.attribute_category = "SCI_TYPE_SELEKSI" and V.ATTRIBUTE1 =' | NILAI) SELECT_LIST_NILAI

    OF SCI_TABLE

    I put the apostrophe before | and the column name (parameter) and doble single quote in varchar where clause. Double quotation mark, 2 times the apostrophe. Easy to understand hope.

    Thanks guys for the feedback.

    Lexover

  • I work for an organization not-for-profit, and I wondered what might be a plan of this organization to use? Really looking for us in the first but are interested in the complete set of CC.

    I work for an organization not-for-profit, and I wondered what might be a plan of this organization to use? Really looking for us in the first but are interested in the complete set of CC.

    Please see this link

    Non profits

    If your institution not-for-profit or charity meets the conditions above, you can browse the education of Adobe software versions. Once you are ready to buy, you will be asked to present evidence or your qualification status when ordering.

  • The complete set of creative cloud (that students and teachers) includes all programs?

    Hello world!

    I mean sorry if this question seems very obvious, but I didn't know if Adobe Acrobat Pro is included is this package, I'd appreciate it if someone could answer this question. Thank you very much.

    Kind regards.

    In terms of pricing and membership cc | Adobe Creative Cloud it indicates clearly that

    "Students and teachers get the complete set of Cloud applications and services at a special price creative."

    Acrobat pro 11 is now available with CC.

    Please refer to: http://www.adobe.com/creativecloud/buy/students.html

    Concerning

    Baudier

  • Dynamic selection of images for OBIEE 11 g report

    Hello dear colleagues,

    need help to solve a problem with the dynamic selection of images for reports OBIEE 11 g.
    For OBIEE 10 g, it works perfectly - put images in

    *'\ < HOME_ORACLE_BI > \web\app\res\s_oracle10\images'*

    Directory and enter edit the column formula (in the answers) of the expression:

    * ' < table_name > '. "" < table_column > | ". jpg'*.

    and selecting

    URL of the image (in the properties of column-> Data Format)

    retrieve the images appropriate for the corresponding model (the project is for fashion retail customer) regarding the description of the specified column (for example * "DM_ITEM".) «MODEL_CODE ' ('09361' = *) put correspondence the name of the image file (* '09361.jpg' *).»

    For the OBIEE 11g (installed on W7, DWH on MSSQL 2008R2, VM in the field), I followed the link * "http://vikramwalia.wordpress.com/category/obiee-11g/" * and stuck at the step where the browser should recover image (s) based on the following address:

    *' http://localhost:9704/analyticsRes/product / *.

    Dive into the issue, I checked the staticports.ini and in the * [WEBLOGIC] * section find the following message is displayed:

    *#The port of 'content' for the most part POET. This is the Weblogic managed server port on which BIEE applications are deploie.*
    Oracle WLS BIEE managed Server Port No. = 9704

    that seems to be OK...

    The netstat command response confuses me much since I found (and also of external) record for TCP Local address (should be < IP localhost >: 9704), which lead me to the point that, probably one of the OBIEE 11 g services not started OR I made a mistake during installation of OBIEE 11 g, although the system did not send a message about this possibility. BTW, the BI Publisher on this machine works correctly.

    So, kindly ask support or advice on this subject. Thank you
    AL

    Published by: user7374943 on 29.04.2013 01:01

    Published by: user7374943 on 29.04.2013 02:15

    Published by: user7374943 on 29.04.2013 02:19

    Not able to open the IAM blog you referred to above.

    Make sure that you have deployed the analyticsRes component as shown in http://www.oracle.com/webfolder/technetwork/tutorials/obe/fmw/bi/bi1113/customizing_obiee11g/customizing_obiee11g.htm. Create a folder called produced under analyticsres and start accessing images.

    Good luck...
    Isabelle Renon

  • Dynamic selection list: link to another page

    Hello

    Following the list of dynamic selection at the bottom of page "product.php" (www.dolls.com.sg)

    < div id = "selectcat" >

    < select name = "Catégories" >

    <? PHP

    {}

    ? >

    < option value = "<?" PHP echo $row_rsCategories ["categoryName"]? > "<?" PHP if (!) () strcmp ($row_rsCategories ["categoryName"], $row_rsCategories ["categoryName"]))) {echo "selected = \"selected\"" ;}? "} > > <? PHP echo $row_rsCategories ["categoryName"]? > < / option >

    <? PHP

    } While ($row_rsCategories = mysql_fetch_assoc ($rsCategories));

    $rows = mysql_num_rows ($rsCategories);

    If ($rows > 0) {}

    mysql_data_seek ($rsCategories, 0);

    $row_rsCategories = mysql_fetch_assoc ($rsCategories);

    }

    ? >

    < / select >

    My goal is, whenever a visitor clicks on a category in the drop down menu, it is transmitted to the respective page "categories.php".

    How can I do?

    Thank you

    Helmut

    Change your code to this:

    In categories.php, use $_GET ['categories'] to filter the Recordset.

  • Problems with dynamic selection lists in IE7

    I have another problem related to the last one I posted here: http://www.adobe.com/cfusion/webforums/forum/messageview.cfm?catid=217 & threadid = 1385428

    I have a list of dynamic selection populated by a SQL Server database.

    I want to select all the items in the list if you have selected a particular item. The code I wrote works fine in Firefox, and I'm assuming that other browsers as well. It does everything not in IE and the specific test does not not in IE7.

    I can't use the fix suggested for my last question, because this time I want all of the selected options and selectedIndex applies only to a single option.

    Any ideas on what I can do to make it work in IE7?

    Here is the code I use:

    I have provided a solution to this question in another forum:

    http://www.Tek-Tips.com/viewthread.cfm?QID=1495671&page=1

    Thank you
    Jesse

  • Setting the default value for a dynamic selection menu

    Hi I have a php with 2 forms to this topic page, you feed on the other to achieve a lock down (manufacturer > model). The menu then select I have a static default value 'Select a model aircraft', I want to set a value for the first menu select dynamic to read "select the manufacturer. When I add a static value to my list, it tells me I alreay have a dynamic behavior on this menu and choose another. I've included the code for two menus. Thank you in advance, I know it must be a stupid question, but it has left me speechless.

    Tom

    This is the menu that I want to add static value defaults to.

    < td width = "667" > < select name = "airMake" style = "" width: 200px; "" OnChange = "This.Form.Submit (); "id ="airMake">

    <? PHP

    {}

    ? >

    < option value = "<?" PHP echo $row_rsAirManufacturer ['aircraft_manufacturer']? > "<?" PHP if (!) strcmp () ($row_rsAirManufacturer ['aircraft_manufacturer'], ((isset($_POST["airMake"]))? $_POST ['airMake'] :""))) {echo "selected =-'selected\'" ;}?})) > > <? PHP echo $row_rsAirManufacturer ['aircraft_manufacturer']? > < / option >

    <? PHP

    } While ($row_rsAirManufacturer = mysql_fetch_assoc ($rsAirManufacturer));

    $rows = mysql_num_rows ($rsAirManufacturer);

    If ($rows > 0) {}

    mysql_data_seek ($rsAirManufacturer, 0);

    $row_rsAirManufacturer = mysql_fetch_assoc ($rsAirManufacturer);

    }

    ? >

    < / select >

    < table >

    < /tr >

    < / table > < / make >

    < do action = "quoteResult.php" method = "post" name = "quoteForm" > "

    < table width = "100%" border = "0" cellpadding = "5px" >

    < b >

    < td width = "260" style = "color: #000;" text-align: right; "> aircraft model: < table >

    < td colspan = "2" > < span id = "spryselect2" >

    This is the menu that works properly.

    < select name = "airModel" style = "" width: 200px; "id ="airModel">"

    < option value = "" <? " PHP if (!) () strcmp ("", ((isset($_POST["airMakeField"]))? ") $_POST ['airMakeField'] :""))) {echo "selected =-'selected\'" ;}?} > > < / option >

    <? PHP

    {}

    ? >

    < option value = "<?" PHP echo $row_rsAirModel ['aircraft_model']? > "<?" PHP if (!) strcmp () ($row_rsAirModel ['aircraft_model'], ((isset($_POST["airMakeField"]))? $_POST ['airMakeField'] :""))) {echo "selected =-'selected\'" ;}?})) > > <? PHP echo $row_rsAirModel ['aircraft_model']? > select a model airplane < / option >

    <? PHP

    } While ($row_rsAirModel = mysql_fetch_assoc ($rsAirModel));

    $rows = mysql_num_rows ($rsAirModel);

    If ($rows > 0) {}

    mysql_data_seek ($rsAirModel, 0);

    $row_rsAirModel = mysql_fetch_assoc ($rsAirModel);

    }

    ? >

    < / select >

    -Change

    So if the value of "airMake" is - 1, you know that no choice has been made.

Maybe you are looking for