Display of the results of the query with the column names unknown

I use this code to grab the headers of columns in a select * statement. (I never know what table is queried out of 12 000 or more.) I want to make a loop on the column headers, then the query results in a web page table.

< cfoutput >
< cfset colHeaderNames = ArrayToList (recordset1.getColumnList ()) / >
#colHeaderNames #.
< / cfoutput >

Is there a similar method or suggestions for the release of the results of the query - now that I know the column headings?

If I understand correctly, you can do something like the code below.

Tags: ColdFusion

Similar Questions

  • Anyway, to remove the column names in the result of the query of SQLPLUS

    Hello

    I am using sqlplus to run a script that returns results with the column names.

    Anyway is to omit the names of columns in the result of the sqlplus query?

    I would like to have only results with their column names in the output.

    Thanks in advance!

    Hello

    Maybe your LINES (IZE) is not defined?

    SCOTT>set lines 130
    SCOTT>select status, machine, module
      2    from v$session
      3   where upper(username) = 'SCOTT';
    
    STATUS   MACHINE                                                          MODULE
    -------- ---------------------------------------------------------------- ------------------------------------------------
    INACTIVE PFAE3\VPC4894-03                                                 TOAD 9.7.2.5
    ACTIVE   PFAE3\VPC4894-03                                                 SQL*Plus
    
    2 rows selected.
    
    SCOTT>
    

    As an alternative to the linesize parameter, you can format the columns:

    SCOTT>set lines 80
    SCOTT>col status for a8
    SCOTT>col machine for a30
    SCOTT>col module for a30
    SCOTT>select status, machine, module
      2    from v$session
      3   where upper(username) = 'SCOTT';
    
    STATUS   MACHINE                        MODULE
    -------- ------------------------------ ------------------------------
    INACTIVE PFAE3\VPC4894-03               TOAD 9.7.2.5
    ACTIVE   PFAE3\VPC4894-03               SQL*Plus
    
    2 rows selected.
    
    SCOTT>
    

    Concerning
    Peter

  • Display the name of the tag as the column name and the value in the tag as a row of data from the input string.

    Hi Forum members,

    I am looking for a query display the name of the tag as the column name and the value in the tag as a row of data.

    I have to print the values within the tag to a file by choosing the value of the flags. the sequence of the tags will vary each time, as the tag name will change dynamically.

    So here is the example of input data and the expected output. The string in the text column must be separated as the column names and values.

    Input data
    Select 1 as seqno,' < > 0210A 50 4f < / 4f > < 5f20 > TEST CARD 16 < / 5f20 > < 5f2a > < / 5f2a > < 82 > 1 c 00 < / 82 > ' double text


    Output:

    Seqno 4f 5f20 5f2a 82
    0210A 50 16 1 00 TEST CARD 1

    Please help me by providing your entries on this.

    We use the version of Oracle 11.2.

    Note: This is not the XML string

    Thank you

    Shree

    with

    data in the form of

    (select 1 as seqno,'<4f>0210 A 50<5f20>TEST CARD 16<5F2a><82>00 1' text of all the double union)

    Select 2 as seqno,'XYZ<4F>0210 A 50<5f20>TEST CARD 16<5f2a><82>00 1' text of all the double union

    Select 3 as seqno,'<4f>0210 A 50<5f20>TEST CARD 16<5F2A><82>1 00XYZ ' text of all the double union

    Select option 4 as seqno,'<4F>0210 A 50<5F20>TEST CARD 16<5f2A><82>1 00XYZ' double text

    )

    Select d.seqno, x.*

    d the data,

    XMLTable ('/ root')

    by the way xmltransform (xmltype ('': replace (replace (text,'<><>'),)))

    XmlType (q'~http://www.w3.org/1999/XSL/Transform "version ="1.0"> ")

                                                     

                                                       

                                                         

                                                       

                                                     

                                                     

                                                       

                                                         

                                                       

                                                     

    ~'

    )

    )

    path of columns '4f' varchar2 (10) "tag4f."

    path of "5f20' varchar2 (30)"tag5f20. "

    path of '5f2a' varchar2 (10) "tag5f2a."

    path of varchar2 (10) "82" "tag82.

    ) x


    SEQNO 4f 5f20 5f2a 82
    1 0210A 50 16 TEST CARD - 1 00
    2 0210A 50 16 TEST CARD - 1 00
    3 0210A 50 16 TEST CARD - 1 00
    4 0210A 50 16 TEST CARD - 1 00

    with

    data in the form of

    (select 1 as seqno,'<4f>0210 A 50<5f20>TEST CARD 16<5F2a><82>00 1' text of all the double union)

    Select 2 as seqno,'XYZ<4F>0210 A 50<5f20>TEST CARD 16<5f2a><82>00 1' text of all the double union

    Select 3 as seqno,'<4f>0210 A 50<5f20>TEST CARD 16<5F2A><82>1 00XYZ ' text of all the double union

    Select option 4 as seqno,'<4F>0210 A 50<5F20>TEST CARD 16<5f2A><82>1 00XYZ' double text

    ),

    Chopper (seqno, Key, value, String) as

    (select seqno,

    regexp_substr (text,'<(.+?)>', 1, 1, null, 1),

    regexp_substr (Text,'>(.*?))

    regexp_substr (text,'<.+?>. *? ) (.*) $', 1, 1, null, 1). » <>'

    from the data

    Union of all the

    Select seqno,

    regexp_substr (String,'<(.+?)>', 1, 1, null, 1),

    regexp_substr (String,'>(.*?))

    regexp_substr (String,'<.+?>. *? ) (.*) $', 1, 1, null, 1)

    Chopper

    where regexp_substr (string,'<(.*?)>', 1, 1, null, 1) is not null

    )

    Select '4f', seqno, '5f2a', '82', '5f20.

    of (seqno, lower (key) select key, value)

    Chopper

    )

    Pivot (max (value) for key in ('4f' as '4f', '5f20' as '5f20', '5f2a' as '5f2a', "82" as "82"))

    Concerning

    Etbin

  • Necessary emergency with a request: fill date of prior art on the column name

    Hello

    Can you please help me with the query. I would be grateful for your time and your help.

    I have the query and the following output. Basically, the query selects a date, a table and counties received documents based on the current date, day-1, - 2 days-, 3 days-4 days-5 days and especially 5 days. It's the query I wrote. Now the requirement has slightly changed and described below.

    Current query:

    SELECT SUM (CASE WHEN TRUNC (SYSDATE) TRUNC ( )File_Date() = 0 PUIS 1 AUTRE 0 FIN) Zéro ,

    SUM (CASE WHEN TRUNC (SYSDATE) TRUNC ( )File_Date() = 1 PUIS 1 AUTRE 0 FIN)   One ,

    SUM (CASE WHEN TRUNC (SYSDATE) TRUNC ( )File_Date() = 2 PUIS 1 AUTRE 0 FIN) Two ,

    SUM (CASE WHEN TRUNC (SYSDATE) TRUNC ( )File_Date() = 3 ALORS 1 SINON 0 FIN) Trois ,

    SUM (CASE WHEN TRUNC (SYSDATE) TRUNC ( )File_Date() = 4 PUIS 1 AUTRE 0 FIN) Quatre ,

    SUM (BOX WHEN TRUNC (SYSDATE) TRUNC (File_Date) = 5 THEN 1 ELSE 0 END) Five ,

    SUM (CASE WHEN TRUNC (SYSDATE) TRUNC ( )File_Date() > 5 PUIS 1 AUTRE 0 FIN) OverFive ,

    COUNTY (*) Total

    DE DOCUMENT_TABLE

    OUTPUT:

    Zero

    One

    Two

    Three

    Four

    Five

    More than five

    Total

    3

    6

    3

    6

    10

    50

    100

    178

    Now the desired output:

    The column name must be the date, for example the column name, we're Sysdate, two column name is Sysdate-1 day and the result would look like:

    OUTPUT:

    17/12/2014

    16/12/2014

    15/12/2014

    14/12/2014

    13/12/2014

    12/12/2014

    More than five

    Total

    3

    6

    3

    6

    10

    50

    100

    178

    Hi, just try below as you say it's urgent

    Select sysdate, sysdate-1, sysdate-2, sysdate-3,-4, etc of daul sysdate

    Union

    your query

    (you must ensure for the same type of data)

    are you using oracle report or just in the sql query. If the reports, then you can manage very easily with the introduction of a formula column.

  • Can I use * and the list of the column names in a select query

    PLSQL again.  Can I use * and the list of the column names in a select query, i.e. Select *, col1, col2 from Mytable.  When I do that my questions tend to the bomb.  Can do in other databases.

    Thank you

    Mike

    Hi, Mike,.

    If there is something else in the more SELECT clause *, then * must be qualified with a table name or alias.

    For example:

    SELECT Mytable. *, col1, col2

    FROM MyTable;

  • Display the column name of the column more recently updated

    I wonder if it is possible to display the name of the column in the column most recently updated in a table.

    Example:

    Emp table

    Name

    Height

    Weight

    Age

    Update_Date

    Update_Column

    Original record (03/20/14)

    Name size weight Age Update_date Update_Column

    John                                                 03/20/14          Name

    Then someone comes and update the height on 22/03/14:

    Name size weight Age Update_date Update_Column

    John 5'9 03/22/14 height

    And the Update_date and the Update_column would change again if someone came and put a value for the age. And so on.

    Is this possible?

    Also, if the above is possible, would it be possible to display the name of extreme right column if a user updated several columns at the same time?

    Example:

    User updates the sub-folder:

    Name size weight Age Update_date Update_Column

    John 5'9 03/22/14 height

    And adds weight and age at the same time on 24-03-14:

    Name size weight Age Update_date Update_Column

    John 5'9 150 31 03/24 / 14

    The Update_Column would display age because it is the furthest to the right. (Think by reading from left to right, the column that has been updated if the extreme right)

    So to sum things, I need to be able to display Updated_date (which will be the date of the day when the record is the last updated) and Updated_Col (which is the column name of the column was last updated, and if multiple columns are updated then display that value has been updated last in)

    I hope that the examples help to clarify things.

    Thank you

    Steven

    I think I found a solution.

    delimiter //
    create table a (
      id int (10) unsigned auto_increment,
      a int(10),
      b int(10),
      update_date datetime NULL,
      update_column varchar(16) NULL,
      primary key (id)
    )//

    create trigger bu_a before update on a for each row begin
      set NEW.update_date = NOW();
      set NEW.update_column = NULL;
      -- you need to start with the rightmost column if you want
      -- that matched with the highest priority
      if OLD.b != NEW.b then
       set NEW.update_column = "b";
      elseif OLD.a != NEW.a then
       set NEW.update_column = "a";
      end if;
    end //

    TEST

    insert into a (id,a,b) values (1,1,1), (2,1,1), (3,1,1), (4,1,1)[
    update a set b = 2 where id = 2;
    update a set a = 2 where id = 3;
    update a set a = 2 where id = 4;
    update a set b = 2 where id = 4;
    select * from a;

    DISPLAY

    ID  A   B   UPDATE_DATE                    UPDATE_COLUMN
    1   1   1   (null)                          (null)
    2   1   2   March, 24 2014 23:22:33+0000      b
    3   2   1   March, 24 2014 23:22:33+0000      a
    4   2   2   March, 24 2014 23:22:33+0000      b

  • How to export data to excel that has 2 tables with the same number of columns and the column names?

    Hi everyone, yet once landed upward with a problem.

    After trying many things to myself, finally decided to post here...

    I created a form in form builder 6i in which clicking on a button, the data gets exported to the excel sheet.

    It works very well with a single table. The problem now is that I cannot do the same with 2 tables.

    Because the tables have the same number of columns and the columns names.

    Here are the 2 tables with column names:

    Table-1 (MONTHLY_PART_1) Table-2 (MONTHLY_PART_2)
    SL_NOSL_NO
    MODELMODEL
    END_DATEEND_DATE
    U-1U-1
    U-2U-2
    U-4U-4
    ..................
    ..................
    U-20U-20
    U-25U-25

    Given that the tables have the same column names, I get the following error :

    402 error at line 103, column 4

    required aliases in the SELECT list of the slider to avoid duplicate column names.

    So how to export data to excel that has 2 tables with the same number of columns and the column names?

    Should I paste the code? Should I publish this query in 'SQL and PL/SQL ' Forum?

    Help me with this please.

    Thank you.

    Wait a second... is this a kind of House of partitioning? Shouldn't it is a union of two tables instead a join?

    see you soon

  • We display only the columns required dynamically?

    Hi all

    I have a scenario where I have 30 columns in the rtf model. All columns will never be displayed, only a privileged few will be available for display. The output file is so see the empty columns. Now, I want to display only the columns that contain data.

    FYI - can't know what columns are made up of data until we run the report.

    Any advice.


    Thanks in advance.

    Malenfant.

    Hello

    You can use the following text:

    Column heading:
    My label

    The data in the column:
    My data

    The @column will tell XMLP wheater or not that column should be indicated.

    I hope this helps you.

    Kenneth BR

  • Select the column name when the value = something

    Is there a way to select the column name when there is a specific value in it?

    As follows:

    create table (abc123)

    COLUMN1 VARCHAR2 (50).

    COLUMN2 VARCHAR2 (50).

    Column3 varchar2 (50)

    );

    insert into abc123 values ('yes', 'Yes', 'No');

    insert into abc123 values ('no', 'Yes', 'No');

    INSERT INTO ABC123 VALUES ('no ',' no', 'No');

    insert into abc123 values ('yes', 'Yes', 'Yes');

    SELECT CASE WHEN COLUMN1 = 'Yes' THEN - the name of the column would be here somehow?

    WHEN COLUMN2 = 'Yes' THEN - the name of the column would be here somehow?

    WHERE Column3 = 'Yes' THEN - the name of the column would be here somehow?

    Another null

    finish as abc123 columnname

    final results for the just Column1 would be:

    COLUMN1

    NULL VALUE

    NULL VALUE

    COLUMN1

    I'm not sure what I use to get the name of column in there

    Thank you.

    Hello

    708631 wrote:

    Is there a way to select the column name when there is a specific value in it?

    As follows:

    create table (abc123)

    COLUMN1 VARCHAR2 (50).

    COLUMN2 VARCHAR2 (50).

    Column3 varchar2 (50)

    );

    insert into abc123 values ('yes', 'Yes', 'No');

    insert into abc123 values ('no', 'Yes', 'No');

    INSERT INTO ABC123 VALUES ('no ',' no', 'No');

    insert into abc123 values ('yes', 'Yes', 'Yes');

    SELECT CASE WHEN COLUMN1 = 'Yes' THEN - the name of the column would be here somehow?

    WHEN COLUMN2 = 'Yes' THEN - the name of the column would be here somehow?

    WHERE Column3 = 'Yes' THEN - the name of the column would be here somehow?

    Another null

    finish as abc123 columnname

    final results for the just Column1 would be:

    COLUMN1

    NULL VALUE

    NULL VALUE

    COLUMN1

    I'm not sure what I use to get the name of column in there

    Thank you.

    Thanks for posting the CREATE TABLE and INSERT for the sample data.

    Don't forget to post the exact results you want from these sample data.  If the results depend on the parameters you want to pass a run time, then give a few different examples, with the the desired results of each.

    You can hardcode the values you want, such as the column names in a query.  For example:

    SELECT CASE WHEN column1 = 'Yes' THEN 'Column1' END like y1

    CASE WHEN column2 = 'Yes' THEN 'Column2' END like y2

    CASE WHEN Column3 = 'Yes' THEN 'Column2' END like y3

    , a. *-If wanted

    Of abc123 one

    ;

  • use a (selection list) element as the column name in the select?

    I have a popup LOV key based on a select (dynamic list of values)
    I want to display and return - select columns in the select statement to be determined by another list.

    I tried:

    Select distinct: P133_COLUMN d: P133_COLUMN r
    FROM MyTable

    but then I don't you the value of: P133_COLUMN... so if: P133_COLUMN is 'EMPNO' LOV popup displays the text "EMPNO" and referred the text 'EMPNO', not the empno column values...

    If I change

    Select distinct P133_COLUMN d & P133_COLUMN r
    FROM MyTable

    I get the standard
    "LOV query is not valid, a display and a return value is needed, the column names must be different. If your query contains a query online, the first CLAUSE in the SQL statement must not belong to the query online. »

    Anyone?

    Also, I was wondering if it is possible to set the textfield object in the item popup LOV to accept the input text directly as well as the selected value, but the first part of the question is the important part.

    Concerning

    Andreas

    Hello Andy,

    Change your LOV to something like this:
    'select' return. : P133_COLUMN |' d, ' | : P133_COLUMN | "as r from myTable";

    Greetings,
    Roel

    http://roelhartman.blogspot.com/

  • Rename the column name of the view

    Suppose I have an employee of the table with the column name. Now, I want to make a view of the employee to the table with the name of the First_name and Last_name column. Is this possible?

    You can also use aliases in the view definition:

    CREATE VIEW employee_view (
      first_name,
      last_name
    ) AS
      SELECT first,
             last
      FROM   employee;
    

    However, you can rename a column in a view. You would have to DROP and CREATE or to CREATE or REPLACE.

    Concerning
    Peter

  • How to move the column label to the right of the column name in the project Panel

    How does a gesture the column label in the project panel to the left of the name to the right of the column name column... machines windows can do this while the macbook pro (3 of 3) this is impossible...

    I still want the opportunity to bring him here where he was.

  • Display the result of a query in 3 columns

    Hello

    I have a query with n records. Now, I want to display all the records in a HTML page into 3 columns. I don't have any idea on how to do it!

    What I would like is (assuming I have 9 entries in my query):

    < div id = "column1" >
    viewing records 1 to 3
    < / div >

    < div id = "column2" >
    view records of 4-6
    < / div >

    < div id = "Column3" >
    view records 7-9
    < / div >

    Someone has a short solution or at least a link to a sloution. I can't find anything big yet...

    Thanks and greetings

    Hello

    I found a solution that works very well - unfortunately I don't really understand it :-)

    Thank you for your contributions!

  • First group title below displays under the column headers using the model 23 classic report with the help of repeat titles on break

    Hello

    I am migrating an application from 3 APEX APEX 4.2 on a thing I noticed with the classic reports when I put them in the model 23, it's that the first section break has break notch under the headings of columns for this section of line while the remaining lines properly have it display above the headers on the subsequent sections of group.


    When I look at firebug code I saw that all the tables but the first, the break line is included in the last line of the previous table, so I can see how it did not work for the holidays since.

    I have tow questions.

    1. is it really intentional because it seems not terribly elegant and my users to zero immediately above as a perceived bug.

    2. is there a reasonable job around always use headers repeat on break? I have multiple reports on the same page in places so switch to interactive reports is not a quick fix for me in this case.

    Example of a question can be seen at apex.oracle.com at home

    Thank you

    Brad

    Roadling wrote:

    Hello

    I am migrating an application from 3 APEX APEX 4.2 on a thing I noticed with the classic reports when I put them in the model 23, it's that the first section break has break notch under the headings of columns for this section of line while the remaining lines properly have it display above the headers on the subsequent sections of group.

    1. is it really intentional because it seems not terribly elegant and my users to zero immediately above as a perceived bug.

    The Standard report template definition in issue 23 contains thead and tbody elements:

    Before the column header

    
    

    Column title template

    #COLUMN_HEADER#
    

    After the title column

    
    
    

    After the lines

    
    
    
    
    
    
    #PAGINATION#
    
    
    
    

    This is intentional, the best practice for marking up HTML tables. What is not expected is the problem that arises when this model is used with the break of repeat titles on break formatting option. The repeated headings result table consisting of soup of tags containing several poorly constructed tbody and thead, which is not valid elements.

    2. is there a reasonable job around always use headers repeat on break? I have multiple reports on the same page in places so switch to interactive reports is not a quick fix for me in this case.

    Create a copy of the report model Standard in Standard (break formatting) for use with reports of the break, remove the thead and tbody definitions of template tags and the breakdown of the reports to use the new model of change. (Or, if you use mainly break reports using the Standard template, keep the tags in the copy and remove them from the original in order to minimize the number of reports, you need to change.)

    Personally, I would create a report model of line custom to break complex reports in order to be able to have complete control over the structure and presentation.

  • Get the column names with cursor or an alternative

    Hi guys,.

    What I currently have is an email with an attachment from PL/SQL. I need to display the query results in .txt attachment. What I've done now is to use a slider but it shows only the results I want column names & ideally the message "14 rows returned. How could I put this in a VARCHAR2?

    Mike

    Add a value to each sub selection order by...

    for example

    SQL> set heading off
    SQL> ed
    Wrote file afiedt.buf
    
      1  select colA, colB, colC
      2  from (
      3        select 1 as ord, cast('TABLE_NAME' as char(30)) colA,cast('GRANTEE' as char(30)) colB,cast('PRIVILEGE' as char(30)) colC from dual
      4        union all
      5        SELECT 2, rpad('-',30, '--') colA, rpad('-',30, '--') colB, rpad('-',30, '--') colC from dual
      6        union all
      7        select 3, cast(table_name as char(30)) colA,cast(grantee as char(30)) colB,cast(privilege as char(30)) colC from user_tab_privs where table_name like 'EMP'
      8       )
      9* order by ord, colA
    SQL> /
    
    TABLE_NAME                     GRANTEE                        PRIVILEGE
    ------------------------------ ------------------------------ ------------------------------
    EMP                            SCOTT                          SELECT
    
    SQL>
    

Maybe you are looking for