SQL puzzler: Line rankings according to the columns

We have a table that looks like the following:

COL_1_RANK COL_1_VALUE COL_2_RANK COL_2_VALUE
1AAA3HHH
2BBB2GGG
3CCC5JJJ
4DDD1FFF
5EEE4III

We want to extract a *single* rank for each case where COL_1_RANK and COL_2_RANK are equivalent. Then we want the values corresponding to this mutual rank to be contained in the same line. Thus, the desired output is as follows:

MUTUAL_RANK COL_1_VALUE COL_2_VALUE
1AAAFFF
2BBBGGG
3CCCHHH
4DDDIII
5EEEJJJ

The other condition is that we want to do this in a *table single pass*. So we are aware of the solutions using two different CLAUSES and by joining in the ranks. It's not what we're looking for here.

We are suspecting that some analytic function can be used here, but can't seem to find, he. Basically, for each line, take the value of COL_1_RANK and, then, on the set of all values of COL_2_RANK , locate the line where COL_2_RANK = s COL_1_RANK. Pull the COL_2_VALUE of this line.

No matter what SQL Smarties out there who have a solution for this?

Thank you

-Joe

SELECT col_1_rank,

col_1_value,

REGEXP_SUBSTR (listagg (col_2_value, ",") THE Group (ORDER BY col_2_rank) (),

'[^,]+',

1,

col_1_rank)

col_2_value

T

order by 1;

Tags: Database

