How to sort index_by pl/sql tables data in Oracle 9i Release 9.2.0.1.0 ?

Hi all,
I have populated an index_by binary_integer pl/sql table :
declare
type rec_ty is record(ligne number,code_enreg number(2),code_enreg_ordered number(2));
     type tab_ty is table of rec_ty index by binary_integer;
     vtab tab_ty;
     i pls_integer := 1;
begin
for venreg in(select * from fichier_tempo where num > 0 order by num) loop
          vtab(i).ligne := venreg.num;
          vtab(i).code_enreg := to_number(substr(venreg.texte,7,2));
          i := i + 1;
     end loop;
end;
Now I want to sort the code_enreg data of vtab into its code_enreg_ordered field. I must do that because I must verify that each code_enreg data entered are ordered. So if code_enreg is not equal to code_enreg_ordered at a specified index of vtab then I must take a decision in my program code ; I must code something when this disorder happens.
How to do that ?
Thank you very much indeed.

Thank you Jeneesh , it works with a few modifications about the assignement of the pl/sql tables.
Fantasy > Your blog talks about sorting the pl/sql table through the key. But I want to sort it through the field data. And my field data contains duplicated data. So you did not really reply to my need. Thank you anymore.

Similar Messages

  • How to join two pl/sql tables .,.,,Urgent pls help

    Hi,
    Please tell me how to join to pl/sql tables with example
    thanks
    asp

    If your main intention is to get the common records/or getting whole records from the 2 different pl/sql arrays then , pls check this piece of code & explanation
    The SQL language has long offered the ability to apply set operations (UNION, INTERSECT, and MINUS) to the result sets of queries. In Oracle Database 10g, you can now use those same high-level, very powerful operators against nested tables (and only nested tables) in your PL/SQL programs and on nested tables declared as columns inside relational tables.
    Let's take a look at some of the syntax needed to do this, starting with UNION.
    First, I create a schema-level nested table type:
    CREATE OR REPLACE TYPE strings_nt
    IS TABLE OF VARCHAR2(100);
    Then I define a package and within it create and populate two nested tables of this type, each containing some of my father's and my favorite things:
    CREATE OR REPLACE PACKAGE favorites_pkg
    IS
    my_favorites strings_nt
    := strings_nt ('CHOCOLATE'
    , 'BRUSSEL SPROUTS'
    , 'SPIDER ROLL'
    dad_favorites strings_nt
    := strings_nt ('PICKLED HERRING
    , 'POTATOES'
    , 'PASTRAMI'
    , 'CHOCOLATE'
    PROCEDURE show_favorites (
    title_in IN VARCHAR2
    , favs_in IN strings_nt
    END;
    In this package, I also include a procedure to show the contents of a strings_nt nested table. This will come in very handy shortly.
    By defining these collections in a package, outside any program, they persist (they maintain their state and values) for the duration of my session or until I change or delete them. This means that I can now write programs outside the package to manipulate the contents of those collections.
    Note that this package has been simplified for the purposes of presenting collection functionality. In a production application, you should always take care to "hide" your package data, as with these collections, in the package body, and then provide procedures and functions to manage the data.
    Suppose, for example, that I would like to combine these two collections into a single collection of our favorites. Prior to Oracle Database 10g, I would have to write a loop that transfers the contents of one collection to another. Now, I can rely on the MULTISET UNION operator, as shown below:
    DECLARE
    our_favorites
    strings_nt := strings_nt ();
    BEGIN
    our_favorites :=
    favorites_pkg.my_favorites
    MULTISET UNION ---- Use INTERSECT , if you want to know common records
    favorites_pkg.dad_favorites;
    favorites_pkg.show_favorites (
    'ME then DAD', our_favorites);
    END;
    The output from this script is:
    ME then DAD
    1 = CHOCOLATE
    2 = BRUSSEL SPROUTS
    3 = SPIDER ROLL
    4 = PICKLED HERRING
    5 = POTATOES
    6 = PASTRAMI
    7 = CHOCOLATE
    ------------------------------

  • How to import XML into SQL Table

    Dear all,
    There are a lot of books about exporting data into XML format.
    Actually, how to use XML Documents? Sorry I am new that I ask such a question.
    What i think may be exchange or save data using xml. If so, How to import into MS SQL table? Do it need to do any mapping?
    Appreciate for your hints

    Are you sure you want to use XML with tables for this? No doubt importing XML into tables is useful for some specialized tasks, such as importing formatting information inside the XML itself, but for most of the familiar tasks that XML excels at, tables are neither necessary nor useful.
    In my (limited) experience, if the XML elements are well-differentiated, by which I mean different types of data have their own distinctive tags, then the special powers of XML can be exploited more fully using the more familiar tagged text, nested tags etc. in ordinary text frames using paragraph breaks, tab characters, etc. to achieve a suitably "tabular" finished appearance.
    If you must import XML into tables, I recommend Adobe's own PDF "Adobe InDesign CS3 and XML: A Technical Reference" availabe here:
    http://www.adobe.com/designcenter/indesign/articles/indcs3ip_xmlrules.pdf
    It sounds very daunting -- the words "technical reference" make me shudder -- but actually it's very readable and not very technical at all. Some nice pics and everything!
    Jeremy

  • Problem with pl/sql table data type

    hai friends,
    i have one procedure it has some in parameters and one out parameter which fetches values to front end.
    But the out parameter will be pl/sql table data type.
    if it is ref cursor
    then i declared as
    var x refcursor;
    exec procedure_name(1,:x);
    it is ok.
    but for pl/sql table data type is out parameter then what i will do in the prompt .
    give me syntax and clarify my doubt.
    advanced thanks...
    madhava

    The SQL*Plus VARIABLE statement does not support user-defined types, hence it cannot support nested tables. It can support cursors because they can be weakly typed (so we can use the one SQL*Plus VAR to hold any shape of resultset). Nested tables are strongly typed; SQL*Plus is a relatively stupid interface and cannot be expected to understand UDT.
    So, it you want to use nested tables as output you'll need to code a wrapping procedure that can understand your nested table type and handle it accordingly.
    Sorry.
    Cheers, APC

  • How do i find out the tables (data)effected in a schema after a particular time stamp

    how do i find out the tables (data not structure)effected in a schema after a particular time stamp?
    pls email in [email protected]

    You can't do that. That would be a real security risc.
    /KAj

  • What is the easiest way to export all tables data from Oracle to MS SQL Server?

    Hello MS,
    I would like to export all tables from Oracle 11.2 to MS SQL Server 2012 R1.
    Using the tool "Microsoft SQL Server Migration Assistant v6.0 for Oracle" did not work for me because there are too many warnings and errors regarding the schema creation (MS cannot know it because they are not the schema designer). My idea is
    to leave/skip the schema creation to the application designer/supplier and instead concentrate on the Oracle data export and MS SQL data import.
    What is the easiest way to export all tables data from Oracle to MS SQL Server quickly?
    Is it:
    - the „MS SQL Import and Export Data“ Tool
    - the “MS SQL Integration Services” Tool
    - not Oracle dump *.dmp format because it is a propritery binary format
    - flat file *.csv (delimited format)
    Thanks!

    Hi lingodingo,
    If you want to directly export all tables from Oracle database to SQL Server, I suggest you use SQL Server Import and Export Wizard. Because you just need to follow the wizard with GUI, this is the easiest way.
    If you want to make some modification for the tables‘ data before loading to SQL Server, I suggest you use SQL Server Integration Services package. For more details, please refer to the following similar thread:
    https://social.msdn.microsoft.com/Forums/sqlserver/en-US/38b2bed2-9d4e-48d4-a33f-1d9eed1c062d/flat-file-to-sql-server?forum=sqldatamining
    Thanks,
    Katherine Xiong
    Katherine Xiong
    TechNet Community Support

  • How to insert more than 32k xml data into oracle clob column

    how to insert more than 32k xml data into oracle clob column.
    xml data is coming from java front end
    if we cannot use clob than what are the different options available

    Are you facing any issue with my code?
    String lateral size error will come when you try to insert the full xml in string format.
    public static boolean writeCLOBData(String tableName, String id, String columnName, String strContents) throws DataAccessException{
      boolean isUpdated = true;
      Connection connection = null;
      try {
      connection = ConnectionManager.getConnection ();
      //connection.setAutoCommit ( false );
      PreparedStatement PREPARE_STATEMENT = null;
      String sqlQuery = "UPDATE " + tableName + " SET " + columnName + "  = ?  WHERE ID =" + id;
      PREPARE_STATEMENT = connection.prepareStatement ( sqlQuery );
      // converting string to reader stream
      Reader reader = new StringReader ( strContents );
      PREPARE_STATEMENT.setClob ( 1, reader );
      // return false after updating the clob data to DB
      isUpdated = PREPARE_STATEMENT.execute ();
      PREPARE_STATEMENT.close ();
      } catch ( SQLException e ) {
      e.printStackTrace ();
      finally{
      return isUpdated;
    Try this JAVA code.

  • How to write a PL/SQL stored procedure in Oracle to call Webservice

    Can any one pelase send me a code on how to write a PL/SQL stored procedure in Oracle database to call the Webservice ?
    Thanks,
    Rajesh

    Were you able to solve this problem

  • Error in import table data using oracle datapump

    i am trying to import table data using oracle datapump
    CREATE TABLE emp_xt (
    ID NUMBER,
    NAME VARCHAR2(30)
    ORGANIZATION EXTERNAL (
    TYPE ORACLE_DATAPUMP
    DEFAULT DIRECTORY backup
    LOCATION ('a.dmp')
    it return the following error
    ORA-29913: error in executing ODCIEXTTABLEOPEN callout
    ORA-29400: data cartridge error
    KUP-04084: The ORACLE_DATAPUMP access driver does not support the ROWID column.
    ORA-06512: at "SYS.ORACLE_DATAPUMP", line 19
    please help me

    .dmp file generated from exp command file not from oracle_datapump

  • Access SQL-Server Data from Oracle 10gXE

    Hello,
    I want to access sql-server data from oracle 10g XE. I need the same functionality provided by Sql-server by Linked Servers, by which we can query on any data source(oracle, Excel, Access).
    do, Oracle 10gXE provide us with same functionality ???
    any pointers ???

    Yes, it does work with Express Edition.
    Here is a thread from the XE forum with examples.
    Re: Database Link to MS Access
    They refer to a MS Access database, but the procedure is the same.
    Doug

  • How to upload sap r/3 table data to ms-sql 2000?

    Dear Friends
    any one can help me out step by step to upload sap r/3 table data to ms-sql 2000.
    Thanks in advance

    hi
    good
    go through this link
    http://www.itcserver.com/blog/2006/06/29/data-transfer-methods/
    thanks
    mrutyun^

  • How to export sql table data to Excel/PDf using Storedprocedure?

    Hi ,
            I have one table in sqlserver2008R2 that named "Customer" so that table hold the 1 Lac rows. Now I want send this table data to Excel/pdf with Columns using Storedprocedure.
       I have tried this using xp_cmdshell so This is not working for me.
    finally i want to get data in Excel and pdf also.
    Please guide me

    You can actually run an Excel Macro to grab the data from the SQL Server DB.  Below are some samples.
    Sub ADOExcelSQLServer()
    ' Carl SQL Server Connection
    ' FOR THIS CODE TO WORK
    ' In VBE you need to go Tools References and check Microsoft Active X Data Objects 2.x library
    Dim Cn As ADODB.Connection
    Dim Server_Name As String
    Dim Database_Name As String
    Dim User_ID As String
    Dim Password As String
    Dim SQLStr As String
    Dim rs As ADODB.Recordset
    Set rs = New ADODB.Recordset
    Server_Name = "Excel-PC\SQLEXPRESS" ' Enter your server name here
    Database_Name = "Northwind" ' Enter your database name here
    User_ID = "" ' enter your user ID here
    Password = "" ' Enter your password here
    SQLStr = "SELECT * FROM dbo.Orders" ' Enter your SQL here
    Set Cn = New ADODB.Connection
    Cn.Open "Driver={SQL Server};Server=" & Server_Name & ";Database=" & Database_Name & _
    ";Uid=" & User_ID & ";Pwd=" & Password & ";"
    rs.Open SQLStr, Cn, adOpenStatic
    ' Dump to spreadsheet
    With Worksheets("sheet1").Range("a1:z500") ' Enter your sheet name and range here
    .ClearContents
    .CopyFromRecordset rs
    End With
    ' Tidy up
    rs.Close
    Set rs = Nothing
    Cn.Close
    Set Cn = Nothing
    End Sub
    Sub ADOExcelSQLServer()
    Dim Cn As ADODB.Connection
    Dim Server_Name As String
    Dim Database_Name As String
    Dim User_ID As String
    Dim Password As String
    Dim SQLStr As String
    Dim rs As ADODB.Recordset
    Set rs = New ADODB.Recordset
    Server_Name = "LAPTOP\SQL_EXPRESS" ' Enter your server name here
    Database_Name = "Northwind" ' Enter your database name here
    User_ID = "" ' enter your user ID here
    Password = "" ' Enter your password here
    SQLStr = "SELECT * FROM Orders" ' Enter your SQL here
    Set Cn = New ADODB.Connection
    Cn.Open "Driver={SQL Server};Server=" & Server_Name & ";Database=" & Database_Name & _
    ";Uid=" & User_ID & ";Pwd=" & Password & ";"
    rs.Open SQLStr, Cn, adOpenStatic
    With Worksheets("Sheet1").Range("A2:Z500")
    .ClearContents
    .CopyFromRecordset rs
    End With
    rs.Close
    Set rs = Nothing
    Cn.Close
    Set Cn = Nothing
    End Sub
    Sub TestMacro()
    ' Create a connection object.
    Dim cnPubs As ADODB.Connection
    Set cnPubs = New ADODB.Connection
    ' Provide the connection string.
    Dim strConn As String
    'Use the SQL Server OLE DB Provider.
    strConn = "PROVIDER=SQLOLEDB;"
    'Connect to the Pubs database on the local server.
    strConn = strConn & "DATA SOURCE=(local);INITIAL CATALOG=NORTHWIND.MDF;"
    'Use an integrated login.
    strConn = strConn & " INTEGRATED SECURITY=sspi;"
    'Now open the connection.
    cnPubs.Open strConn
    ' Create a recordset object.
    Dim rsPubs As ADODB.Recordset
    Set rsPubs = New ADODB.Recordset
    With rsPubs
    ' Assign the Connection object.
    .ActiveConnection = cnPubs
    ' Extract the required records.
    .Open "SELECT * FROM Categories"
    ' Copy the records into cell A1 on Sheet1.
    Sheet1.Range("A1").CopyFromRecordset rsPubs
    ' Tidy up
    .Close
    End With
    cnPubs.Close
    Set rsPubs = Nothing
    Set cnPubs = Nothing
    End Sub
    Finally, you can run a SProc in SQL Server, from Excel, if you want the SProc to do the export.
    Option Explicit
    Sub Working2()
    'USE [Northwind]
    'GO
    'DECLARE @return_value int
    'EXEC @return_value = [dbo].[TestNewProc]
    ' @ShipCountry = NULL
    'SELECT 'Return Value' = @return_value
    'GO
    Dim con As Connection
    Dim rst As Recordset
    Dim strConn As String
    Set con = New Connection
    strConn = "Provider=SQLOLEDB;"
    strConn = strConn & "Data Source=LAPTOP\SQL_EXPRESS;"
    strConn = strConn & "Initial Catalog=Northwind;"
    strConn = strConn & "Integrated Security=SSPI;"
    con.Open strConn
    'Put a country name in Cell E1
    Set rst = con.Execute("Exec dbo.TestNewProc '" & ActiveSheet.Range("E1").Text & "'")
    'The total count of records is returned to Cell A5
    ActiveSheet.Range("A5").CopyFromRecordset rst
    rst.Close
    con.Close
    End Sub
    Sub Working()
    'USE [Northwind]
    'GO
    'DECLARE @return_value int
    'EXEC @return_value = [dbo].[Ten Most Expensive Products]
    'SELECT 'Return Value' = @return_value
    'GO
    Dim con As Connection
    Dim rst As Recordset
    Set con = New Connection
    con.Open "Provider=SQLOLEDB;Data Source=LAPTOP\SQL_EXPRESS;Initial Catalog=Northwind;Integrated Security=SSPI;"
    Set rst = con.Execute("Exec dbo.[Ten Most Expensive Products]")
    'Results of SProc are returned to Cell A1
    ActiveSheet.Range("A1").CopyFromRecordset rst
    rst.Close
    con.Close
    End Sub
    Knowledge is the only thing that I can give you, and still retain, and we are both better off for it.

  • How to Sort Dimension in Pivot Table via Order Column which is changing like Factual values

    Hi,
    Recently in of our product offerings we got stuck on this following question:
    How to Sort Dimension based on the Order Value which Keeps Changing with Factual Values??
    We have a data source laid out as (example)
    In the above the “Order” columns are changing per
    Company/(DimensionA) for DimesnsionB.
    Instead what we want is: (But only if we can get the following result without putting the “Order” Column in the “Values” Section. 
    If there are any configurations that we can make to our power pivot model for the similar data set so that the
    DimesnionB in this case can be sorted by the Order column, would be greatly helpful to us. 
    Sample File:
    http://tms.managility.com.au/query_example.xlsx
    Thanks
    Amol 

    Hi Amol,
    According to your description, you need to sort dimension members in Pivot Table via order column, and you don't want the order column show on the Pivot table, right?
    Based on my research, we can sort the data on the Pivot table based on one of the columns in that table, and we cannot sort the data based on the columns that not existed on the Pivot table. So in your scenario, to achieve your requirement, you can
    add the column to pivot table and hide it.
    https://support.office.com/en-gb/article/Sort-data-in-a-PivotTable-or-a-PivotChart-report-49efc50a-c8d9-4d34-a254-632794ff1e6e
    Regards,
    Charlie Liao
    TechNet Community Support

  • [HOW TO] comare 2 PL/SQL tables

    I want to compare 2 PL/SQL tables, something like this pseudo code:
    TYPE type_tbl IS TABLE OF table123%ROWTYPE
    INDEX BY BINARY_INTEGER;
    test1 type_tbl;
    test2 type_tbl;
    BEGIN
    insert a couple rows into each table
    IF test1 = test2 then EQUAL!
    ELSE NOT EQUAL
    END IF
    Based on this link I would think it's possible in 10g but I get a compile time error on the IF statement.
    [http://www.oracle.com/technology/oramag/oracle/03-sep/o53plsql.html]
    I understand that I could write my own Equal function but I it looks like it should be built in functionality.
    Thanks in advance for the help!

    Here is how it's going to be used: 2 separate developers are going to write code, each will create an in memory table, call them table1 and table2. These two tables then need to be compared against each other to see if every row and every column are identical. If they are equal we will take the data from one of the in memory tables and write that data to a physical table.
    If the 2 in memory tables are not equal then we want to abort and throw an error.

  • How to loop and read repeating table data of infoPath form in Visual studio workflow.

    Hi,
    I am trying to read info Path form repeating table data in Visual studio workflow.
    could anyone elaborate me in brief how to loop through repeating table and read all rows value one by one in workflow.
    any help would be more then welcome. 
    Thanks...

    Hi Rohan,
    According to your description, my understanding is that you want to create a Visual Studio workflow to get data from info path repeating table.
    I suggest you can submit Repeating Table to a SharePoint List and then you can create a .NET workflow to read data from the SharePoint List.
    Here are some detailed articles for your reference:
    Codeless submitting InfoPath repeating table to a SharePoint list
    Create a Workflow using Visual Studio 2010
    Best Regards
    Zhengyu Guo
    TechNet Community Support

Maybe you are looking for

  • HTTPS from JDK1.2.1 to JDK 1.4.1

    We are trying to connect application running on JDK1.2.1 to application in JDK 1.4.1. Both applications are in Oracle 9ias application server but with different JDK and different physical machines. We are getting following error while trying to acces

  • Error while runnig adcfgclone.pl dbTier

    Hii. i was cloning my PROD instance to a Test instance and while configuring the target system database server perl adcfgclone.pl dbTier, Im getting the following error The new database context file has been created : */u03/UAT/uatdb/10.2.0/appsutil/

  • IOS devices will not enroll

    Hi I having a server OS  X10.9.2 on a Mac Mini. I have enroll my MacBook Pro no problem. First i install Trust Profile, and then I enroll. Everything worked. When I tried to do the same with my iPhone and iPad everything was OK but still it asked to

  • View All Products Shipped To Customer

    Hi All, I'm new to SAP overall and was just wondering if it is possible to view all the products being sent in a certain date to a particular customer. I know how to view the Sales Orders for customers (VA05), but is there any way I can see a full li

  • CS4 won't open

    I installed CS4 on my new Vista 64bit computer. I had it operating and now it will not open up in either 32 to 64 bit. Bridge will open up but CS4. Also it will not open up .cr2 files. It will open DNG's. Will I need to reinstall CS4? Any other cure?