Oracle equivalent of...

What is the oracle equivalent of a sql datatype bigint as an IDENTITY column with identity seed 1 and identity increment 1. I am very new to oracle so I am using TOAD to create this table. So im just looking for a KEY field such as an ID field that just creates its own number every time data is entered into any column.
Kind of like ACCESS's autonumber field. Where or what datatype in TOAD do I select for this and tell it that it should automatically create the next ID number.
For example I insert 4 rows
"Jon"
"Bob"
"Steve"
"Mark"
The result in the table should be:
1 Jon
2 Bob
3 Steve
4 Mark
(the numbers are automatic)...If I delete steve then it becomes
1 Jon
2 Bob
4 Mark
(gaps are of course OK since this is just an identity column).
Thanks,
Jon
PS: Is there a way toi change my oracle forum password ? I cant seem to find that either.

You can use a sequence and insert it in a trigger :
TEST@db102 SQL> create sequence test_seq nocache;
Sequence created.
TEST@db102 SQL> create table test(c1 number not null , c2 varchar2(50));
Table created.
TEST@db102 SQL> create or replace trigger test_trig
  2  before insert on test
  3  for each row
  4  begin
  5     select test_seq.nextval into :new.c1 from dual;
  6* end;
TEST@db102 SQL> /
Trigger created.
TEST@db102 SQL> insert into test(c2) values('Jon');
1 row created.
TEST@db102 SQL> insert into test(c2) values('Bob');
1 row created.
TEST@db102 SQL> insert into test(c2) values('Steve');
1 row created.
TEST@db102 SQL> insert into test(c2) values('Mark');
1 row created.
TEST@db102 SQL> select * from test;
        C1 C2
         1 Jon
         2 Bob
         3 Steve
         4 Mark
TEST@db102 SQL>                                                      

