the selection of all colomns_names of a table, with their data types...

HI :)

I would like to know, how to select in SQL for all the names of columns in a table with their data types so that I get something like this:

Table 1: table_name

the ID of the column has the NUMBER data type
the name of the column has Datatype Varchar2
*....*

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

Table 2: table_name

the check in the column has the NUMBER data type
the air of the column has Datatype Varchar2
*....*


and it must be for all the tables that I own!...

P. S: I'm trying to do this with java, so it s would be enough if you just tell me how to select all tables_names with all their colums_names and all their data types!...

Thanks :)



I've heard this can be done with USER_TABLES... but I have no idea how: (...)

Edited by: user8865125 the 17.05.2011 12:22

Hello

USER_TAB_COLUMNS data dictionary view has a row for each column of each table in your schema. The columns TABLE_NAME, COLUMN_NAME and DATA_TYPE contains all the information you need.
Another view of data, USER_TABLES dictionary, can be useful, too. He has a line of table pre.

Tags: Database

Similar Questions

  • Windows cannot be installed to this disk. The selected disk is a MBR patition table.

    I recently bought a desktop computer with Windows 7 Home Premium x 64 preinstalled (OEM). I tried to install Windows 7 Ultimate x 64 on this computer, but I received the following error message:

    Windows cannot be installed to this disk. The selected disk is a MBR partition table. On EFI systems, Windows cannot be installed to GPT disks.

    The 1 TB of HARD drive on this computer has three partitions:

    NTFS SYSTEM 100 - healthy (System, the Active Primary Partition)

    OPERATING SYSTEM (C :)) 9148.04 GB NTFS - healthy (start, page file, crash dump, primary Partition))

    HP_RECOVERY (D :)) 13.37 GB NTFS - healthy (Primary Partition))

    Please advice. Thanks in advance.

    I'm trying to install a new copy of Windows.

    Disconnect your 2nd monitor temporarily, then go to your computer manufacturer's support web site and search for Windows 7 drivers for your specific model number.

    If there are Windows 7 drivers, then to download to a folder on your hard drive and install all of them, starting with the card drivers mother/chipset, SATA, LAN, Audio, USB, graphics, Webcam, Etc., and so on.

    List of computer manufacturer support sites:
    http://Windows.Microsoft.com/en-us/Windows/help/contact-support/computer-manufacturers

    If you have an Intel motherboard, you can try the Intel driver update utility: http://www.intel.com/support/detect.htm?iid=dc_iduu

    Tips for solving common driver problems
    http://Windows.Microsoft.com/en-us/Windows7/tips-for-fixing-common-driver-problems
    Vista: http://windows.microsoft.com/en-US/windows-vista/Tips-for-fixing-common-driver-problems

    Graphics/video drivers:
    Check the download site of the manufacture of the graphics card for the latest Windows 7 drivers for your card.
    ATI: http://support.amd.com/us/gpudownload/Pages/index.aspx
    NVIDIA: http://www.nvidia.com/Download/index5.aspx?lang=en-us

    J W Stuart: http://www.pagestart.com

  • Windows cannot be installed to this disk. the selected disk is a MBR partition table. The EFI system, Windows cannot be installed on GPT disks

    Server 8 installation error "Windows cannot be installed to this disk. the selected disk is a MBR partition table. The EFI system, Windows cannot be installed to GPT disks.

    How do I resolve this problem and install windows 8 as usual? I have several partitions with data... I don't want to delete all partitions and create partitions from scratch and install the os...

    How to get there?

    Windows cannot be installed to this disk. the selected disk is a MBR partition table. The EFI system, Windows cannot be installed to GPT disks.

    This could happen not only windows 8, but also windows 7, windows Server 2008, or 8 server 2008 R2... Troubleshooting steps will be similar for all windows to get this problem...

    I had this problem when installing server 2008 r2 on a dell... T110 server without remove the other partitions or lose all the data on the other drivers, you can solve this problem...

    simply, I have followed these steps using gparted and solved my problem... These measures will be useful for anyone with similar problem... . All the steps that I've documented here... All the steps I've documented here...

    https://www.pcandtablet.com/Windows-8-errors-and-crashes/846/Windows-cannot-be-installed-to-this-disk-the-selected-disk-has-an-MBR-partition-tabl.html

  • How to select all text in a table with a single click cell?

    How to select all text in a table with a single click cell? I use TextField.selectAll () when you implement a table cell factory. But when I select a line with a single click, then a click on a table cell again: see the result image

    The text in the table cell is not all selected. What I simply selects all the text in a table cell when there is a click on it. How to realize that? Thank you

    Thanks for help ~.

  • Select/deselect all rows in a table

    Hi Experts,

    11.1.2 JDEV


    I have a form in which a richeTableau with only two Columns.Also a radio button group with two point (select all / deselect all).

    My use is,

    When I select the option button, if it is SELECT ALL, all lines must be selected
    If it's ALL DESELECT, all lines are deselection

    Current follwing method is used for all the ranks of selection,

    {} public void selectAllRowsInTable (rt richeTableau)
    RKS RowKeySet = new RowKeySetImpl();
    Model CollectionModel = (CollectionModel) rt.getValue ();
    ROWCOUNT int = model.getRowCount ();

    for (int i = 0; i < rowcount; i ++) {}
    model.setRowIndex (i);
    Key of the object = model.getRowKey ();
    RKS. Add (Key);
    }

    rt.setSelectedRowKeys (rks);
    }

    is there a simple alternative way to select/deselect all rows in a Table?

    Thankz in advance

    PMS

    Hello

    If you do not want to do in the view layer, this is the way to go. However, if you use BC as a model, you can have a transition attribute in the original Version (with the Boolean type) and set its value to true / false based on the checkbox.

    Arun-

  • Enter the selected line only an editable af:table ADF

    Hello

    We have an obligation to engage only the selected lines in a table. All lines in the table must be modifiable. There should be a 'Save' button in a column that has to save the selected line when you click it.

    Could you please share your comments/suggestions.

    Environment:

    JDeveloper and ADF 11.1.1.7

    Thank you

    Srikanth

    Maybe you can add the attribute transitional to EO as an indicator whether the line should be validated in db or not, override EOImpl.doDML () and skip super.doDML () If this attribute is not set.

    Dario

  • How to create a dynamic RTF report that creates dynamic columns based on the selection of dynamic columns in a table?

    Hi all

    Suppose I have table, whose structure changes frequently on a daily basis.

    For example. / / desc my_table gives you after the name of the column the day 1

    SQL > my_table DESC;

    Output

    Name

    Age

    Phone


    Day 2, two other columns are added, viz, address and salary.

    SQL > my_table DESC;

    Output

    Name

    Age

    Phone

    Address

    Salary


    Now, I want to create a Dynnamic RTF report which made extracting data from all columns from my_table daily. For this, I have defined a simultaneous program with XML output type and include in annex a data/definition of data model that takes XML as input and gives the final result of the conc program in EXCEL layout. I am able to do that for a constant number of columns, but don't know how to do it when the number of columns to display dynamically changes.

    For 1 day my XML file should be like this.

    <?xml version="1.0" encoding="UTF-8"?>
    <dataTemplate name="XYZ" description="iExpenses Report" Version="1.0">
    <dataQuery>
    <sqlStatement name="Q2">
    <![CDATA[
    SELECT Name
    ,Age
    ,Phone
    FROM my_table
    ]]>
    </sqlStatement>
    </dataQuery>
    <dataStructure>
    <group name="G_my_table" source="Q2">
      <element name="Name" value="Name" />
      <element name="Age" value="Age" />
      <element name="Phone" value="Phone" />
    </group>
    </dataStructure>
    </dataTemplate>
    
    

    And my day 1, EXCEL output RTF model should be like this.
    Name age phone

    Swapnill 23 12345

    For 2 days my XML file should be like this. With 2 new columns selected in the SELECT clause.

    <?xml version="1.0" encoding="UTF-8"?>
    <dataTemplate name="XYZ" description="iExpenses Report" Version="1.0">
    <dataQuery>
    <sqlStatement name="Q2">
    <![CDATA[
    SELECT Name
    ,Age
    ,Phone
    ,Address
    ,Salary
    FROM my_table
    ]]>
    </sqlStatement>
    </dataQuery>
    <dataStructure>
    <group name="G_my_table" source="Q2">
      <element name="Name" value="Name" />
      <element name="Age" value="Age" />
      <element name="Phone" value="Phone" />
      <element name="Address" value="Address" />
      <element name="Salary" value="Salary" />
    </group>
    </dataStructure>
    </dataTemplate>
    
    

    And my day 2, exit EXCEL model RTF should be like this.
    Name address telephone pay

    23 12345 Madrid 100000 Swapnill

    Now, I don't know below things.

    • Make the dynamic XML as we did in the day 1 there are 3 columns in the SELECT statement and the day 2, 5 columns. I want to create a dynamic XML which must not be changed if the new columns are added into my_table. I don't know how to create this query and also create their corresponding items below.
    • Make the RTF model dyanamic as day 1 there are 3 exit EXCEL columns and the day 2, 5 columns. I want to create a dynamic RTF model that would display all the columns selected in XML dynamic. I don't know how the RTF will create new XML tags and how it will know where to place them in the report. Means, I can create model RTF day 1, by loading the XML data for 3 columns and place 3 tags XML in the model. But how he will create and place the tags for the new columns the day 2?

    Hope so, you got my requirement, it's difficult. Please let me know how I can implement the necessary solution using the RTF dynamically without any manual intervention.

    Kind regards

    Patricia K.

    Post edited by: SwapnilK

    Hi guys,.

    I was able to solve above the requirement.

    I created a procedure that would create & update (attached to the data definition) XML file dynamically for each race. This dynamic XML contains the SQL statement for the data query that is built dynamically. I am updating this XML file using XDOLoader utility to the definition of data. Then run my program customized to generate the excel output.

    Exit excel retrieves correct number of columns dynamically (3 on Day1 and Day2 5), with corresponding data records.

    Kind regards

    Patricia K.

  • How to select columns, that we need a table with pivot

    Hello

    How can I select only the required columns that I need the table

    My goal is to keep everything in one line

    Database: 11.2.0.2.0

    I have a table called Table Agent

    create the table AGENT_DETAIL

    (

    agent_id NUMBER (20) not null,

    agent_type_code VARCHAR2 (10) not null,

    agent_type_prefix VARCHAR2 (10) not null,

    Type_Code VARCHAR2 (10) not null,

    type_prefix VARCHAR2 (10) not null,

    last_modified DATE not null

    )

    INSERT INTO agent_detail VALUES

    (29709, ARE ',' OFFICE ',' DNSWEB ',' AGTDETAILS', SYSDATE);

    INSERT INTO AGENT_DETAIL VALUES

    (29709, ARE ',' OFFICE ',' DNSNATID ',' AGTDETAILS', SYSDATE);

    INSERT INTO AGENT_DETAIL VALUES

    (29709, ARE ',' OFFICE ',' DELIVERY ',' AGTDETAILS', SYSDATE);

    INSERT INTO AGENT_DETAIL VALUES

    (29709, ARE ', 'OFFICE', "WEBUSAGE", "WEBUSER" SYSDATE);

    When you query it against the table

    SELECT * FROM AGENT_DETAIL;

    AGENT_IDAGENT_TYPE_CODEAGENT_TYPE_PREFIXTYPE_CODETYPE_PREFIXLAST_MODIFIED
    129709REOFFICEDNSWEBAGTDETAILS22:14:15 12/09/2015
    229709REOFFICEDNSNATIDAGTDETAILS09/12/2015-22:15:26
    329709REOFFICEDELIVERYAGTDETAILS09/12/2015-22:21:37
    429709REOFFICEWEBUSAGEWEBUSER10/12/2015-09:27:52

    Because my goal is to put everything in a single line instead of get in 4 rows

    My query is like that

    (select *)

    the Dungeon of pivot (min (TYPE_CODE) AGENT_DETAIL (last dense_rank command by LAST_MODIFIED) for TYPE_CODE in ('DNSWEB' as the WEB)

    'DNSNATID' as

    NATIONAL,

    'DELIVERY' AS

    DELIVERY,

    "WEBUSAGE" AS WEBUSAGE

    )

    ))

    Result:

    AGENT_IDAGENT_TYPE_CODEAGENT_TYPE_PREFIXTYPE_PREFIXWEBNATIONALDELIVERYWEBUSAGE
    129709REOFFICEWEBUSERWEBUSAGE
    229709REOFFICEAGTDETAILSDNSWEBDNSNATIDDELIVERY

    Is it possible to get everything in one record, I know that I have two type_prefixes different (WEBUSER, AGTDETAILS)

    But all I want to see my data is like this

    Agent_id Agent_type_code Agent_type_prefix WEB WEBUSAGE NATIONAL DELIVERY

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

    RE OFFICE DNSWEB DNSATID DELIVERY WEBUSAGE 29709

    Hello

    When you use SELECT... PIVOT, the result set contains 1 row for all the distinct combinations of the values of all columns except columns mentioned in the PIVOT clause.  If you want to ignore some columns completely, then let the PIVOT operated at a "table" that does not include the.  For example:

    with RELEVANT_AGENT_DETAIL as

    (

    Select AGENT_ID, AGENT_TYPE_CODE, AGENT_TYPE_PREFIX, TYPE_CODE, LAST_MODIFIED

    of AGENT_DETAIL

    -where--if you filter, put it here

    )

    Select *.

    of RELEVANT_AGENT_DETAIL

    Pivot (min (TYPE_CODE) Dungeon (last dense_rank command by LAST_MODIFIED))

    for TYPE_CODE in ('DNSWEB' as WEB

    'DNSNATID' as NATIONAL

    'DELIVERY' as DELIVERY

    "WEBUSAGE" as WEBUSAGE

    )

    )

    ;

    If you are lazy or trying to be cute, maybe you can give the columns unwanted some lazy jobs in the PIVOT clause, like this:

    Select *.

    of AGENT_DETAIL

    Pivot (min (TYPE_CODE) Dungeon (dense_rank last order by LAST_MODIFIED)

    TYPE_CODE

    TYPE_PREFIX

    )

    for TYPE_CODE in ('DNSWEB' as WEB

    'DNSNATID' as NATIONAL

    'DELIVERY' as DELIVERY

    "WEBUSAGE" as WEBUSAGE

    )

    )

    ;

    But this makes the code confusing and may be difficult to maintain.

  • Change the length of a Table column (CHAR data type)

    Hi gurus,

    SQL > select * from version $ v

    BANNER

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

    Oracle Database 10g Release 10.2.0.3.0 - 64 bit Production

    PL/SQL version 10.2.0.3.0 - Production

    CORE Production 10.2.0.3.0

    AMT for Linux: release 10.2.0.3.0 - Production

    NLSRTL Version 10.2.0.3.0 - Production

    I need to increase the length of a CHAR of a table data type column (currently it's tank (3) and you want to change to char (4)). Here are more details on the table:-

    • Contains more than 20 million lines.
    • Table contains several indexes.
    • Table is referenced by several tables (about 60 tables) and it refers to several tables (about 3)
    • Table has 4 complex triggers. Triggers call procedures and packages.

    What I've tried so far


    1 disabled all triggers and ran ALTER statement to increase the length. It took hours and did not finish in a reasonable amount of time, even if no error, but it took more than 12 hours.

    2 tried DBMS_REDEFINITION package but it does not work with the standard version of Oracle 10 g.

    I think to try next

    I think same Optics:

    Say my name of the existing table is OLD_T1 where the length of column need to increase

    -Create a copy (with increased column length) table of OLD_T1, Say NEW_T1

    -Move data from in OLD_T1 to the new table NEW_T1

    -Lower OLD_T1 (or rename it to OLD_T1_TMP)

    -Rename NEW_T1 to OLD_T1

    -Create all indexes, triggers, constraints etc..

    I wish to confirm, if my approach is correct? Or someone has a better idea to do this?

    Please note: I know that the CHAR data type gives the problem but it is an old system and I don't have authority to change the design of database.

    Appreciate any comment/suggestion

    Thanks in advance

    > I mean, can any application break if it depends on fixed-length?

    Yes, because the code can be expected completed on the right areas.

  • The Associations of all feature works not just for some file types

    I'm having some problems with the functionality of all Associations, located in the section default programs in Control Panel.  There are a number of types/protocols files that are set up to be opened with the wrong default programs.  When I go to change the program, the browse option doesn't let me choose the program I want.  One of the files I'm having this problem with is the .docx file.  I want to put in place to make the default Microsoft Word program, but he keeps recommending Microsoft Word Viewer and will not let me choose Microsoft Word on my computer.  I know this isn't a major problem and that the files can be opened by Word by using other methods.  It's just annoying, and it bothers me when something does not work on my computer.  A lot of files/protocols are also unknown application listed under the column of default program.  I know that is not normal.  Any of you know what is the cause?

    RE docx default program

    You have MS Office Word. How to uninstall Word Viewer?
    Then, check the Aoosociate file type or Protocol of a program. See if MS Office Word is now the default program to open docx.

    If necessary, use the option open with to set MS Office Word as the default program to open docx.

    1. how to install open with from the context menu
    http://www.SevenForums.com/tutorials/52833-open-context-menu-item-Add-Remove.html

    It applies to both Vista and Win 7.

    2. how to use open with...

    Right-click to .docx... click Open with... click on choose default program... click MS Office Word... down, check the box in front of "always use the selected program to open this type of file"... OK when finished.

  • How update the relational table with XML data?

    I get XML messages that include a bunch of data items to be updated in a table. An arbitrary subset of rows is updated for each message received.

    The output of the following example is correct, but the use of the intermediate table that bothers me. The temporary table can be eliminated somehow? Or is the most reasonable way to loop just explicitly and parse the XML message and then update each row separately?

    I'm under 11.2.0.1.0.
    create table otn9test (
      id number not null primary key,
      data xmltype
    );
    
    insert into otn9test values (1, xmltype('<data>default for 1</data>'));
    insert into otn9test values (2, xmltype('<data>default for 2</data>'));
    insert into otn9test values (3, xmltype('<data>default for 3</data>'));
    
    create table otn9input (
      id number,
      data xmltype
    );
    
    column data format a30
    
    declare
      updata constant xmltype := xmltype('<root>
      <item>
        <id>1</id>
        <data>Id 1 updated.</data>
      </item>
      <item>
        <id>3</id>
        <data>Id 3 updated.</data>
      </item>
      <item>
        <id>4</id>
        <data>Id 4 updated.</data>
      </item>
    </root>');
    
    begin
      insert into otn9input
        select * from
        xmltable('/root/item' passing updata
              columns
              id number path 'id',
              data xmltype path 'data');
    
      update otn9test t set data = (
        select data from otn9input i
        where t.id = i.id
      ) where t.id in (select id from otn9input);
    
      commit;
    end;
    /
    
    select * from otn9input;
    
    /*
         ID DATA
    ---------- ------------------------------
          1 <data>Id 1 updated.</data>
          3 <data>Id 3 updated.</data>
          4 <data>Id 4 updated.</data>
    */
    
    select * from otn9test;
    
    /*
         ID DATA
    ---------- ------------------------------
          1 <data>Id 1 updated.</data>
          2 <data>default for 2</data>
          3 <data>Id 3 updated.</data>
    */
    
    drop table otn9input;
    drop table otn9test;

    The temporary table can be eliminated somehow?

    You can do it with the MERGER:

    merge into otn9test t
    using (
      select id, data
      from xmltable('/root/item' passing updata
            columns
              id   number  path 'id',
              data xmltype path 'data'
           )
    ) x
    on ( t.id = x.id )
    when matched then update
     set t.data = x.data
    ;
    

    However, if you are looking for performance on large data sets, I think that the best is to use an intermediate table of XMLType (binary storage) to maintain the XML instance.

    create table otn9input of xmltype
    xmltype store as securefile binary xml;
    
    insert into otn9input values(
    xmltype('
      
        1
        Id 1 updated.
      
      
        3
        Id 3 updated.
      
      
        4
        Id 4 updated.
      
    ')
    );
    
    merge into otn9test t
    using (
    select id, data
    from otn9input,
         xmltable('/root/item' passing object_value
              columns
                id number path 'id',
                data xmltype path 'data'
         )
    ) x
    on ( t.id = x.id )
    when matched then update
     set t.data = x.data
    ;
    

    A structured XMLIndex could also help.

  • When I install FSX SP2, the box of the menu showing the plan chosen and also in the game, the graphics are all messed up (black, black with lines on the screen and so on) do not know what to do? I need help.

    I have FSX Deluxe. When I installed FSX SP1, it was all fine, but when I installed FSX SP2 graphics were messed up. So I uninstalled FSX SP2 and tried again, and it was the same thing. So I uninstalled FSX all together and reinstalled fresh and put on FSX SP1, it was going well until I put FSX SP2, the same thing happened again, messed up graphics.

    So I uninstalled FSX SP2 and updated my drivers graphic and tried again and the same thing happened.

    I need help please.
    Thank you

    Hi Mmarshall_1993,

    Welcome to the Microsoft Answers site.

    We would like to get a better understanding of this issue, so we can better help not only you but other users with similar problems.

    (a) what operating system do you use?

    Method 1:

    Adjust display settings

    Many recent Microsoft games require a card video and monitor that can run a resolution of at least 800 x 600 in color (16 bit). Set the resolution of Windows display on 800 x 600 in color (16 bit), and then test the game. To do this, follow these steps:

    1. in Windows XP, click Start, point to settings and then click Control Panel.
    In Windows Vista, click on start to reduce this includes personalization thtype in the Search box and then click on personalization in the programs list.

    2. in Windows XP, double-click display.
    In Windows Vista, click display settings.

    3. click on the settings tab.

    4. move the slider of the desktop area or screen area slider to 800 x 600 pixel definition.

    5. in the Color Palette box or in the color box, click colors (16 bit).

    6. click OK and then click OK again.

    7. click Yes to accept the setting.

    Method 2:

    Adjust graphics hardware acceleration

    To adjust graphics hardware acceleration, use the method described for the operating system that you use:

    ·         Windows Vista

    1. click on start to reduce this includes this ima, type personalization in the Start Search box, and then click personalization in the list of programs .

    2. click on display settings.

    3. click on Advanced settings.

    4. click the Troubleshooting tab, and then click change settings.

    Reduce this includes this imIf that you are prompted for an administrator password or a confirmation, type the password or click on allow.

    5. move the notches on both Hardware Acceleration slider to the left of full (the parameter disable the accelerations of cursor and bitmap ).

    6. click OK and then click restart now.

    7. once the computer has restarted, test the game.

    ·         Microsoft Windows 2000 or Windows XP

    1. click on Start, point to settings and then click Control Panel.

    2. double-click on display.

    3. on the settings tab, click Advanced.

    4. click on the Troubleshooting tab.

    5. move the notches on both Hardware Acceleration slider to the left of full (the turn off all cursor and advanced drawing accelerations setting).

    6. click OK and then click OK again.

    7. test the game.

    Method 3:

    Check or turn on Direct 3D

    To check or turn on Windows XP Direct3D acceleration, follow these steps:

    1. click on Start, click run, type dxdiag , and then click OK.

    2. on the display tab, verify that all DirectX features are enabled. If all the features are disabled, click enable next to the feature.
    Note If some DirectX features are unavailable, verify that your video card meets the minimum requirements.

    For more information, follow the below mentioned articles.

    How to resolve display issues in Microsoft games

    http://support.Microsoft.com/kb/263039

    The Flight Simulator X game display flickers and are damaged on a Windows Vista-based computer that is connected to multiple monitors

    http://support.Microsoft.com/kb/933590

    Hope this information is useful.

    Thanks and regards.

    Thahaseena M
    Microsoft Answers Support Engineer.
    Visit our Microsoft answers feedback Forum and let us know what you think.

  • The script generation is not supported for Table with XML or UDT column Types

    I get this message trying to generate a script to create a table with an XMLTYPE column.  We use the Oracle Developer Tools for Visual Studio to generate scripts as SQLDeveloper does still not support TFS integration.  He was always pretty easy to generate scripts and maintain control of source code in this way (with the exception of materialized views).  It was great, just right click and generate a script for the project and check it in.  Unfortunately as the adoption of XML grows, we find passage to the SQL Developer more often to perform tasks not supported and then return to the VS IDE to manage source code control.  Free of any chance that it will be supported in the future?

    Yes, our plan is to support several types as time goes by.

    You possibly can speed things along by voting or by filing a request for new feature here:

    http://Apex.Oracle.com/pls/Apex/f?p=18357:46

  • table (cast - invalid data type problem

    Hi all

    Baseline scenario:

    --------------------------
    PACKAGE
    --------------------------
    create or replace
    PACKAGE C2_PAYMENT_DOC IS

    Bin_array TYPE TABLE IS NUMBER
    INDEX OF DIRECTORY;

    FUNCTION test_fun (l_doc_id IN integer) RETURN bin_array;
    --------------------------
    PACKAGE_BODY
    --------------------------
    create or replace
    package C2_PAYMENT_DOC as body

    Bin_array test_fun (l_doc_id-IN integer) FUNCTION RETURNS IS
    l_gross bin_array;
    Start
    c2_purchase_invoice.get_inv_gross_amount (l_doc_id, l_gross (1));
    Return l_gross;
    end;
    END;
    --------------------------
    QUERY
    --------------------------
    Select * from Table (Cast (c2_payment_doc.test_fun (1) as bin_array));

    The query result is ORA-00902: invalid data type
    How can I make the valid select statement?
    Thanks in advance,
    Bartek

    You cannot use local collection types in SQL. You must create a bin_array of type like nested SQL table type. In addition, depending on the version you will not cast:

    SQL> CREATE OR REPLACE
      2    TYPE bin_array
      3      AS TABLE OF NUMBER
      4  /
    
    Type created.
    
    SQL>  create or replace
      2   PACKAGE C2_PAYMENT_DOC IS
      3  FUNCTION test_fun(l_doc_id IN integer) RETURN bin_array;
      4  end;
      5  /
    
    Package created.
    
    SQL> create or replace
      2  package body C2_PAYMENT_DOC as
      3
      4  FUNCTION test_fun (l_doc_id IN integer) RETURN bin_array IS
      5  l_gross bin_array := bin_array();
      6  begin
      7      l_gross.extend;
      8      l_gross(1) := l_doc_id;
      9  return l_gross;
     10  end;
     11  END;
     12  /
    
    Package body created.
    
    SQL> select * from Table(Cast(c2_payment_doc.test_fun(1) As bin_array));
    
    COLUMN_VALUE
    ------------
               1
    
    SQL> select * from Table(c2_payment_doc.test_fun(1))
      2  /
    
    COLUMN_VALUE
    ------------
               1
    
    SQL> 
    

    SY.

  • data from 3 tables with later dates

    Hello
    Need help with the PL/SQL code, I need to write a code that will get the data from 3 tables with the most recent date.

    For an individual ACT_CODE the output of the SQL query should display the data including the last dates back to 3 tables, if there is no
    Date of the table, it should show the remaining data (think that the left join will do here)

    Names of tables:
    Institution_UPDT aiu
    AC ASQ_CONTACT
    GR_AUTHORIZE gr

    All 3 tables have ACT_Code in common

    Column names

    INSTITUTION_UPDT IAU - IAU. ACT_CODE, AIU.project_id as proj, IAU. UPDT_TYPE_ID, IAU. User_id, IAU. UPDT_DATE

    ASQ_CONTACT ac - ac. ACT_CODE as contact_code, ac.project_id, ac.first_name, ac.middle_initial, ac.last_
    Name, AC.title, AC. Status, AC.status_date

    GR_AUTHORIZE gr - GR ACT_CODE as grad_code, gr.name, gr.title AS grad_title, gr.submit_date


    Are the names of the columns date
    AC.status_date,
    IAU. UPDT_DATE and
    Gr.submit_date

    Thanks to you all
    appreciate your help

    Jesh

    Hi, Ngoumba,

    If a given ACT_Code couldn't miss from any of the tables, then you will use better full outer joins, not a join left outer.

    Perhaps it would be more effective to make a UNION of the three tables, then rotate the results in three datecolumns.

    You can use the GROUP BY aggregation to get the last date for each ACT_Code in each table.
    If you need other columns in the row which is the last date, you can use the ROW_NUMBER analytic function, like this:

    SELECT  ACT_Code
    ,     updt_date
    ,     ROW_NUMBER () OVER ( PARTITION BY  ACT_Code
                              ORDER BY          updt_date     DESC
                      ) AS r_num
    FROM    institution_updt
    

    The lines with r_num = 1 are the most recent

    This is a technique of ot the UNION-PIVOT example:

    WITH     union_data     AS
    (
         SELECT    ACT_Code
         ,       MAX (updt_date)     AS last_date
         ,       1                  AS table_id
         FROM       institution_updt
         GROUP BY  ACT_Code
    UNION ALL
         SELECT    ACT_Code
         ,       MAX (status_date)     AS last_date
         ,       2                  AS table_id
         FROM       ASQ_Contact
         GROUP BY  ACT_Code
    UNION ALL
         SELECT    ACT_Code
         ,       MAX (submit_date)     AS last_date
         ,       3                  AS table_id
         FROM       GR_Authorize
         GROUP BY  ACT_Code
    )
    SELECT       ACT_Code
    ,       MAX (CASE WHEN table_id = 1 THEN last_date END)     AS aiu_updt_date
    ,       MAX (CASE WHEN table_id = 2 THEN last_date END)     AS ac_status_date
    ,       MAX (CASE WHEN table_id = 3 THEN last_date END)     AS gr_submit_date
    FROM       union_data
    GROUP BY  ACT_Code
    ORDER BY  ACT_Code
    ;
    

    Published by: Frank Kulash, on September 16, 2009 15:02
    Added UNION-pivot example

Maybe you are looking for