Similar Questions

  • SQL Server Oracle Migration: semantics of the column

    I'm testing a migration to SQL Server 2012 to Oracle 12 c using SQL Developer 4.0.0.13 migration Assistant. The problem that I am facing is that all the generated table creation scripts have CHARACTER semantics for character columns. I wish that the semantic bytes. As the generated tables and columns are several thousand it is not possible to manually change the semantics.

    CREATE TABLE account_dod)

    account_ID VARCHAR2 (16 CHAR) NOT NULL,

    I can't find any possibility to change the semantics when generating. Anyone know of any option that I can set so that the migration wizard will generate all of the columns in the form of BYTES?

    Thank you very much

    Hello

    If you email me, I can provide an extension changed to use unity BYTE CHAR and VARCHAR2 columns.

    My email address is my [email protected]

    Kind regards

    Dermot ONeill

    SQL development team

  • Master-detail-shape; Hide/show columns in the form of details according to the column

    Hello

    I have a form master detail. In the long form, I have the columns:
    ID, MASTER_ID_FK, PC_SOURCE, A_C1, A_C2, A_C3, B_C1, B_C2, B_C3

    The PC_SOURCE of the column must be a LOV with values
    NULL VALUE
    A
    B

    So if I choose or enter a master record the detailed form appears and I can enter one or more detail records.

    PC_SOURCE is the first column.
    If I choose one, the columns B_C1, B_C2, B_C3 should disappear as there should be no possible entry.
    If I have B, A_C1, A_C3, A_C2 columsn should disappear as there should be no possible entry.

    Is this possible?

    I tried a bit of my own, but without success. I tried to put in the first column (lov SOURCE PC) in the attributes of the element a javascript call like onChange = "do_Refresh('#PC_SOURCE#'); »

    The javascript funktion do_Refresh tries to grab the value of the column and the value of a hidden item P1_SOURCE as document.getElementById('P1_SOURCE').value = v_source;

    But this does not work, because there is not the value of the recovered column.
    And probably can´t work because of more lines of a detail.

    Thank you and best regards,
    Matthias

    Hello

    The html code of your detailed form will be an array of the elements of entry with names f01, f02, etc.. The columns of the key of the fields are normally hidden, so your PC_SOURCE column will probably use the name f03. A_C1 column name will be f04 etc.

    Once you have the input names for your columns, you can create a dynamic action (DA) to hide the items you want.

    You want the DA to fire when any element PC_SOURCE is changed if you want when to be:
    Event: change
    Selection type: jQuery Selector
    jQuery Selector: input [name = "f03"]
    Condition: no strings attached

    The action is to hide an element in the same line, if the changed item is a value. The action must therefore:
    Action: Run the JavaScript Code
    Fires when the event is: true
    Code: if(this.triggeringElement.value=="A") {$x_Hide ('f04_' + this.triggeringElement.id.split ('_') [1])}

    You then need a lot of real actions for each item that you want to hide.

    Rod West

  • SQL help - Need help to rotate the columns to rows

    I have a HughesNet to divide the columns into multiple lines. For example:

    EMP_DEPT

    ROWID empid1 ename1 empid2 ename2 empid2 ename2 empid4 ename4 dept4 dep3 dep2 dept1
    100001 1 'SCOTT' 10 2 'DAVE' 20 3 10 4 20 SMITH "MILLER"
    100002 1 'SCOTT' 10 2 'DAVE' 20 3 'MILLER' 20

    Note: EMP_DEPT do not always have information about the 4 employees settled for example in info only 3 employees rank 2 are there

    I need to convert and insert it into the EMPLOYEE table as follows:

    EMPLOYEE

    EmpID ename dept
    1 SCOTT 10
    2 20 DAVE
    3 MILLER 10
    4 SMITH 20

    1 SCOTT 10
    2 20 DAVE
    3 MILLER 20

    Thank you
    KeV

    Hey Kevin,

    Here's one way:

    WITH t AS (
      SELECT level i FROM dual CONNECT BY level <= 4
    )
    SELECT enty_type, enty_name, enty_id
    FROM (
      SELECT case when mod(t.i,2) = 0 then 'DEPARTMENT'
                  else 'EMPLOYEE'
             end as enty_type
           , case t.i
               when 1 then emp_name1
               when 2 then dept_name1
               when 3 then emp_name2
               when 4 then dept_name2
             end as enty_name
           , case t.i
               when 1 then emp_id1
               when 2 then dept_id1
               when 3 then emp_id2
               when 4 then dept_id2
             end as enty_id
      FROM emp
           CROSS JOIN t
    )
    WHERE enty_id IS NOT NULL
    ;
    

    Another using the MODEL clause:

    SELECT *
    FROM (
      SELECT enty_id, enty_name, enty_type
      FROM emp
      MODEL
      RETURN UPDATED ROWS
      PARTITION BY (pk)
      DIMENSION BY (0 i)
      MEASURES(
         emp_id1, emp_name1
       , emp_id2, emp_name2
       , dept_id1, dept_name1
       , dept_id2, dept_name2
       , cast(null as number(10)) enty_id
       , cast(null as varchar2(200)) enty_name
       , cast(null as varchar2(30)) enty_type
      )
      RULES (
         enty_type[1] = 'EMPLOYEE' , enty_id[1] = emp_id1[0], enty_name[1] = emp_name1[0]
       , enty_type[2] = 'EMPLOYEE' , enty_id[2] = emp_id2[0], enty_name[2] = emp_name2[0]
       , enty_type[3] = 'DEPARTMENT' , enty_id[3] = dept_id1[0], enty_name[3] = dept_name1[0]
       , enty_type[4] = 'DEPARTMENT' , enty_id[4] = dept_id2[0], enty_name[4] = dept_name2[0]
      )
    )
    WHERE enty_id IS NOT NULL
    ;
    

    Published by: odie_63 on 8 Dec. 2010 21:00

  • Display lines of dates in the column

    Hello

    I use 12 c DB.

    Database Oracle 12 c Enterprise Edition Release 12.1.0.1.0 - 64 bit Production

    PL/SQL Release 12.1.0.1.0 - Production

    "CORE 12.1.0.1.0 Production."

    AMT for 64-bit Windows: Version 12.1.0.1.0 - Production

    NLSRTL Version 12.1.0.1.0 - Production

    I wrote under request, I want to display these lines in columns... How can I do?

    Select to_date (1 January 2013 "") + level 1 double dte

    connect by to_date (January 1, 2013 ',' MON-DD-YYYY') + level 1 < = last_day (to_date (January 31, 2013 ',' MON-DD-YYYY ""));

    Thank you.

    As already suggested by


    Select *.

    from (select level lvl, dates "2013-01-01' + level - 1 dte)

    of the double

    connect by level<= last_day(date="" '2013-01-01')="" -="" date="" '2013-01-01'="" +="">

    )

    Pivot (max lvl in (d1, d2, d3, d4, d5, d6, d7, d8, d9, d10, 10 9 8 7 6 5 4 3 2 1 (dte)

    11 as d11, d12, d13, d14, d15, d16, d17, d18, d19, d20, 20 19 18 17 16 15 14 13 12

    21 as d21, d22, d23, d24 24 23, 25 as d25, 26 as d26, d27 27, 28 d28, d29 29, 30 as d30, 22

    31 as d31

    )

    )

    Concerning

    Etbin

  • Using SQL query, create data according to the requirement

    Hello

    Here is my table

    CREATE TABLE Test_Data
      ( Test_Id VARCHAR2(10), Start_Date DATE, end_date DATE
      );
    INSERT
    INTO Test_Data VALUES
      (
        'A1',
        To_Date('10-OCT-2013','DD-MON-YYYY'),
        To_Date('11-OCT-2013','DD-MON-YYYY')
      );
      
    INSERT
    INTO Test_Data VALUES
      (
        'A2',
        to_date('05-APR-2014','DD-MON-YYYY'),
        to_date('05-APR-2014','DD-MON-YYYY')
      );
    commit
    

    Nauru output like:

    ID
    Date Date_Part
    A1OCTOBER 10, 20131
    A1OCTOBER 10, 20132
    A1OCTOBER 10, 20133
    A1OCTOBER 10, 20134
    A1OCTOBER 11, 20131
    A1OCTOBER 11, 20132
    A1OCTOBER 11, 20133
    A1OCTOBER 11, 20134
    A2APRIL 5, 20141
    A2APRIL 5, 20142
    A2APRIL 5, 20143
    A2APRIL 5, 20144

    Help, please.

    Something along these lines perhaps, but I suggest that you create your own collection types.

    Oracle Database 11 g Enterprise Edition Release 11.2.0.3.0 - 64 bit Production

    With partitioning, OLAP, Data Mining and Real Application Testing options

    SQL > WITH test_data AS

    2 (SELECT 'A1' test_id, to_date (October 10, 2013 ',' MON-DD-YYYY "") start_date,)

    3 to_date (11 October 2013 ',' MON-DD-YYYY "") end_date

    4 DOUBLE

    5. ANY TRADE UNION

    6. SELECT 'A2', to_date (5 April 2014 ',' MON-DD-YYYY "").

    7 to_date (5 April 2014 ',' MON-DD-YYYY "")

    8 DOUBLE)

    9. SELECT td.test_id 'ID', da.column_value 'Date', pa.column_value 'Date_Part '.

    10 test_data TD,

    TABLE 11 (CAST (MULTISET

    12 (SELECT td.start_date + LEVEL - 1

    13 DOUBLE

    14 CONNECT BY LEVEL<= td.end_date="" -="" td.start_date="" +="" 1)="">

    da 15 sys.odcidatelist)).

    16 pa TABLE (sys.odcinumberlist (1, 2, 3, 4));

    ID Date Date_Part

    -- --------- ----------

    A1 10 OCTOBER 13 1

    OCTOBER 10, 13 2 A1

    OCTOBER 10, 13 3 A1

    A1 10 OCTOBER 13 4

    OCTOBER 11, 13 1 A1

    OCTOBER 11, 13 2 A1

    OCTOBER 11, 13 3 A1

    OCTOBER 11, 13 4 A1

    A2 5 APRIL 14 1

    APRIL 5, 14 2 A2

    APRIL 5, 14 3 A2

    APRIL 5, 14 4 A2

    12 selected lines.

    SQL >

  • A PDF form text field is adjustable to wrap the text and automatically expand the 'line height' without changing the "column width" (as a .xls document)? I can't use the Auto font resizing.

    Any suggestions?

    A text AcroForm field can be configured to wrap the text, but do not resize

    automatically.

    The game, may 7, 2015 23:16, mikej16900439 [email protected]>

  • I need to force the width of the columns to values that are smaller than the minimum preset (1 058 mm) indesign.

    Jongware provided two ideas to force the table rows and columns in the heights and widths smaller than the Indesign predefined 1.058 mm.

    For lines: app.selection [0] .properties = {autoGrow:false, height: "0.5 mm"};

    And for columns he sugested: app.selection [0] .width = "0.5 mm;

    The problem is that, while the code for lines works perfectly, for the columns return a error "Unit expected, but received 0.5 mm" I'm under Indesign cs6. Someone has ideas to help fixing such script, or maybe a different approach? Thank you!



    HM, other than the use of InDesign CS5.5 or underneath with scripts?
    Or export IDMS, open and edit (by script of course, it is just a plain text file in disguise), place IDMS and replace the table?

    (IDML as an alternative)

    Laughing out loud

    Uwe

  • Db line not retained in the report

    I have one very simple view report.
    It retrieves data from db and displays such what.

    I have a column in db, where the records are stored with character CHR (10) newline.
    When I try to see the same page of the report, the line break is not preserved.

    For example,.

    I have a db as column value:
    DUMMY TEXT LINE 1
    DUMMY TEXT LINE 2

    But in the report page sound displayed as,
    TEXT LINE 1 DUMMY MANNEQUIN
    LINE OF TEXT 2

    printing is controlled by the number of characters in the first line and the width of the column in the report.
    All that may be the case, I want the new line to be preserved in report page.

    Could someone let me know how can I keep?

    Replace line breaks in the column with elements of HTML line break. Change the column in the report query in a function call with an alias:

    replace(db_column, chr(10), '
    ') db_column

    Make sure the column attribute display as for the report column is column of Standard report.

  • SQL Loader - ignore the lines with "rejected - all null columns."

    Hello

    Please see the attached log file. Also joined the table creation script, data file and the bad and throw the files after execution.

    Sqlldr customer in the version of Windows-

    SQL * Loader: release 11.2.0.1.0 - Production

    The CTL file has two clauses INTO TABLE due to the nature of the data. The data presented are a subset of data in the real world file. We are only interested in the lines with the word "Index" in the first column.

    The problem we need to do face is, according to paragraph INTO TABLE appears first in the corresponding CTL lines file to the WHEN CLAUSE it would insert and the rest get discarded.

    1. statement of Create table : create table dummy_load (varchar2 (30) name, number, date of effdate);

    2. data file to simulate this issue contains the lines below 10. Save this as name.dat. The intention is to load all of the rows in a CTL file. The actual file would have additional lines before and after these lines that can be discarded.

    H15T1Y Index | 2. 19/01/2016 |

    H15T2Y Index | 2. 19/01/2016 |

    H15T3Y Index | 2. 19/01/2016 |

    H15T5Y Index | 2. 19/01/2016 |

    H15T7Y Index | 2. 19/01/2016 |

    H15T10Y Index | 2. 19/01/2016 |

    CPDR9AAC Index | 2. 15/01/2016 |

    MOODCAVG Index | 2. 15/01/2016 |

    H15TXXX Index | 2. 15/01/2016 |

    H15TXXX Index | 2. 15/01/2016 |

    3. the CTL file - name.ctl

    DOWNLOAD THE DATA

    ADD

    IN THE TABLE dummy_load

    WHEN (09:13) = "Index".

    TRAILING NULLCOLS

    (

    COMPLETED name BY ' | ',.

    rate TERMINATED BY ' | '.

    COMPLETED effdate BY ' | '. ' TO_DATE (: effdate, "MM/DD/YYYY").

    )

    IN THE TABLE dummy_load

    WHEN (08:12) = "Index".

    TRAILING NULLCOLS

    (

    COMPLETED name BY ' | ',.

    rate TERMINATED BY ' | '.

    COMPLETED effdate BY ' | '. ' TO_DATE (: effdate, "MM/DD/YYYY").

    )

    invoke SQL loader in a file-> beats

    C:\Oracle\product\11.2.0\client\bin\sqlldr USERID = myid/[email protected] CONTROL=C:\temp\t\name.ctl BAD=C:\temp\t\name_bad.dat LOG=C:\temp\t\name_log.dat DISCARD=C:\temp\t\name_disc.dat DATA=C:\temp\t\name.dat

    Once this is run, the following text appears in the log file (excerpt):

    Table DUMMY_LOAD, charged when 09:13 = 0X496e646578 ('Index' character)

    Insert the option in effect for this table: APPEND

    TRAILING NULLCOLS option in effect

    Column Position Len term Encl. Datatype name

    ------------------------------ ---------- ----- ---- ---- ---------------------

    NAME                                FIRST     *   |       CHARACTER

    RATE                                 NEXT     *   |       CHARACTER

    EFFDATE NEXT * |       CHARACTER

    SQL string for the column: ' TO_DATE (: effdate, "MM/DD/YYYY").

    Table DUMMY_LOAD, charged when 08:12 = 0X496e646578 ('Index' character)

    Insert the option in effect for this table: APPEND

    TRAILING NULLCOLS option in effect

    Column Position Len term Encl. Datatype name

    ------------------------------ ---------- ----- ---- ---- ---------------------

    NAME                                 NEXT     *   |       CHARACTER

    RATE                                 NEXT     *   |       CHARACTER

    EFFDATE NEXT * |       CHARACTER

    SQL string for the column: ' TO_DATE (: effdate, "MM/DD/YYYY").

    Record 1: Ignored - all null columns.

    Sheet 2: Cast - all null columns.

    Record 3: Ignored - all null columns.

    Record 4: Ignored - all null columns.

    Sheet 5: Cast - all null columns.

    Sheet 7: Discarded - failed all WHEN clauses.

    Sheet 8: Discarded - failed all WHEN clauses.

    File 9: Discarded - failed all WHEN clauses.

    Case 10: Discarded - failed all WHEN clauses.

    Table DUMMY_LOAD:

    1 row loaded successfully.

    0 rows not loaded due to data errors.

    9 lines not loading because all WHEN clauses were failed.

    0 rows not populated because all fields are null.

    Table DUMMY_LOAD:

    0 rows successfully loaded.

    0 rows not loaded due to data errors.

    5 rows not loading because all WHEN clauses were failed.

    5 rows not populated because all fields are null.


    The bad file is empty. The discard file has the following

    H15T1Y Index | 2. 19/01/2016 |

    H15T2Y Index | 2. 19/01/2016 |

    H15T3Y Index | 2. 19/01/2016 |

    H15T5Y Index | 2. 19/01/2016 |

    H15T7Y Index | 2. 19/01/2016 |

    CPDR9AAC Index | 2. 15/01/2016 |

    MOODCAVG Index | 2. 15/01/2016 |

    H15TXXX Index | 2. 15/01/2016 |

    H15TXXX Index | 2. 15/01/2016 |


    Based on the understanding of the instructions in the CTL file, ideally the first 6 rows will have been inserted into the table. Instead the table comes from the line 6' th.

    NAMERATEEFFDATE
    H15T10Y Index2January 19, 2016



    If the INTO TABLE clauses were put in the CTL file, then the first 5 rows are inserted and the rest are in the discard file. The line 6' th would have a ""rejected - all columns null. "in the log file. "


    Could someone please take a look and advise? My apologies that the files cannot be attached.

    Unless you tell it otherwise, SQL * Loader assumes that each later in the table and what clause after the first back in the position where the previous left off.  If you want to start at the beginning of the line every time, then you need to reset the position using position (1) with the first column, as shown below.  Position on the first using is optional.

    DOWNLOAD THE DATA

    ADD

    IN THE TABLE dummy_load

    WHEN (09:13) = "Index".

    TRAILING NULLCOLS

    (

    name POSITION (1) TERMINATED BY ' | '.

    rate TERMINATED BY ' | '.

    COMPLETED effdate BY ' | '. ' TO_DATE (: effdate, "MM/DD/YYYY").

    )

    IN THE TABLE dummy_load

    WHEN (08:12) = "Index".

    TRAILING NULLCOLS

    (

    name POSITION (1) TERMINATED BY ' | '.

    rate TERMINATED BY ' | '.

    COMPLETED effdate BY ' | '. ' TO_DATE (: effdate, "MM/DD/YYYY").

    )

  • Column data reading according to the number of lines

    Hi guys,.

    I am currently stuck on the problem of recovering the data from my database (MS Access) according to the number of lines, he has at any time (without having to know how many lines there will be during the programming of this part).

    First, I show how my program works. I'm working on an automated food, order and after the customer has chosen his power, system information such as the name of the food, quantity and price of the food will be written to the MS Access database table. (for example table name "Orderingtable" in MS Access) For my case, 1 order of food will occupy 1 line of the database table. In other words, as part of the same, if he orders 3 different foods, 3 rows will be filled in my database table.

    I would then get the part number of 'Quantity' for each order of the database and summarize the amount finally to count the total number of orders in the table of database at any time. This addition of result will be then shown on the Panel before informing the customer how many orders waiting's just prior to his order. In this case, it can get out if he wants to, if the number of orders is too big for its waiting time.

    However, I do not know how many lines my 'Orderingtable' will be 'Orderingtable' because both accumulate lines and data lines until being command to remove. Therefore, I cannot predict how many lines I program the party totals the number of quantity for each line.

    Is it possible that I can get the part of the 'quantity' without having to know the number of rows in the database so that I can count the total number of pending orders just by adding up the value of the quantity for each line?

    I do not wish to "code" my program by limiting the tables of database for us are going to say, only 50 lines at any time.

    Attached below, this is how my database table "Orderingtable" looks at, which will be used to extract the 'Quantity' column so that it can count the total number of orders and be shown/shown on the front panel of my Labview program.

    I hope that you are able to help me!

    Thank you so much in advance.

    See you soon,.

    MUI

    You can also use the SUM function:

    SELECT SUM (Quantity) OF the order WHERE Queue_No = %d

    And no need of an "Order By" clause, if you add just the quantities.

  • How to change the color of line according to the value of the column

    Hi all

    I have an obligation to change the color of the column based on the value. As I have a table of results and the State are success and failure and progresses, if the State values is the success that should appear in green and if the status is failed, that should be red...

    Here is my table ADF Trinidad read only tables.

    Can someone help me with this.

    Thank you

    Hello

    Try this:

    styleClass="#{row.bindings.Status.inputValue=='IN PROGRESS' ? 'INPROGRESS' : row.bindings.Status.inputValue}"
    
  • How to set the value of a column in a table according to another column?

    Hello world!

    I use Apex 4.1.
    My question is how can I set the value of a column in a table according to another column?
    I have a table and when I insert the value in the column content, I want to change this value in the note column with the note, which is generated with pl/sql function (function of string returned if the typed value is in the range).

    I tried to use javascript as
     $('input[name=f02]').live('change', function(){
    if($(this).val()!='1'){
    $('input[name=f03]').val("test")}
    }); 
    for the development of the column note to test if the value typed in the content of the column is not 1, but this code assigns the value to all the lines and I need to set only the specified line.

    Can someone give me a hint in any way to do this if possible?

    Kind regards
    drama9346

    You will need create a process on your page type PLSQL and develop this process "we demand" of the page. In this process, you can run the PLSQL you need. That is to say to retrieve the note value as described in your PC:

    and when I insert the value in the column content, I want to change this value in the note column with the note, which is generated with pl/sql function (function of string returned if the typed value is in the range).

    In this process, you must provide a return value of the call, and you can do this by using htp.p. Example:

    DECLARE
       --putting x01 in a var to simplify
       l_test_var VARCHAR2(200) := apex_application.g_x01;
       l_return VARCHAR2(200);
    BEGIN
       -- a simplistic test
       IF LENGTH(l_test_var) BETWEEN 10 AND 20 THEN
          l_return := 'String is between 10 and 20';
       END IF;
    
       --this will write l_return to the buffer, and the ajax callback will receive this
       htp.p(l_return);
    END;
    

    And the code that I wrote above, which is javascript, would need to go where your current code is that binds to the onchange event. The result should be that, when a change is made to this element, an ajax request is made on the server. When the call is finished, it will be the value returned in the item you want.

  • Update line in the column-based database

    Hello

    I am trying to find a way to update a row that has a SQL database based on two columns. If the command and the match number sensor order number and sales sensor that already exists in the database, I want to update the column of reading of the sensor. If not exists then I want that it creates a new line. How would I go to do this?

    Thank you

    Chris

    You can use the tools of DB Query.vi Execute. Here is an example of a MS Access 2010 database where a column value is updated in all rows satisfying the WHERE conditions.

    Ben64

  • SQL or PL/SQL to display several links of BLOB in the column of the IR

    I have a need in an IR or a standard report to provide a link to view/download several BLOBs. Basically I have a function that, for a given record, will focus on a relational table and get a list of all the associated files and it has a list of output HTML. List the files is great, however, I would like to take a step further and actually have the names of files as a link to view/download the actual file. Reading the API on GET_BLOB_FILE_SRC it doesn't look like it can do what I want, because it requires a valid page for the file element, and I have 0 - x files associated with a row with a given number of lines per page.

    Basically, what I have is...

    Select

    some_pk

    some_data01

    some_data02

    custom_function_get_files (some_pk)

    my table

    order that either;

    It produces something similar to...

    PK Data 1 Data 2 List of files
    1SomethingSomething
    • File01.txt
    • File02.txt
    • File03.txt
    2Datadata
    • Image.PNG
    3xxxxxx(NULL)

    .. and so on.

    Of course, if I did only 1 file I can format the column of type BLOB and APEX type takes care of everything. Any ideas or suggestions?

    I know I could create a list of files as a link to another page, passing the key document and that the 'view' file using this page. Even if it's a little more messy.

    d3bruts1d wrote:

    I have a need in an IR or a standard report to provide a link to view/download several BLOBs. Basically I have a function that, for a given record, will focus on a relational table and get a list of all the associated files and it has a list of output HTML. List the files is great, however, I would like to take a step further and actually have the names of files as a link to view/download the actual file. Reading the API on GET_BLOB_FILE_SRC it doesn't look like it can do what I want, because it requires a valid page for the file element, and I have 0 - x files associated with a row with a given number of lines per page.

    apex_util.get_blob_file_srcis indeed what you are looking for. The parameter item page is simply a shortcut used to get information about the BLOB of metadata associated with items to upload files and ARF process used to load the images. If these elements do not exist because the images are not loaded in this way, simply add the upload queue and ARF process that would be used to do this to a page, the conditions never set on them so that they are not displayed or executed and reference the element in the apex_util.get_blob_file_src call.

    The list of files can be generated in the query using SQL/XML to eliminate the need for a custom function:

    select
        t.some_pk
      , t.some_data01
      , t.some_data02
      , xmlserialize(
            content
            xmlelement(
                "ul"
              , xmlagg(
                    xmlelement(
                        "li"
                      , xmlelement(
                            "a"
                          , xmlattribute(apex_util.get_blob_file_src('P1_FILE', t.some_pk, null, 'attachment') "href")
                          , f.some_filename))
                    order by f.some_filename))) file_list
    from
        my_table t
          left outer join my_files f
            on t.some_pk = f.some_fk
    group by
        t.some_pk
      , t.some_data01
      , t.some_data02
    

Maybe you are looking for