Similar Messages

  • What is the Oracle equivalent of the Microsoft Access FIRST function?

    Using: Oracle 10gR2 RAC on SUSE Linux 9 (10.2.0.3)
    In the process of converting a Microsoft Access database to Oracle, an Access query is using the FIRST function.
    What is the Oracle equivalent of the Microsoft Access FIRST function?
    In the attempt to convert, the Oracle FIRST_VALUE function was used. However, the same results was not achieved.
    Thanks,
    (BLL)
    Query:
    h2. ACCESS:
    SELECT
         TRE.GCUSNO,
         UCASE([DCUSNO]) AS DCUSNO_STD,
         *FIRST(UCASE([DNAME])) AS DNAME_STD*,
         *FIRST(UCASE([DADDR])) AS DADDR_STD*,
         *FIRST(UCASE([DCITY])) AS DCITY_STD*,
         TRE.DSTATE,
         FIRST(TRE.DZIP) AS DZIP,
         TRE.DREGN,
         TRE.DDIST,
         TRE.DSLSMN,
         TRE.DCHAIN,
         TRE.MARKET,
         TRE.MKTPGM,
         TRE.EUMKT
    FROM
         TRE
    GROUP BY
         TRE.GCUSNO,
         UCASE([DCUSNO]),
         TRE.DSTATE,
         TRE.DREGN,
         TRE.DDIST,
         TRE.DSLSMN,
         TRE.DCHAIN,
         TRE.MARKET,
         TRE.MKTPGM,
         TRE.EUMKT;
    h2. ORACLE:
    SELECT DISTINCT
    TRE.GCUSNO,
    UPPER(TRIM(TRE.DCUSNO)) AS DCUSNO_STD,
    UPPER(TRIM(TRE.DNAME)) AS DNAME_STD,
    UPPER(TRIM(TRE.DADDR)) AS DADDR_STD,
         FIRST_VALUE(UPPER(TRIM(TRE.DNAME)) IGNORE NULLS) OVER (ORDER BY TRE.GCUSNO) AS DNAME_STD,
         FIRST_VALUE(UPPER(TRIM(TRE.DADDR)) IGNORE NULLS) OVER (ORDER BY TRE.GCUSNO) AS DADDR_STD,
         FIRST_VALUE(UPPER(TRIM(TRE.DCITY)) IGNORE NULLS) OVER (ORDER BY TRE.GCUSNO) AS DCITY_STD,
    TRE.DSTATE,
    TRE.DZIP,
    FIRST_VALUE(UPPER(TRIM(TRE.DZIP)) IGNORE NULLS) OVER (ORDER BY TRE.DZIP ASC) AS DZIP,
    TRE.DREGN,
    TRE.DDIST,
    TRE.DSLSMN,
    TRE.DCHAIN,
    TRE.MARKET,
    TRE.MKTPGM,
    TRE.EUMKT
    FROM CRM.TREUP100R TRE
    GROUP BY
    TRE.GCUSNO,
    UPPER(TRIM(TRE.DCUSNO)),
    TRE.DNAME,
    TRE.DADDR,
    TRE.DCITY,
    TRE.DSTATE,
    TRE.DZIP,
    TRE.DREGN,
    TRE.DDIST,
    TRE.DSLSMN,
    TRE.DCHAIN,
    TRE.MARKET,
    TRE.MKTPGM,
    TRE.EUMKT;

    A slight correction to odie's post. I think you want min not max to replicate the Access first function, but see below to be sure. So:
    min(upper(trim(tre.dname))) keep (dense_rank first order by tre.gcusno) as dname_std
    user10860953 wrote:How does one ignore null values?The min and max functions will ignore nulls automatically, so if there is a null value in tre.dname, it will not be be returned, unless all of the values are null. For example:
    SQL> WITH t AS (
      2     SELECT 65 id, 'ABCD' col FROM dual UNION ALL
      3     SELECT 37, 'DEFG' FROM dual UNION ALL
      4     SELECT 65, 'DEFG' FROM dual UNION ALL
      5     SELECT 65, null FROM dual UNION ALL
      6     SELECT 70, null FROM dual UNION ALL
      7     SELECT 70, null FROM dual UNION ALL
      8     SELECT 37, 'ABC' from dual)
      9  SELECT id,
    10         MIN(col) keep (DENSE_RANK FIRST ORDER BY id) min_dname_std,
    11         MAX(col) keep (DENSE_RANK FIRST ORDER BY id) max_dname_std
    12  FROM t
    13  GROUP BY id;
            ID MIN_ MAX_
            37 ABC  DEFG
            65 ABCD DEFG
            70John

  • Looking for the oracle equivalent of T-SQL 'SELECT TOP n'

    Hi,
    I'm looking for the Oracle equivalent of T-SQL 'SELECT TOP n'
    and can't find any. There is SAMPLE(n) function but it supposed
    to pick up random values and I'm not sure if it's possible to
    make it select top values. Please help 8-)
    Thanx

    Hi Marina.
    Oracle does not have a functionality like SQL Server for TOP
    selection. The ROWNUM option should be used with great care and
    you may get unreliable results.
    Try looking at Metalink
    Doc ID: 291065.999
    Doc ID: 267329.999
    - They discuss this issue, and solutions.

  • Oracle equivalent of MySql commands and code.

    Hi,
    Does anyone know the Oracle equivalent of the following? I'm not a DBA and my DBA doesn't know MySQL. TIA
    Assign access rights: login as root user to mysql:
    mysql -uroot -pYourSecretPassword
    On some MySQL installations, the root user has no password, in that case drop
    the -p parameter.
    Then grant the necessary access rights using the following commands: (this will
    automatically create the users)
    GRANT ALL ON daisyrepository.* TO daisy@"%" IDENTIFIED BY "daisy";
    GRANT ALL ON daisyrepository.* TO daisy@localhost IDENTIFIED BY "daisy";
    (The localhost entries are necessary because otherwise the default access rights
    for anonymous users @localhost will take precedence.)
    and create the database using:
    CREATE DATABASE daisyrepository;
    jack

    GRANT ALL ON daisyrepository.* TO daisy@% IDENTIFIED
    BY "daisy";This means:
    GRANT ALL privileges
    ON all tables and views in schema 'daisyrepository'
    To user daisy from any host.
    There are several problems in translation to Oracle:
    1) Oracle has a few more privs than MySQL, in part because there are a few more object types. You need to be more restrictive than 'GRANT ALL';
    2) Oracle does not support wild cards or patterns grants against a schema's objects. You need to specify each object individually;
    3) Oracle users are database users, not host users, so daisy@% does not make any sense at all. You specify the database user name, or perhaps group users into roles and specify the role name.
    This is discussed in the SQL Reference manual, in the 'GRANT' chapter, for each version of the database. The docs are at http://docs.oracle.com
    Have fun :-p

  • Oracle equivalent of SQL - URGENT

    UPDATE tblA A INNER JOIN tblB B ON (A.TRAN_REF_NO = B.TRAN_REF_NO) AND (A.LINE_TYPE = B.LINE_TYPE) SET A.FLAG = 'U'
    WHERE B.UPDT_ACT_CD='I'. This SQL works fine in SQL Server.
    I need an Oracle equivalent of the above SQL that will work with 9i. It's very urgent, I tried some syntax and everything was hit with error.

    Hi,
    UPDATE PRE_STG_FIF_GL_CROSS_REF A INNER JOIN STG_FIF_GL_CROSS_REF B ON (A.TRAN_REF_NO = B.TRAN_REF_NO) AND (A.LINE_TYPE = B.LINE_TYPE) AND (A.COST_RETAIL_FLAG = B.COST_RETAIL_FLAG) AND (A.TRAN_CODE = B.TRAN_CODE) AND (A.LOCATION = A.LOCATION) AND (A.SUBCLASS = B.SUBCLASS) AND (A.CLASS = B.CLASS) AND (A.DEPT = B.DEPT)
    SET B.DR_CCID = A.DR_CCID, B.DR_SEQUENCE1 = A.DR_SEQ1, B.DR_SEQUENCE2 = A.DR_SEQ2, B.DR_SEQUENCE3 = A.DR_SEQ3, B.DR_SEQUENCE4 = A.DR_SEQ4, B.DR_SEQUENCE5 = A.DR_SEQ5, B.DR_SEQUENCE6 = A.DR_SEQ6, B.DR_SEQUENCE7 = A.DR_SEQ7,B.CR_CCID = A.CR_CCID, B.CR_SEQUENCE2 = A.CR_SEQ2, B.CR_SEQUENCE3 = A.CR_SEQ3, B.CR_SEQUENCE4 = A.CR_SEQ4, B.CR_SEQUENCE5 = A.CR_SEQ5, B.CR_SEQUENCE6 = A.CR_SEQ6, B.CR_SEQUENCE7 = A.CR_SEQ7, B.LST_UPDT_ID = A.Userid, B.LST_UPDT_DTTM = A.Date_Time
    WHERE ((B.UPDT_ACT_CD)='I' Or (B.UPDT_ACT_CD)='U')
    I migrated the above access query to below oracle query and it gives me an error.
    UPDATE STG_FIF_GL_CROSS_REF c
    SET
    DR_CCID,
    DR_SEQUENCE1, DR_SEQUENCE2, DR_SEQUENCE3, DR_SEQUENCE4, DR_SEQUENCE5, DR_SEQUENCE6, DR_SEQUENCE7,
    CR_CCID,
    CR_SEQUENCE1, CR_SEQUENCE2, CR_SEQUENCE3, CR_SEQUENCE4, CR_SEQUENCE5, CR_SEQUENCE6, CR_SEQUENCE7,
    LST_UPDT_ID,LST_UPDT_DTTM
    ) =
    SELECT A.DR_CCID,
    A.DR_SEQ1,A.DR_SEQ2,A.DR_SEQ3,A.DR_SEQ4,A.DR_SEQ5, A.DR_SEQ6,A.DR_SEQ7,
    A.CR_CCID,
    A.CR_SEQ1,A.CR_SEQ2,A.CR_SEQ3,A.CR_SEQ4,A.CR_SEQ5, A.CR_SEQ6,A.CR_SEQ7,
    A.USERID,A.DATE_TIME
    FROM xrfsys.PRE_STG_FIF_GL_CROSS_REF A,STG_FIF_GL_CROSS_REF B WHERE
    B.TRAN_REF_NO = A.TRAN_REF_NO AND
    B.LINE_TYPE = A.LINE_TYPE AND
    B.TRAN_CODE = A.TRAN_CODE AND
    B.LOCATION = A.LOCATION AND
    B.SUBCLASS = A.SUBCLASS AND
    B.CLASS = A.CLASS AND
    B.DEPT = A.DEPT AND
    B.COST_RETAIL_FLAG = A.COST_RETAIL_FLAG)
    WHERE (c.UPDT_ACT_CD='I' Or c.UPDT_ACT_CD='U')
    It throws,ORA-01427: single-row subquery returns more than one row. Please help me to convert this access query to oracle equivalent. The sub query returns multiple records. There are 7 unique records between the two tables and they are returned as output of sub query.

  • Oracle equivalent of SQL IDENTITY Column

    Is there an Oracle equivalent of the MS SQL and Sybase IDENTITY column that creates an automatically incrementing number for each row added?
    Thanks in advance.
    Andy Llewellyn
    [email protected]

    Oracle has what's called a sequence but it's not actually a column in a table. It's a database object that generates
    a sequential number. Here's a simple example of how it works. You can look in the manual for more information.
    SQL> create sequence tt start with 1 nocache;
    Sequence created.
    SQL> create table test(c1 varchar2(1),c2 number);
    Table created.
    SQL> insert into test values('A',tt.nextval);
    1 row created.
    SQL> /
    1 row created.
    SQL> commit;
    Commit complete.
    SQL> select * from test;
    C C2
    A 1
    A 2

  • Oracle equivalent of DECRYPT_CHAR() in DB2

    Dear All,
    We are working in a migration project. We are migrating ODI interfaces from DB2 to Oracle.
    The function DECRYPT_CHAR() is used in one of the procedure script. I could not able to find oracle equivalent of DECRYPT_CHAR() function.
    Could you anyone please provide any pointers on this.
    Thanks a lot in advance.

    Hi,
    As per my experience, there is NO direct function reside for this in Oracle, rather it has inbuild packages to do decryption and encryption but still you need to create a user defined function in your schema.
    Thanks,
    Guru

  • Oracle Equivalent user

    Hi,
    OS: IBM-AIX
    Oracle: Oracle10g 10.2.0.3.0
    I created Oracle user with relavent groups. With logging in as oracle user, I can perform DBA activities.
    My senario is that, I have to create oracle equivalent user say (neworacle). So I have created neworacle user in unix and assigned Oinstall and dba groups.
    I try to login as 'neworacle' user and try to take export of a schema.
    I get the following error
    Connected to: Oracle Database 10g Enterprise Edition Release 10.2.0.3.0 - 64bit Production
    With the Partitioning, OLAP and Data Mining options
    ORA-31626: job does not exist
    ORA-31633: unable to create master table "USR.SYS_EXPORT_SCHEMA_05"
    ORA-06512: at "SYS.DBMS_SYS_ERROR", line 95
    ORA-06512: at "SYS.KUPV$FT", line 863
    ORA-01116: error in opening database file 5
    ORA-01110: data file 5: '/oracle/oradata10g/unbdb/DXML01.dbf'
    ORA-27092: size of file exceeds file size limit of the process
    Additional information: 131071
    Additional information: 944529
    Are this errors cause due to exporting dump through a new user 'neworacle'?
    Is it possible to perform oralce activities using 'neworacle'?
    Thanks in advance
    KSG
    Edited by: KSG on Dec 3, 2009 11:57 AM

    KSG wrote:
    Issue solved.
    I gave datafile access permission to the neworacle user
    and ulimit to unlimited
    Why did you need to give access to datafile 5 to the new user? In fact to change my question to a statement. You should not have had any need to give access to the datafiles to any users.The oracle account should own them and that manages all access to them.
    John
    www.jhdba.wordpress.com

  • Oracle equivalent for OBJECTPROPERTY

    Hi Friends,
    I want the oracle equivalent for the following sql code,
    Select @Command = 'IF OBJECTPROPERTY(object_id('''+ @TableName + '''), ''TableHasForeignRef'') = 1
                              DELETE FROM ' + @TableName + '
                          ELSE
                              TRUNCATE TABLE ' + @TableName
    EXEC sp_MSForEachTable @CommandI have tried to find out, but no use. Please help me.
    Thanks,
    Ram.

    Ram wrote:
    I have tested a table which has foreign key. But the count returned from the query is 0.
    Have I implemented your query in the right way?Same like in SQL Server, Oracle does not allow truncating table if it has a PK or UK which is referenced by FK. There are no issues truncating table with FK. Again, it is table with PK/UK where you might not be able to truncate if that PK/UK is referenced by FK. And SQL Server property TableHasForeignRef = TRUE means there is a FK (on a different table or maybe even on same table if it is self-referencing FK) which is referencing PK/UK on a table in question. Query I suggested returns 1 if table has a PK or UK which is referenced by FK. Otherwise it returns 0. So if, in your case, table MY_TABLE owned by user DBO_XYZ has just FK, 0 is correct and you can truncate it. If it would return 1, you would not be able to truncate and would have to delete.
    SY.

  • Oracle equivalent of SQL DTS package

    In process of migrating SQL database to Oracle database what is Oracle equivalent of SQL DTS package???

    Data transformation services are something totally different, that have nothing to do with migration process. Can you please be more specific with your question? If you really want an answer, then you can consider the conversion phase....
    But, again, there is no reason to compare these two.
    If you want you can read about Oracle's data warehouse concepts, probably ETL is the true answer to your question

  • Connecting via Datasource - Oracle equivalent to DB2DataSource

    Hi
    Have anybody use to connect to oracle via Datasource (using JNDI rather using driver managers) for J2EE (no EJB) development ? (I use WSAD 5.0)
    I had in DB2 there is a class called "DB2DataSource " coming from a package COM.ibm.db2.jndi.DB2InitialContextFactory..
    By digging into Oracle documents in their site they said use following to get InitialContextFactory...
    import com.evermind.sql.DriverManagerDataSource;
    import com.evermind.server;
    Also I included jndi.jar in the project.
    Still I am getting error for above two packages. Where does these packages reside.
    (I have oracle 9i free downloaded version installed)
    What is OC4J ?
    Oracle also said JNDI will beloaded by OC4J.
    Thanks
    Mei

    Hi all
    Thanks for not responding to my question.
    I found that the oracle equivalent package was,
    import oracle.jdbc.pool.OracleDataSource;
    I am all set..
    Mei..

  • "for XML path "  Oracle equivalent of this SQL expression

    SELECT TheID,
    REPLACE(
    RTRIM(
    SELECT StudentID + ' '
    FROM StudentinSchoolLocation TL
    WHERE (LocationID = Results.LocationID)
    FOR XML PATH ('')
    ) AS StudentIDs,
    What is the equivalent of 'For XML path' used above
    The goal is to get a concatenated list of the group by columns. Like where ever the location is same , get the studentIds and make a comma seperated list of all ids for common location
    Works perfectly in SQL.
    Thank you

    Hi,
    user6287828 wrote:
    The goal is to get a concatenated list of the group by columns. Like where ever the location is same , get the studentIds and make a comma seperated list of all ids for common locationThat's called "String Aggregation"
    [AskTom.oracle.com|http://asktom.oracle.com/pls/asktom/f?p=100:11:0::::P11_QUESTION_ID:2196162600402] shows several different ways to do it.
    I recommend the first one, the user-defined function STRAGG, which you can copy from that page.
    On Oracle 10 (and up) you may have a similar function, WM_CONCAT (owned by WMSYS), already installed.
    WM_CONCAT is not documented, so you may not want to use it in your Production applications.
    STRAGG is not so convenient if the order of items in the concatenated string is important.
    In that case, use XMLAGG or SYS_CONNECT_BY_PATH, as shown later in the asktom page.
    MODEL can also do ordered string aggregation.

  • Oracle equivalent of SQL Server's "FOR XML" and "OPENXML"

    Hi
    Can someone please tell what are the Oracle's equivalent of SQL Server's "FOR XML" and "OPENXML" features?

    Probably you can try General XML forum General XML
    Gints Plivna
    http://www.gplivna.eu

  • Oracle equivalent to SQL Server Table Variables ?

    Does Oracle have anything equivalent to SQL Server table variables, that can be used in the JOIN clause of a select statement ?
    What I want to do is execute a query to retrieve a two-column result, into some form of temporary storage (a collection ?), and then re-use that common data in many other queries inside a PL/SQL block. I could use temporary tables, but I'd like to avoid having to create new tables in the database, if possible. If I was doing this in SQL Server, I could use a table variable to do this, but is there anything similar in Oracle ? SQL Server example:
    use Northwind
    DECLARE @myVar TABLE(CustomerID nchar(5), CompanyName nvarchar(40))
    INSERT INTO @myVar(CustomerID, CompanyName)
    select CustomerID, CompanyName
    from Customers
    --Join the variable onto a table in the database
    SELECT *
    FROM @myVar mv join Customers
    on mv.CompanyName = Customers.CompanyName
    The closest I've found in Oracle is to use CREATE TYPE to create new types in the database, and use TABLE and CAST to convert the collection to a table, as shown below. I can't see anyway without creating new types in the database.
    CREATE TYPE IDMap_obj AS Object(OldID number(15), NewID number(15));
    CREATE TYPE IDMap_TAB IS TABLE OF IDMap_obj;
    DECLARE
    v_Count Number(10) := 0;
    --Initialize empty collection
    SourceIDMap IDMap_TAB := IDMap_TAB();
    BEGIN
    --Populate our SourceIDMap variable (dummy select statement for now).
    FOR cur_row IN (select ID As OldID, ID + 10000000 As NewID From SomeTable) LOOP
    SourceIDMap.extend;
    SourceIDMap(SourceIDMap.Last) := IDMap_obj(cur_row.OldId, cur_row.NewId);
    END LOOP;
    --Print out contents of collection
    FOR cur_row IN 1 .. SourceIDMap.Count LOOP
    DBMS_OUTPUT.put_line(SourceIDMap(cur_row).OldId || ' ' || SourceIDMap(cur_row).NewId);
    END LOOP;
    --OK, can we now use our collection in a JOIN statement ?
    SELECT COUNT(SM.NewID)
    INTO v_Count
    FROM SomeTable ST JOIN
    TABLE(CAST(SourceIDMap As IDMap_TAB)) SM
    ON ST.ID = SM.OldID;
    DBMS_OUTPUT.put_line(' ' );
    DBMS_OUTPUT.put_line('v_Count is ' || v_Count);
    END;

    Hi, got this from our plsql guys:
    The term "table function" is a bit confusing here. In Oracle-speak, it means a function that can be used in the from list of a select statement thus:
    select * from Table(My_Table_Function()),..
    where...
    The function's return type must be a collection that SQL understands. So for the interesting case -- mimicking a function with more than one column -- this would be a nested table of ADTs where both the ADT and the nested table are defined at schema level. PL/SQL -- by virtue of some clever footwork -- allows you to declare the type as a nested table of records where both these types are declared in a package spec. This alternative is generally preferred, especially because the nested table can be of Some_Table%rowtype (or Some_Cursor%rowtype if you prefer).
    As I understand it from our man on the ANSI committee, our use terminology follows the standard.
    The construct below seems to be a bit different (though there are similarities) because it appears from your code sample that it's usable only within procedural code. And the object from which you select is a variable rather than a function.
    So, after that preamble... the answer would be:
    No, we don't have any constructs to let you "declare" something that looks like a regular schema-level table as a PL/SQL variable -- and then use (static) SQL on it just as if it were a schema-level table.
    But yes, you can use PL/SQL's pipelined table function to achieve much of the same effect.
    Look at the attached Table_Function.sql.
    It shows that you can populate a collection of records using ordinary PL/SQL code. You can't use SQL for insert, update, or delete on such a collection. I see that SQL Server lets you do
    insert into Program_Variable_Table select... from Schema_Level_Table
    The PL/SQL equivalent would be
    select...
    bulk collect into Program_Variable_Collection
    from Schema_Level_Table
    The attached shows that once you have populated your collection, then you can then query it with regular SQL -- both from inside PL/SQL code and from naked SQL.
    and the code is here
    CONNECT System/p
    -- Drop and re-create "ordinary" user Usr
    EXECUTE d.u
    CONNECT Usr/p
    create table Schema_Things(ID number, Description Varchar2(80))
    create package Pkg is
    subtype Thing_t is Schema_Things%rowtype;
    type Things_t is table of Thing_t; -- index by pls_integer
    Things Things_t;
    -- PLS-00630: pipelined functions must have
    -- a supported collection return type
    -- for "type Things_t is table of Thing_t index by pls_integer".
    function Computed_Things return Things_t pipelined;
    procedure Insert_Schema_Things(No_Of_Rows in pls_integer);
    end Pkg;
    create package body Pkg is
    function Computed_Things return Things_t pipelined is
    Idx pls_integer;
    Thing Thing_t;
    begin
    Idx := Things.First();
    while Idx is not null loop
    pipe row (Things(Idx));
    Idx := Things.Next(Idx);
    end loop;
    end Computed_Things;
    procedure Insert_Schema_Things(No_Of_Rows in pls_integer) is
    begin
    Things := Things_t();
    Things.Extend(No_Of_Rows);
    for j in 1..No_Of_Rows loop
    Things(j).ID := j;
    Things(j).Description := To_Char(j, '00009');
    end loop;
    insert into Schema_Things
    select * from Table(Pkg.Computed_Things());
    end Insert_Schema_Things;
    end Pkg;
    -- Test 1.
    begin Pkg.Insert_Schema_Things(100); end;
    select * from Schema_Things
    -- Test 2.
    begin
    Pkg.Things := Pkg.Things_t();
    Pkg.Things.Extend(20);
    for j in 1..20 loop
    Pkg.Things(j).ID := j;
    Pkg.Things(j).Description := To_Char(j, '00009');
    end loop;
    for j in 1..5 loop
    Pkg.Things.Delete(5 +2*j);
    end loop;
    end;
    select * from Table(Pkg.Computed_Things())
    /

  • XML output from oracle equivalent to sql server

    Hi,
    I need an equivalent sql server 2005 equivalent output from oracle.
    Tried with DBMS_XMLGEN.getxml, xforest etc. But I am not able to get desired output.
    Could anyone help me in giving a hint to do so.
    Here below i am pasting sql server 2005 query and output, oracle query and output.
    SELECT top 5
    P.process_id AS Ppid,
    P.name AS Pn,
    P.group_id AS Pg,
    P.locked AS Pl,
    P.build AS Pb,
    100 AS qcount,
    200 AS ocount,
    PI.question_id AS PIqid,
    PI.process_id AS PIpid,
    PI.posx AS PIpx,
    PI.posy AS PIpy,
    PI.innertext AS PItext,
    PI.itemtype AS PItype,
    PI.linkfrom AS PIfrom,
    PI.linkto AS PIto,
    PI.associated AS PIas,
    PI.content_id AS PIc,
    PI.exitpoint1_id AS PIe1,
    PI.exitpoint2_id AS PIe2,
    PI.exitpoint3_id AS PIe3,
    PI.resolveidentifier AS PIri,
    PI.libquestion_idfk AS PIlqid,
    PI.followoncall AS PIfoc,
    PI.userinput AS PIui,
    PI.isLocked AS PIstls,
    PI.PreviousAnswer as PIPAns,
    PI.VisibleToAgent as PIVAgent,
    PI.RetryAttempt as PIRetry,
    PI.Tags as PITag,
    PO.option_id AS POoid,
    PO.question_id AS POqid,
    PO.process_id AS popid,
    PO.posx AS POpx,
    PO.posy AS POpy,
    PO.opt_innertext AS POtext,
    PO.opt_linkfrom AS POfrom,
    PO.opt_linkto AS POto,
    PO.libquestion_idfk AS POlqid,
    PO.liboption_idfk AS POloid
    FROM
    dbo.processes_ec AS P WITH (nolock) INNER JOIN
    dbo.vw_ProcessesQuestions_Simulator_v6 AS PI WITH (nolock)
    ON P.process_id = PI.process_id LEFT OUTER JOIN
    dbo.vw_ProcessesOptions_Simulator_v6 AS PO WITH (nolock)
    ON PI.question_id = PO.question_id AND PI.process_id = PO.process_id
    ORDER BY Ppid, PIqid, POoid ASC
    FOR XML AUTO, ELEMENTS
    O/P
    <P>
    <Ppid>450</Ppid>
    <Pn>CBB1015 - Router Firewall Settinngs Process</Pn>
    <Pg>9</Pg>
    <Pl>0</Pl>
    <Pb>5</Pb>
    <qcount>100</qcount>
    <ocount>200</ocount>
    <PI>
    <PIqid>1</PIqid>
    <PIpid>450</PIpid>
    <PIpx>366</PIpx>
    <PIpy>-516</PIpy>
    <PItext>CBB1015 - Router Firewall Settinngs Process</PItext>
    <PItype>Title</PItype>
    <PIto>2</PIto>
    <PO />
    </PI>
    <PI>
    <PIqid>2</PIqid>
    <PIpid>450</PIpid>
    <PIpx>366</PIpx>
    <PIpy>-437</PIpy>
    <PItext>Is the customers PC Firewall turned off?</PItext>
    <PItype>Question</PItype>
    <PIfrom>1</PIfrom>
    <PIto>2.2,2.1</PIto>
    <PO>
    <POoid>1</POoid>
    <POqid>2</POqid>
    <popid>450</popid>
    <POpx>-50</POpx>
    <POpy>70</POpy>
    <POtext>Yes</POtext>
    <POto>5</POto>
    </PO>
    <PO>
    <POoid>2</POoid>
    <POqid>2</POqid>
    <popid>450</popid>
    <POpx>50</POpx>
    <POpy>70</POpy>
    <POtext>No</POtext>
    <POto>3</POto>
    </PO>
    </PI>
    <PI>
    <PIqid>3</PIqid>
    <PIpid>450</PIpid>
    <PIpx>468</PIpx>
    <PIpy>-344</PIpy>
    <PItext>Advise the customer to turn off the PC Firewall in order to continue. Has this been done?</PItext>
    <PItype>Question</PItype>
    <PIfrom>2.2</PIfrom>
    <PIto>3.2,3.1</PIto>
    <PIc>278</PIc>
    <PO>
    <POoid>1</POoid>
    <POqid>3</POqid>
    <popid>450</popid>
    <POpx>-50</POpx>
    <POpy>70</POpy>
    <POtext>Yes</POtext>
    <POto>5</POto>
    </PO>
    <PO>
    <POoid>2</POoid>
    <POqid>3</POqid>
    <popid>450</popid>
    <POpx>50</POpx>
    <POpy>70</POpy>
    <POtext>No</POtext>
    <POto>4</POto>
    </PO>
    </PI>
    </P>
    Oracle query and output
    select DBMS_XMLGEN.getxml('select * from (SELECT
    P.process_id AS Ppid,
    P.name AS Pn,
    P.group_id AS Pg,
    P.locked AS Pl,
    P.build AS Pb,
    100 AS qcount,
    200 AS ocount,
    PI.question_id AS PIqid,
    PI.process_id AS PIpid,
    PI.posx AS PIpx,
    PI.posy AS PIpy,
    PI.innertext AS PItext,
    PI.itemtype AS PItype,
    PI.linkfrom AS PIfrom,
    PI.linkto AS PIto,
    PI.associated AS PIas,
    PI.content_id AS PIc,
    PI.exitpoint1_id AS PIe1,
    PI.exitpoint2_id AS PIe2,
    PI.exitpoint3_id AS PIe3,
    PI.resolveidentifier AS PIri,
    PI.libquestion_idfk AS PIlqid,
    PI.followoncall AS PIfoc,
    PI.userinput AS PIui,
    PI.isLocked AS PIstls,
    PI.PreviousAnswer as PIPAns,
    PI.VisibleToAgent as PIVAgent,
    PI.RetryAttempt as PIRetry,
    PI.Tags as PITag,
    PO.option_id AS POoid,
    PO.question_id AS POqid,
    PO.process_id AS popid,
    PO.posx AS POpx,
    PO.posy AS POpy,
    PO.opt_innertext AS POtext,
    PO.opt_linkfrom AS POfrom,
    PO.opt_linkto AS POto,
    PO.libquestion_idfk AS POlqid,
    PO.liboption_idfk AS POloid
    FROM
    processes_ec P INNER JOIN
    vw_ProcessesQuestions_Sim_v6 PI
    ON P.process_id = PI.process_id LEFT OUTER JOIN
    vw_ProcessesOptions_Sim_v6 PO
    ON PI.question_id = PO.question_id AND PI.process_id = PO.process_id
    ORDER BY Ppid, PIqid, POoid ASC) where rownum<=5') from dual
    O/P
    <?xml version="1.0"?>
    <ROWSET>
    <ROW>
    <PPID>450</PPID>
    <PN>CBB1015 - Router Firewall Settinngs Process</PN>
    <PG>9</PG>
    <PL>0</PL>
    <PB>5</PB>
    <QCOUNT>100</QCOUNT>
    <OCOUNT>200</OCOUNT>
    <PIQID>1</PIQID>
    <PIPID>450</PIPID>
    <PIPX>366</PIPX>
    <PIPY>-516</PIPY>
    <PITEXT>CBB1015 - Router Firewall Settinngs Process</PITEXT>
    <PITYPE>Title</PITYPE>
    <PITO>2</PITO>
    </ROW>
    <ROW>
    <PPID>450</PPID>
    <PN>CBB1015 - Router Firewall Settinngs Process</PN>
    <PG>9</PG>
    <PL>0</PL>
    <PB>5</PB>
    <QCOUNT>100</QCOUNT>
    <OCOUNT>200</OCOUNT>
    <PIQID>2</PIQID>
    <PIPID>450</PIPID>
    <PIPX>366</PIPX>
    <PIPY>-437</PIPY>
    <PITEXT>Is the customers PC Firewall turned off?</PITEXT>
    <PITYPE>Question</PITYPE>
    <PIFROM>1</PIFROM>
    <PITO>2.2,2.1</PITO>
    <POOID>1</POOID>
    <POQID>2</POQID>
    <POPID>450</POPID>
    <POPX>-50</POPX>
    <POPY>70</POPY>
    <POTEXT>Yes</POTEXT>
    <POTO>5</POTO>
    </ROW>
    <ROW>
    <PPID>450</PPID>
    <PN>CBB1015 - Router Firewall Settinngs Process</PN>
    <PG>9</PG>
    <PL>0</PL>
    <PB>5</PB>
    <QCOUNT>100</QCOUNT>
    <OCOUNT>200</OCOUNT>
    <PIQID>2</PIQID>
    <PIPID>450</PIPID>
    <PIPX>366</PIPX>
    <PIPY>-437</PIPY>
    <PITEXT>Is the customers PC Firewall turned off?</PITEXT>
    <PITYPE>Question</PITYPE>
    <PIFROM>1</PIFROM>
    <PITO>2.2,2.1</PITO>
    <POOID>2</POOID>
    <POQID>2</POQID>
    <POPID>450</POPID>
    <POPX>50</POPX>
    <POPY>70</POPY>
    <POTEXT>No</POTEXT>
    <POTO>3</POTO>
    </ROW>
    <ROW>
    <PPID>450</PPID>
    <PN>CBB1015 - Router Firewall Settinngs Process</PN>
    <PG>9</PG>
    <PL>0</PL>
    <PB>5</PB>
    <QCOUNT>100</QCOUNT>
    <OCOUNT>200</OCOUNT>
    <PIQID>3</PIQID>
    <PIPID>450</PIPID>
    <PIPX>468</PIPX>
    <PIPY>-344</PIPY>
    <PITEXT>Advise the customer to turn off the PC Firewall in order to continue. Has this been done?</PITEXT>
    <PITYPE>Question</PITYPE>
    <PIFROM>2.2</PIFROM>
    <PITO>3.2,3.1</PITO>
    <PIC>278</PIC>
    <POOID>1</POOID>
    <POQID>3</POQID>
    <POPID>450</POPID>
    <POPX>-50</POPX>
    <POPY>70</POPY>
    <POTEXT>Yes</POTEXT>
    <POTO>5</POTO>
    </ROW>
    <ROW>
    <PPID>450</PPID>
    <PN>CBB1015 - Router Firewall Settinngs Process</PN>
    <PG>9</PG>
    <PL>0</PL>
    <PB>5</PB>
    <QCOUNT>100</QCOUNT>
    <OCOUNT>200</OCOUNT>
    <PIQID>3</PIQID>
    <PIPID>450</PIPID>
    <PIPX>468</PIPX>
    <PIPY>-344</PIPY>
    <PITEXT>Advise the customer to turn off the PC Firewall in order to continue. Has this been done?</PITEXT>
    <PITYPE>Question</PITYPE>
    <PIFROM>2.2</PIFROM>
    <PITO>3.2,3.1</PITO>
    <PIC>278</PIC>
    <POOID>2</POOID>
    <POQID>3</POQID>
    <POPID>450</POPID>
    <POPX>50</POPX>
    <POPY>70</POPY>
    <POTEXT>No</POTEXT>
    <POTO>4</POTO>
    </ROW>
    </ROWSET>
    Any help really appreciated.
    Thanks in advance

    Here are the links ->
    http://www.psoug.org/reference/xml_functions.html
    http://www.psoug.org/reference/dbms_xmlgen.html
    http://www.adp-gmbh.ch/ora/sql/xmlelement.html
    http://www.oracle-base.com/articles/9i/SQLXML9i.php
    http://download.oracle.com/docs/cd/B10500_01/appdev.920/a96620/toc.htm
    Regards.
    Satyaki De

Maybe you are looking for

  • How to switch to older version of final cut pro x from 10.1.2?

    How to switch to previous version of Final cut pro X after once it is updated to 10.1.2?

  • Trying to compile firefox nightly

    I was hoping to do the equivalent of what heftig did for aurora and compile firefox nightly into its own package. First things first is getting the source code to succesfully compile at all before worrying about how its packaged. Here's my PKGBUILD:

  • Adobe Standard 8.1.2  Print Output Challenge

    Greetings! Some (not all!) end-users (clients) have informed me that their printed version of a pdf file contains altered spacing (eg "potato" prints out as "potat o"). One client was kind enough to allow me to run several tests, the most recent of w

  • Error with Early Watch

    Dear Consultants, I start an early watch report, but did not started, when I start it manually, and the background job started it gives me the following: Error: An exception with the type CX_SY_OPEN_SQL_DB occurred, but was neither handled locally, n

  • Want to use external clock for SCTL on myRIO

    Hi people, I'm trying to find a way to get a 2.5 MSPS 16-bit ADC, TI ADS1602, to send data to the myRIO device. Ideally, I want to record bits at 40 MHz in order to get the benefit of the full 2.5 MSPS. I know that I can create an 80 MHz SCTL on the