NATIVE PL SQL with OWB9i

Can we use NATIVE PL-SQL with OWB ?
Is there a performance advantage to use it with OWB.
We work with owb9.0.2. We are going to migrate to owb10g soon.

You may be able to, however I have never done so. I would expect that you can just call native PL/SQL from something like SQL Plus? In that case you may be able to use it in custom functions...
Jean-Pierre

Similar Messages

  • What is the problem with native dynamic sql when counting rows in all table

    what is the problem with native dynamic sql when counting rows in all table?Giving an error "table or view does not exist". Thanks.
    DECLARE
    v_sql_string varchar2(1000);
    v_no_of_rows number;
    BEGIN
    for i in ( select table_name from all_tables )
    loop
    v_sql_string := ' select count(1) from ' || i.table_name;
    dbms_output.put_line( v_sql_string );
    --execute immediate v_sql_string into v_no_of_rows;
    end loop;
    END;

    Usually your problem can be described with 'Who cares'. I mean, for what reason do you do this? I doubt that there's a business need to get 100 % accurate answers for this. Normally such things are used to get a picture about the growth of data.
    Personally I would prefer to have up-to-date statistics for all tables and just query the number of rows from there. Sufficient for me in < 99 % of all cases.
    Just my $ .02...

  • Gcc compiler for native pl-sql (SunOS 5.9)

    Hi All !
    Whether it is possible to use native pl-sql compilation on platform Solaris 9 with the compiler gcc? I Have established gcc version 3.3.2
    At compilation of a package I receive a error: (Warning) PLS-00923: native compilation failed: make:spdtexmk:?

    Although the configuration is certified not all new 9i features are supported with previous versions of Oracle.
    In order for result set to work you will require Oracle v9i.

  • Using Native Dynamic SQL in Forms

    Can Native Dynamic SQL be used in Forms 5.0 or Forms 6.0? (Database 8.1.6.0.0)
    I have tried the following code (examples below) from the PL/SQL User's Guide and Reference Release 8.1.6 and the Metalinks Note: 62592.1 and the trigger/procedure (in Forms) will not compile. I appreciate any help given.
    Example1:
    (I have a table named temp_jane with a column named companies and a value 'Hello'. When compiling, I receive the error: 'Error 103 at line 8, column 11 Encountered the symbol ''IMMEDIATE" when expecting one of the following :=.(@%; ')
    declare
    str varchar2( 200 );
    val varchar2( 20 );
    ret temp_jane%rowtype;
    begin
    str := 'select company from temp_jane where company = :b1';
    val := 'Hello';
    execute immediate str into ret using val;
    message('Value fetched from table: '&#0124; &#0124;ret.company);
    end;
    Example2:
    (Here is the real issue, I don't know what the select statement, so I need to be able to assign a variable. When compiling, I receive the error: 'Error 103 at line 28, column 21 Encountered the symbol "VSQLSTATEMENT" when expecting one of the following: select ').
    declare
    type ItemsControlCurTyp is ref cursor;
    ItemsCur ItemsControlCurTyp;
    ItemsRec Items%rowtype;
    vSQLStatement varchar2( 5000 );
    vExecuteSQL varchar2( 5000 );
    vNumRows integer;
    vValue varchar2( 2000 );
    vFirstOne varchar2( 1 ) := 'Y';
    vRetval varchar2( 2000 );
    begin
    -- Display the column prompts with the right text.
    set_item_property( 'ITEMS_AVAILABLE.NDB_VALUE', PROMPT_TEXT, :ITEMS_CONTROL.AVAILABLE_LABEL );
    set_item_property( 'ITEMS_CHOSEN.NDB_VALUE', PROMPT_TEXT, :ITEMS_CONTROL.CHOSEN_LABEL );
    -- Save the original version of CHOSEN_STRING in case the user reverts or cancels.
    :ITEMS_CONTROL.CHOSEN_STRING_ORIG := :ITEMS_CONTROL.CHOSEN_STRING;
    vSQLStatement := :ITEMS_CONTROL.SELECT_STATEMENT;
    vExecuteSQL := vSQLStatement;
    -- Open the cursor
    open ItemsCur for vSQLStatement;

    Hi JTaylor
    You cannot use NDS in Client side (Developer). You have to use DBMS_SQL only.
    Regards
    A K Srinivasan
    Oracle.

  • Workaround for opening a strongly typed cursor using native dynamic SQL

    Hi All,
    In reading the PL/SQL documentation for Oracle 9i, I noted that the OPEN-FOR
    statement with a dynamic SQL string only allows the use of weakly typed cursors.
    I have verified this limitation with my own experimentation as follows:
    DECLARE
    type rec_type is record(
    str     varchar2(40),
    num     number(22)
    type cur_type is ref cursor return rec_type;
    my_cur     cur_type;
    que     varchar2(100);
    tab     varchar2(40);
    BEGIN
    tab := 'dynamic_table_name';
    que := 'select key_name, key_value from ' || tab || ' where key_name like ''01%''';
    open my_cur for que;
    loop
    if my_cur%found then
    dbms_output.put_line('source_name: ' || my_cur.str || ', page_sn: ' || my_cur.num);
    exit;
    end if;
    end loop;
    close my_cur;
    END;
    Running the above trivial example in an anonymous sql block yields the following
    errors as expected:
    ORA-06550: line 10, column 8:
    PLS-00455: cursor 'MY_CUR' cannot be used in dynamic SQL OPEN statement
    ORA-06550: line 10, column 3:
    PL/SQL: Statement ignored
    ORA-06550: line 13, column 54:
    PLS-00487: Invalid reference to variable 'MY_CUR'
    ORA-06550: line 13, column 7:
    PL/SQL: Statement ignored
    Is there a workaround to the situation? Since I do not know the table name at run
    time, I must use Native Dynamic SQL. I have a long and complex record type
    that I wish to return through JDBC using the REFCURSOR Oracle type in order to
    avoid having to register an inordinate number of OUT parameters. Moreover, I
    would like to return potentially one or more results in a ResultSet. Using the
    standard method of registering native SQL types for the IN and OUT bindings
    can only return one result. Hence the reason I would like to return a strong
    cursor type. Also, the type of query I am doing is complex, and needs to be
    executed in a PL/SQL procedure for performance reasons. Therefore simply
    executing a SELECT query dynamically built up on the the JDBC client won't
    do the trick.
    If anybody has experience with a similar problem and would like to volunteer
    information on their workaround, I would really appreciate it.
    Best Regards,
    J. Metcalf

    We can use strongly-typed REF CURSORs in DNS, but the typing derives from a table e.g.
    TYPE EmpCurTyp IS REF CURSOR RETURN emp%ROWTYPE;
    so the problem is your use of "return rec_type" bit.
    Forgive my bluntness but I think you have misunderstood strong and weak typing. You actually want to be using weakly-typed cursors. I mean this:
    Moreover, I would like to return potentially one or more results in a ResultSet. suggests that the structure of your resultset may vary, which is precisely what a weakly-typed ref cursor allows us to do. Then we can use the JDBC metadata methods to interrogate the structure of the resultset, innit.
    so try this:
    DECLARE
    type cur_type is ref cursor;
    my_cur cur_type;
    que varchar2(100);
    tab varchar2(40);
    BEGIN
    tab := 'dynamic_table_name';
    que := 'select key_name, key_value from ' || tab || ' where key_name like ''01%''';
    open my_cur for que;
    loop
    if my_cur%found then
    dbms_output.put_line('source_name: ' || my_cur.str || ', page_sn: ' || my_cur.num);
    exit;
    end if;
    end loop;
    close my_cur;
    END;
    ras malai, APC
    Cheers, APC

  • Alternative to native, dynamic sql to return a ref cursor to a client

    I'm on Oracle 8.0.4, and would like to pass a string of values like '1,2,7,100,104' that are the primary key for a table. Then use something like:
    procedure foo( MyCur RefCurType, vKey varchar2)
    begin
    open MyCur for
    'select names from SomeTable' &#0124; &#0124;
    ' where ID in (' &#0124; &#0124; vKey &#0124; &#0124; ')'
    end;
    This would return a recordset to (in this case) a Crystal Reports report.
    However, native dynamic SQL ain't available until 8.1.0. So can anyone think of a clever way to accomplish this, with a way to return a cursor? I can't figure out how to do this with DBMS_SQL, because open_cursor is just returning a handle, not a referene to a cursor that can be passed to a remote client.
    Thanks in advance.

    I'm on Oracle 8.0.4, and would like to pass a string of values like '1,2,7,100,104' that are the primary key for a table. Then use something like:
    procedure foo( MyCur RefCurType, vKey varchar2)
    begin
    open MyCur for
    'select names from SomeTable' &#0124; &#0124;
    ' where ID in (' &#0124; &#0124; vKey &#0124; &#0124; ')'
    end;
    This would return a recordset to (in this case) a Crystal Reports report.
    However, native dynamic SQL ain't available until 8.1.0. So can anyone think of a clever way to accomplish this, with a way to return a cursor? I can't figure out how to do this with DBMS_SQL, because open_cursor is just returning a handle, not a referene to a cursor that can be passed to a remote client.
    Thanks in advance.

  • Native PL/SQL compilation

    Hi -
    Does anyone have native PL/SQL compilation working correctly on their Linux server?
    It is reasonably easy to deduce suitable values for the init.ora parameters "plsql_...." .
    I suspect the problem is with the make file: spnc_makefile.mk .
    The supplied make file:
    $ORACLE_HOME/plsql/spnc_makefile.mk
    does not work, throwing an internal error:
    PLS-00801: internal error [79704]
    I have read the article on OTN concerning upgrading the entire database to native PL/SQL. It is very helpful, but unfortunately does not solve the problem.
    Can anyone help? Thanks.
    Bryan Genet

    Hi
    try
    --RN 24.3.2003, PL/SQL mit native execution
    -- Example in PL/SQL Users Guide and Reference, Kap. 12, Tuning PL/SQL
    -- SuSE 8.0, oracle 9.2.0.1 using spfile
    -- ORACLE_HOME /oracle/ORA92
    alter system set plsql_native_library_dir='/opt/oracle/native_lib';
    -- here you'll find the shared librarys
    alter system set plsql_native_make_utility='gmake';
    -- a normal make/gmake will work?
    alter system set plsql_native_make_file_name='/oracle/ORA92/plsql/spnc_makefile.mk';
    alter session set plsql_compiler_flags='NATIVE';
    set serveroutput on;
    set timing on
    create or replace procedure with_native
    as
    erg number;
    begin
    for i in 1..1000000 loop
    erg := mod(i,4711);
    end loop;
    dbms_output.put_line(to_char(erg));
    end;
    show errors
    execute with_mitnative
    prompt "NATIVE"
    alter session set plsql_compiler_flags='INTERPRETED';
    create or replace procedure without_native
    as
    erg number;
    begin
    for i in 1..1000000 loop
    erg := mod(i,4711);
    end loop;
    dbms_output.put_line(to_char(erg));
    end;
    -- show errors
    execute witout_native
    prompt "INTERPRETED"
    regards
    Roman

  • If..then..else statement in SQL with 'generalized' conditions in the if sta

    it is possible to write something approaching an if..then..else statement in SQL with 'generalized' conditions in the if statement.
    Attached is the query for the payment register, in which I've written a series of decode statements, one for each possible value of the payment code. The query works OK - however, its specific and as the number of paycodes expand (and they do), the report won't pick up the new paycode until the code is changed. More importantly, the report won't be correct until someone 'discovers' that a paycode is missing, which might take months.
    If I were writing the equivalent of this series of decode statements in Focus, it would be something like this:
    DEFINE.......
    PAYMED/D12.2 = IF PAYMENT_CD LE 18
                   THEN PAYMENT_AMT
                   ELSE 0 ;
    PAYIND/D12.2 = IF PAYMENT_CD GE 19 AND PAYMENT_CD LE 49
                   THEN PAYMENT_AMT
                   ELSE 0 ;
    PAYEXP/D12.2 = IF PAYMENT_CD GE 70
                   THEN PAYMENT_AMT
                   ELSE 0 ;
    PAYREC/D12.2 = IF PAYMENT_CD GE 50 AND PAYMENT_CD LE 69
                   THEN PAYMENT_AMT
                   ELSE 0;
    END
    IN SQL/PLUS:
    SELECT ACCOUNT_NAME,
    LOCATION_1,
    CLMNT_LAST_NAME,
    CLAIM_NBR,
    DATE_OF_INJURY,
    DATE_CHECK_REGISTER,
    PAYEE_NAME_1,
    PAYMENT_CD,
    SERV_OFC,
    CPO_CHECK_NBR,
    PAYMENT_FORM,
    DECODE(PAYMENT_CD, 20, PAYMENT_AMT, 21, PAYMENT_AMT,
    22, PAYMENT_AMT, 23, PAYMENT_AMT, 25, PAYMENT_AMT,
    26, PAYMENT_AMT, 27, PAYMENT_AMT, 28, PAYMENT_AMT,
    29, PAYMENT_AMT, 30, PAYMENT_AMT, 31, PAYMENT_AMT,
    32, PAYMENT_AMT, 33, PAYMENT_AMT, 34, PAYMENT_AMT,
    35, PAYMENT_AMT, 36, PAYMENT_AMT, 37, PAYMENT_AMT,
    39, PAYMENT_AMT, 40, PAYMENT_AMT, 41, PAYMENT_AMT,
    42, PAYMENT_AMT, 43, PAYMENT_AMT, 44, PAYMENT_AMT,
    45, PAYMENT_AMT, 46, PAYMENT_AMT, 47, PAYMENT_AMT,
    48, PAYMENT_AMT, 49, PAYMENT_AMT, NULL) INDEMNITY,
    DECODE(PAYMENT_CD, 0, PAYMENT_AMT, 1, PAYMENT_AMT,
    2, PAYMENT_AMT, 3, PAYMENT_AMT, 4, PAYMENT_AMT,
    5, PAYMENT_AMT, 6, PAYMENT_AMT, 7, PAYMENT_AMT,
    8, PAYMENT_AMT, 9, PAYMENT_AMT, 10, PAYMENT_AMT,
    11, PAYMENT_AMT, 12, PAYMENT_AMT, 13, PAYMENT_AMT,
    14, PAYMENT_AMT, 15, PAYMENT_AMT, 18, PAYMENT_AMT,
    17, PAYMENT_AMT, NULL) MEDICAL,
    DECODE(PAYMENT_CD, 70, PAYMENT_AMT, 71, PAYMENT_AMT,
    72, PAYMENT_AMT, 73, PAYMENT_AMT, 74, PAYMENT_AMT,
    75, PAYMENT_AMT, 76, PAYMENT_AMT, 77, PAYMENT_AMT,
    78, PAYMENT_AMT, 79, PAYMENT_AMT, 80, PAYMENT_AMT,
    81, PAYMENT_AMT, 82, PAYMENT_AMT, 83, PAYMENT_AMT,
    84, PAYMENT_AMT, 85, PAYMENT_AMT, 86, PAYMENT_AMT,
    87, PAYMENT_AMT, 88, PAYMENT_AMT, 89, PAYMENT_AMT,
    90, PAYMENT_AMT, NULL) EXPENSES,
    DECODE(PAYMENT_CD, 50, PAYMENT_AMT, 51, PAYMENT_AMT,
    52, PAYMENT_AMT, 53, PAYMENT_AMT, 54, PAYMENT_AMT,
    55, PAYMENT_AMT, 56, PAYMENT_AMT, 57, PAYMENT_AMT,
    58, PAYMENT_AMT, NULL) RECOVERIES,
    DECODE(PAYMENT_FORM, 'N', PAYMENT_AMT, NULL) NONCASH,
    DATE_FROM_SERVICE,
    DATE_THRU_SERVICE
    FROM &INPUT_TABLES
    WHERE &SECURITYCOND
    DATE_OF_PAYMENT BETWEEN :START_DATE AND :END_DATE
    ORDER BY LOCATION_1, CPO_CHECK_NBR
    As you can see, this is both much easier to write and covers the possibility of expansion of paycodes (expansions always fit in these defined ranges).
    My question is, then, is it possible to write something like this in SQL and, if so, could you give me some sample code? (I'm one of those people who learn best from looking at the code as opposed to a set of instructions)

    Here is one way you could do it.
    Create a table that has columns like:
    Payment_code varchar2(2),
    Effective_Date Date,
    Payment_type varchar2(20),
    Expiration_Date Date)
    Payment type for example could be
    I- indemnity
    M- medical
    R- recovery
    E- expenses
    Let the table name for example be PAYMENT_CODE.
    The select query would look like
    SELECT ACCOUNT_NAME,
    LOCATION_1,
    CLMNT_LAST_NAME,
    CLAIM_NBR,
    DATE_OF_INJURY,
    DATE_CHECK_REGISTER,
    PAYEE_NAME_1,
    PAYMENT_CD,
    SERV_OFC,
    CPO_CHECK_NBR,
    PAYMENT_FORM,
    DECODE(p.payment_type,'E',PAYMENT_AMOUNT,0) expenses,
    DECODE(p.payment_type,'I',PAYMENT_AMOUNT,0) indemnity,
    DECODE(p.payment_type,'M',PAYMENT_AMOUNT,0) Medical,
    DECODE(p.payment_type,'R',PAYMENT_AMOUNT,0) recoveries,
    DECODE(PAYMENT_FORM, 'N', PAYMENT_AMT, NULL) NONCASH
    FROM &INPUT_TABLES,
    PAYMENT_CODE P
    WHERE P.PAYMENT_CODE = SOMEINPUT_TABLE.PAYMENT_CODE
    and other conditions
    The idea is to group all the payment codes into a few groups to reduce the clutter. If there is ever a change to the payment code, you could modify the table and it will be reflected in your select query.

  • Problem in SQL with CURSOR( ) ,Why the CURSOR did not work?

    hi All:
    I have a problem in SQL with CURSOR.
    The data is as the attachments.
    Here is the SQL statement as follow:
    SELECT A.WADCTO,A.WADOCO,B.IGCOST,CURSOR (SELECT X.IGLITM
    FROM F3102 X
    WHERE X.IGDOCO=A.WADOCO
    AND X.IGCOST IN ('B1','D1','C3')) AS DETAIL
    FROM F4801 A INNER JOIN F3102 B ON A.WADOCO=B.IGDOCO AND A.WADCTO=B.IGDCTO AND B.IGCOST>' '
    WHERE A.WADOCO='10004'
    The statement above returns records as follow:
    WADC WADOCO IGCOST DETAIL
    WO 10004 A1 CURSOR STATEMENT : 4
    CURSOR STATEMENT : 4
    IGLITM
    1KV90CPG2
    1KV90CPG2
    1KV90CPG2
    But, after I add one statement in the subquery, there is no record returned from CURSOR.
    Here is the SQL statement:
    SELECT A.WADCTO,A.WADOCO,B.IGCOST,CURSOR (SELECT X.IGLITM
    FROM F3102 X
    WHERE X.IGDOCO=A.WADOCO
    AND X.IGCOST=B.IGCOST
    AND X.IGCOST IN ('B1','D1','C3')) AS DETAIL
    FROM F4801 A INNER JOIN F3102 B ON A.WADOCO=B.IGDOCO AND A.WADCTO=B.IGDCTO AND B.IGCOST>' '
    WHERE A.WADOCO='10004'
    The statement above returns records as follow:
    WADC WADOCO IGCOST DETAIL
    WO 10004 A1 CURSOR STATEMENT : 4
    CURSOR STATEMENT : 4
    no rows selected
    Why the CURSOR did not work?
    The database version is Oracle Database 10g Release 10.2.0.4.0 - 64bit Production.
    F3102 DATA:
    IGDOCO     IGDCTO     IGLITM     IGCOST
    10004     WO     1KV90CPG2      A1
    10004     WO     1KV90CPG2      B1
    10004     WO     1KV90CPG2      C3
    10004     WO     1KV90CPG2      D1
    F4801 DATA:
    WADCTO     WADOCO
    WO     10004
    Edited by: user2319139 on 2010/3/2 上午 1:17
    Edited by: user2319139 on 2010/3/2 上午 1:20

    Why this structure and not a join?
    The cursor() function returns a cursor handle that needs to be processed - in other words, the client needs to fetch data from it. The Oracle® Database SQL Reference+ (http://download.oracle.com/docs/cd/B19306_01/server.102/b14200/expressions005.htm#i1035107) describes it as being equivalent to a ref cursor handle.
    Thus why are you creating ref cursor handles as a column in a SQL projection - where each row will have a "+nested+" ref cursor handle to process. What problem are you attempting to hack solve this way?

  • How to reduce different versions of SQL with bind variables

    There is an application, developed on Java.
    Application executes SQL following types:
    select * from t where id in (:1)
    select * from t where id in (:1, :2)
    select * from t where id in (:1, :2, :3)
    select * from t where id in (:1, :2, :3, :4)
    ...And as a result very many versions (thousands) of similar SQL.
    Do you know a method to reduce number of such SQLs?
    I see one method: use one form of SQL with large number of prepared bid variables.
    Like as
    select * from t where id in (:1, :2, :3, :4, :5, :6, :7, :8, ...);And if query will be executed with one variable, the others will be equal to null.
    Is there another method?

    Cannot you insert those values into a temporary table and work within a subquery against that table ? That will make the code more secure, especially if the number of values is high.
    Nicolas.

  • Integrating PL/SQL with Perl

    Hello All,
    I have just started learning PL/SQL and this my first R&D stuff with PL/SQL :)
    I have a very basic beginner question.
    Suppose I want to insert 1 lakh rows in a table through Perl. One and easiest way to do is to prepare and execute insert queries using Perl module - 'DBI' module in a loop
    But I guess this will send lot of traffic over the LAN. What I rather feel is that if I execute these 1 lakh SQL queries using PL/SQL it will be comparatively more network efficient and fast.
    So I have following questions:
    1. Is it possible to integrate PL/SQL with Perl using 'DBI' module
    2. Is there a way in PL/SQL that it will return status of all the 1 Lakh SQL queries after execution that will let me know which SQL queries were successfully executed and which failed.

    1. Is it possible to integrate PL/SQL with Perl using 'DBI' moduleyes, just use a PL/SQL statement instead of a sql one
    2. Is there a way in PL/SQL that it will return status of all the 1 Lakh SQL queries after execution that will let me know which SQL queries were successfully executed and which failed.yes, you have to manage an exception block for each row and store the single row result in a cumulative variable:
    The following code is an incomplete and not testet example:
    my $STM = "
    declare
    ret varchar2(10);
    begin
      begin
        insert into mytab values(1);
        ret := ret||'0';
      exception
        when others then
          ret:=ret||'1';
      end;
      begin
        insert into mytab values(2);
        ret := ret||'0';
      exception
        when others then
          ret:=ret||'1';
      end;
    ... and so on ...
      select ret into :OUTRES from dual;
    end;";
    my $outres;
    my $hnd = $db->prepare($STM);
    $hnd->bind_param_inout( ":OUTRES", \$outres, 10);  -- 10 is the variable length, e.g. the number of inserts
    $hnd->execute();
    print "inserts output: $outres\n";At the end of the script you should hava a string of bits. A 0 for each successful insert an 1 for each unsuccessful...
    Max
    [My Italian Oracle blog|http://oracleitalia.wordpress.com/2010/01/10/crittografia-in-plsql-utilizzando-dbms_crypto/]

  • Learning PL/SQL with SQL plus

    I'm looking to teach myself PL/SQL with SQL Plus, it's a works pc so I can not use any other software than SQL plus.
    When starting SQL plus I'm asked for a username, password and host string.
    I'm taking it the host string is the db I want to connect to and obviously supply the username and password for level of access?
    Also what I ideally need is a sample db on my local machine to connect to with SQL plus to learn that way.
    Can anyone point me in the right direction please. Any help is greatly appreciated.

    Use the net8 configuration assistant preferably as it'll get the syntax correct.
    Otherwise you copy the sample one up one folder and edit that.
    Connection information (SID, Server/IP, port number) you'll have to get off your DBA.
    The name at the start of a tnsnames entry is the name that you want to reference the database as, so you can call it FRED if you like.
    e.g.
    FRED =
      (DESCRIPTION =
        (ADDRESS_LIST =
          (ADDRESS =
            (PROTOCOL = TCP)
            (HOST = <server name or ip address>)
            (PORT = <port>) -- usually 1521 but can differ if more than one instance on the server
        (CONNECT_DATA =
          (SID = <database SID>) -- the name of the database on the server.
      )Once that's set up you can then log onto the database in the following way:
    sqlplus <user>/<password>@fred
    What happens is that the TNS Listener service (that should be running on your PC) will look up "fred" in the tnsnames.ora file and then use the information from that to make the connection to the server on the correct port and connect you to the actual database on there.
    After that.... it's up to you.
    :)

  • Tuning sql with analytic function

    Dear friends I've developed one sql :
    with REP as
    (select /*+ MATERIALIZE */ branch_code,
       row_number() over(partition by branch_code, account order by bkg_date desc  ) R,
             account,
             bkg_date,
             lcy_closing_bal
        from history t
    select REP1.branch_code,
           REP1.account,
           REP1.bkg_date,
           REP1.lcy_closing_bal,
             NULL  AS second,
           REP2.bkg_date        bkg_date2,
           REP2.lcy_closing_bal lcy_closing_bal2,
            NULL  AS third,
           REP3.bkg_date        bkg_date3,
           REP3.lcy_closing_bal lcy_closing_bal3
      from (SELECT * FROM REP WHERE R=1) REP1, (SELECT * FROM REP WHERE R=2) REP2, (SELECT * FROM REP WHERE R=3) REP3
    where
           (REP1.BRANCH_CODE = REP2.BRANCH_CODE(+) AND REP1.ACCOUNT = REP2.ACCOUNT(+)) AND
           (REP1.BRANCH_CODE = REP3.BRANCH_CODE(+) AND REP1.ACCOUNT = REP3.ACCOUNT(+))The point is I want to restrict (tune) REP before it used ,because , as you can see I need maximum three value from REP (where R=1,R=2,R=3) . Which analytic function and with wich options I have to use to receive only 3 values in each branch_code,account groups at the materializing time ?

    Radrigez wrote:
    Dear friends I've developed one sql :
    with REP as
    from (SELECT * FROM REP WHERE R=1) REP1,
    (SELECT * FROM REP WHERE R=2) REP2,
    (SELECT * FROM REP WHERE R=3) REP3
    where
    (REP1.BRANCH_CODE = REP2.BRANCH_CODE(+) AND REP1.ACCOUNT = REP2.ACCOUNT(+)) AND
    (REP1.BRANCH_CODE = REP3.BRANCH_CODE(+) AND REP1.ACCOUNT = REP3.ACCOUNT(+))
    The first step is to put your subquery (which doesn't need to be materialized) into an inline view and restrict the result set on r in (1,2,3) as suggested by thtsang - you don't need to query the same result set three times.
    Then you're looking at a simple pivot operation (assuming the number of rows you want per branch and account is fixed). If you're on 11g search the manuals for PIVOT, on earlier versions you can do this with a decode() or case() operator.
    Step 1 (which could go into another factored subquery) would be something like:
    select
            branch_code, account,
            case r = 1 then bkg_date end bkg_date,
            case r = 1 then lcy_closing_bal end lcy_closing_bal,
            case r = 2 then bkg_date end bkg_date2,
            case r = 2 then lcy_closing_bal end lcy_closing_bal2,
            case r = 3 then bkg_date end bkg_date3,
            case r = 3 then lcy_closing_bal end lcy_closing_bal3
    from
            repThis gives you the eight necessary columns, but still (up to) three rows per branch/account.
    Then you aggregate this (call it rep1) on branch and account.
    select
            branch_code, account,
            max(bkg_date),
            max(lcy_closing_bal),
            max(bkg_date2),
            max(lcy_closing_bal2),
            max(bkg_date3),
            max(lcy_closing_bal3)
    from
            rep1
    group by
            branch_code, account
    order by
            branch_code, accountRegards
    Jonathan Lewis
    http://jonathanlewis.wordpress.com
    Author: <b><em>Oracle Core</em></b>

  • Can a SQL WITH Clause be used in Materialized View

    Hello,
    Can we use SQL WITH clause in Materialized View.
    Thanks

    Hello,
    Here is an example
    CREATE MATERIALIZED VIEW MV_TEST
    BUILD IMMEDIATE
    REFRESH FORCE ON DEMAND
    AS
    WITH t AS (SELECT owner, object_type, COUNT ( * )
               FROM my_objects
               GROUP BY object_type, owner)
    SELECT *
    FROM t
    WHERE owner IN ('SYS', 'SYSTEM');Regards

  • [1.1.2.25.79] Program hangs after starting long runnin SQL with parameters

    Hello Forum,
    I'm currently tuning some SQLs with parameters that run some minutes. When I enter the SQL in the worksheet and press F9, SQL Developer asks for the parameters. But after clicking "Apply" (or whatever it is called in the english version, I'm using german ;-)
    I get the elapsed time of 0.018 seconds displayed and the whole program hangs until the SQL is completed. The elapsed time is not updated so I don't get the real elapsed time.
    I run SQL Developer against an Oracle 9.2 Database on Win2k. The client runs WinXP.
    I hope this is not a double post but searching the forum for "parameters" gave too many hits to check. ;-)
    Regards,
    dhalek

    Sqldev hangs when issuing an action that requires the previous action to be completed first.
    Sqldev could open a new connection for this, or at least display a message telling the action isn't possible until the previous one completes, instead of just hanging. Vote for the requests for this on the SQL Developer Exchange if you want this getting addressed sooner.
    Thanks,
    K.

Maybe you are looking for

  • Saving Sessions 100% Correctly For Launching On Another Computer

    Hi, I have GB 2.02. On Mac OS 10.4.11. PowerBook G4 17". I have made a few songs, some have actual recorded audio in them, some have samples, and some of course have the midi stock sounds in them. What I was wondering is, where the heck are all these

  • Can we enable Info Objects as input in the Input Ready Query...

    Hi Folks, As I wanted to implement Input Ready Query for Planning in which User has to enter Charactersitc Values apart from Keyfigures. Per Example:- Project Number and Budget are Fields in Input ready query. Here user wanted to enter Project Number

  • p tags with attributes not removed from JTextPane

    We are using HTMLEditorKit with JtextPane to create a HTML Document Editor, for our project. [JDK 1.3.1.] When we have a simple <p> tag for paragraph in HTML and we start deleting things from end of the document, it works fine. But when we have a <P>

  • Fehler beim WMI-Anbieter für den Berichtsserver: Ungültiger Namespace

    hi the following error comes up in, sql2012, & sharepoint 2010, in centraladmin > Reporting Services-Integration for SSRS use i try to set up a new "Reporting Services Integration" always the following error comes up! Fehler beim WMI-Anbieter für den

  • Developer6i on Redhat7.2 (openmotif-2.1.30-5_ICS)

    Hi there, I am trying to install Developer 6i on RedHat 7.1 and openmotif-devel-2.1.30-5_ICS openmotif-2.1.30-5_ICS I obtain the following message during relinking: ------------ Start of Message --------------------------- /usr/X11R6/lib/libXt.so: un