View calling SQL query in procedure

Hi,
is it possible to see in SQL procedure the SQL query, which calls this procedure? I want to log that SQL when some error occurs.
Thanks
SASA

I'll be interested to see if anyone has an easy solution to this. Here's a function that will get all the currently open cursors but that's not quite the solution ...
create or replace function f
    return varchar2 is
    v_sql_text varchar2(32767);
begin
    for rec in (
        select v$sqltext_with_newlines.sql_text
        into v_sql_text
        from v$open_cursor,
            v$sqltext_with_newlines
        where v$open_cursor.address = v$sqltext_with_newlines.address
            and v$open_cursor.hash_value = v$sqltext_with_newlines.hash_value
            and v$open_cursor.sid = (
                select sid
                from v$mystat
                where rownum = 1)
            and (v$open_cursor.address, v$open_cursor.hash_value) != (
                select sql_address,
                    sql_hash_value
                from v$session
                where sid = (
                    select sid
                    from v$mystat
                    where rownum = 1))
        order by v$sqltext_with_newlines.address,
            v$sqltext_with_newlines.piece
        ) loop
        v_sql_text := v_sql_text || rec.sql_text;
    end loop;
    return v_sql_text;
end;

Similar Messages

  • How to view the sql query?

    hi,
      how to view the sql query formed from the xml structure in the receiver jdbc?

    You can view SAP Note at
    http://service.sap.com/notes
    But you require SMP login ID for this which you should get from your company. The content of the notes are as follows:
    Reason and Prerequisites
    You are looking for additional parameter settings. There are two possible reasons why a feature is available via the "additional parameters" table in the "advanced mode" section of the configuration, but not as documented parameter in the configuration UI itself:
    Category 1: The parameter has been introduced for a patch or a SP upgrade where no UI upgrade and/or documentation upgrade was possible. In this case, the parameter will be moved to the UI and the documentation as soon as possible. The parameter in the "additional parameters" table will be deprecated after this move, but still be working. The parameter belongs to the supported adapter functionality and can be used in all, also productive, scenarios.
    Category 2. The parameter has been introduced for testing purposes, proof-of-concept scenarios, as workaround or as pre-released functionality. In this case, the parameter may or may not be moved to the UI and documentation, and the functionality may be changed, replaced or removed. For this parameter category there is no guaranteed support and usage in productive scenarios is not supported.
    When you want to use a parameter documented here, please be aware to which category it belongs!
    Solution
    The following list shows all available parameters of category 1 or 2. Please note:
    Parameter names are always case-sensitive! Parameter values may be case-sensitive, this is documented for each parameter.
    Parameter names and values as documented below must be used always without quotaton marks ("), if not explicitly stated otherwise.
    The default value of a parameter is always chosen that it does not change the standard functionality
    JDBC Receiver Adapter Parameters
    1. Parameter name: "logSQLStatement"
                  Parameter type: boolean
                  Parameter value: true for any string value, false only for empty string
                  Parameter value default: false (empty String)
                  Available with: SP9
                  Category: 2
                  Description:
                  When implementing a scenario with the JDBC receiver adapter, it may be helpful to see which SQL statement is generated by the JDBC adapter from the XI message content for error analysis. Before SP9, this can only be found in the trace of the JDBC adapter if trace level DEBUG is activated. With SP9, the generated SQL statement will be shown in the details page (audit protocol) of the message monitor for each message directly.
                  This should be used only during the test phase and not in productive scenarios.
    Regards,
    Prateek

  • How to view the sql query generated in query designer..?

    Hi experts,
       Can i view the sql query generated by the query designer for a query in sap bw?
    regards,
    ksvsivam

    Hi Sivam,
    You can definitely view the sql query.
    Go to RSRT and give the report name. Then goto Execute+Debug and click on it.
    A new window will open, there tick the box  Display SQL/BIA Query and the press on the ok button.
    Finally click on execute. The Sql query will be displayed.
    Hope this helps.
    Thanks,
    Rahul

  • Creating logical view using sql query

    hi
    i'm new in OBIEE,
    would like to know if its possible to create a custom view (logical table) by writing a sql query (without use the existing tables in the business model).
    how can i do that? i didnt find the place where i can write the sql manually...
    thanks

    Not in BMM layer but you can achieve this in Physical layer.
    In physical layer --> Create New Physical Table --> select table type as Select

  • FIFO in pl/sql query or procedure

    Hi,
    I have two tables:
    1)Table of recieved items
    create table receipts
    (item_id number(5),
    recieved_date date,
    recieved_quantity number,
    receipt_id number(5));
    insert into receipts(item_id, recieved_date, recieved_quantity, receipt_id)
    values(668, '29/12/10', 400, 441);
    insert into receipts(item_id, recieved_date, recieved_quantity, receipt_id)
    values(668, '29/12/10', 100, 442);
    insert into receipts(item_id, recieved_date, recieved_quantity, receipt_id)
    values(668, '03/02/11', 150, 444);2)Table of sold items
    create table deliveries
    (item_id number(5),
    delivered_date date,
    delivered_quantity number,
    delivery_id number(5));
    insert into deliveries(item_id, delivered_date, delivered_quantity, delivery_id)
    values(668, '01/02/11', 10, 1301);
    insert into deliveries(item_id, delivered_date, delivered_quantity, delivery_id)
    values(668, '02/02/11', 450, 1303);
    insert into deliveries(item_id, delivered_date, delivered_quantity, delivery_id)
    values(668, '08/02/11', 15, 1305);
    insert into deliveries(item_id, delivered_date, delivered_quantity, delivery_id)
    values(668, '09/02/11', 90, 1306);I need to track down from which batch goods are taken (for each delivery) using FIFO method.
    FIFO priorities are RECIEVED_DATE, RECEIPT_ID for INs and DELIVERED_DATE, DELIVERY_ID for OUTs.
    Desired output should be something like this:
    {noformat}
    ITEM_ID          DELIVERED_DATE  DELIVERED_QUANTITY      DELIVERY_ID     FROM_RECEIPT    STOCK_QUANTITY(*)
    668          01/02/11     10               1301          441          390
    668          02/02/11     390(**)               1303          441          0
    668          02/02/11     60(**)               1303          442          40
    668          08/02/11     15               1305          442          25
    668          09/02/11     25(**)               1306          442          0
    668          09/02/11     65(**)               1306          443          85
    {noformat}(*)Where STOCK_QUANTITY is the remaining quantity from that batch at the moment after according delivery amount deduction.
    (**)If the delivery gets the goods from different batches, the row should be split to display the amount taken from each batch.
    How can I make pl/sql query/procedure to track down this?
    Any help is very appreciated.
    DB version is: Oracle Database 11g Enterprise Edition Release 11.1.0.6.0
    Thank you,
    Nikita

    Hi, Nikita,
    Thanks for posting the CREATE TABLE and INSERT statements; that's very helpful.
    Use the analytic SUM functuion to get a running total of how much has been receeived and delivered to date. I did this in the sub-queries deliveries_rt and reciepts_rt:
    WITH     receipts_rt     AS
         SELECT     item_id
         ,     received_date
         ,     received_quantity
         ,     SUM (received_quantity) OVER ( PARTITION BY  item_id
                                        ORDER BY          received_date
                                    ,               receipt_id
                                  )      AS received_total
         ,     receipt_id
         FROM    receipts
    ,     deliveries_rt     AS
         SELECT     item_id
         ,     delivered_date
         ,     delivered_quantity
         ,     SUM (delivered_quantity) OVER ( PARTITION BY  item_id
                                         ORDER BY      delivered_date
                                     ,                delivery_id
                                  )      AS delivered_total
         ,     delivery_id
         FROM    deliveries
    SELECT       d.item_id
    ,       d.delivered_date
    ,       LEAST ( received_total  + delivered_quantity - delivered_total
                , delivered_total + received_quantity  - received_total
              , delivered_quantity    -- *****  See correction, below  *****
              )          AS delivered_quantity
    ,       d.delivery_id
    ,       r.receipt_id          AS from_receipt
    ,       GREATEST ( received_total - delivered_total
                   , 0
                 )          AS stock_quantity
    FROM       deliveries_rt     d
    JOIN       receipts_rt     r  ON     d.item_id        = r.item_id
                        AND     d.delivered_total  > r.received_total  - r.received_quantity
                      AND     r.received_total   > d.delivered_total - d.delivered_quantity
    ORDER BY  d.item_id
    ,            d.delivered_date
    ,       d.delivery_id
    ,            r.received_date
    ,       r.receipt_id
    ;What role does item_id play in this problem? I made a guess, but guessing isn't a very good way to solve problems.
    It may help to think of each row as having a low running total (or low_rt, the total quantity up to, but NOT including the current row) and a high running total (high_rt, the total qualntity up to AND including the current row). In the sub-queries above, I only computed the high_rt, since it's easy enough to get the low_rt from that by subtraction.
    Each row in the deliveries table will be joined to a row in the receipts table if the running totals overlap, that is, if the high_rt of each row is greaterr than the low_rt of the other.
    Delivered_quantity is the minimum of the high_rt from either table minus the low_rt of the other, but it can never be greater than the delivered_quantity.
    Edited by: Frank Kulash on Mar 3, 2011 10:06 AM
    Brief explanation added.
    Edited by: Frank Kulash on Apr 23, 2013 12:56 PM
    <H3>Correction</H3>
    The computation of delivered_quantity in the main query should have 1 more argument to LEAST, like this:
    ,       LEAST ( r.received_total  + d.delivered_quantity - d.delivered_total
                , d.delivered_total + r.received_quantity  - r.received_total
              , d.delivered_quantity
              , r.received_quantity               -- ***  Added  ***
              )          AS delivered_quantityThanks to Jean Marie Delhaze ( {message:id=10980754} below) for finding and correcting my mistake.

  • Bug with readonly view (through sql query)

    HI , I'm using JDEV11.1.1.2
    I found the following problem which I consider a bug:
    When you create a readonly view object based on sql query the first attribute gets type: VARCHAR2(255) although it is VARCHAR2(10) in the database. All other attributes get the correct type and length only the first one is not correct.
    Can you confirm this behavior to be a bug ?
    Thanks
    agruev

    Hi,
    of other string attributes show the correct length then this indeed sounds like a bug. However, a bug is a bug when it is getting filed.
    Frank

  • Error when call sql server stored procedure

    hello everybody,
    I'm working with MII 14 and I want call a SqlServer stored procedure provided from my customer.
    I configured a FixedQuery like this:
    [dbo].[spElencoEntrateUscite_AV] @delta = 0, @daquando='130101', @CompanyID='000002', @Elenco = @MyCursor OUTPUT
    but when i test the query i have back the error:
    com.microsoft.sqlserver.jdbc.SQLServerException: Must declare the scalar variable "@MyCursor".
    I tried also to set the query like this:
    [dbo].[spElencoEntrateUscite_AV]
    and pass Parameters:
    0
    130101
    000002
    OUTPUT
    but i have this error:
    com.microsoft.sqlserver.jdbc.SQLServerException: Procedure or function 'spElencoEntrateUscite_AV' expects parameter '@Elenco', which was not supplied.
    Any suggestion?
    thanks in advance
    Alex

    hello Kuldeep!
    yes i solved.
    I used fixed query in MII and declared the cursor:
    example:
    DECLARE @MyCursor CURSOR
    EXEC [dbo].[spElencoEntrateUscite_AV] @delta = 0,@daquando='[Param.1]', @CompanyID='[Param.2]', @Elenco = @MyCursor OUTPUT
    I hope this may help u
    Alessandro

  • SQL QUERY into PROCEDURE

    Hi! I am a newbie in PL/SQL..
    Can somebody teach me on how to make this SQL QUERY into a PROCEDURE?
    TABLE 1: LOGS
    TABLE 2: MASTER LIST
    Logs = records the logs
    Master list = list of all registered name.
    select * from table1
    where not exists
    select host, user, name
    from table2
    where table2.host = table1.host and
    table2.user = table1.user and
    table2.name = table1.name
    TABLE 1
    HOST | USER | NAME
    ==============
    1 | A | A1
    1 | A | A1
    1 | A | A1
    1 | A | D1
    TABLE 2
    HOST | USER | NAME
    =============
    1 | A | A1
    1 | A | B1
    1 | A | C1
    Result:
    HOST | USER | NAME
    ===============
    1 | A | D1
    Thanks. :)

    QKWS wrote:
    Hi! I am a newbie in PL/SQL..
    Can somebody teach me on how to make this SQL QUERY into a PROCEDURE?
    TABLE 1: LOGS
    TABLE 2: MASTER LIST
    Logs = records the logs
    Master list = list of all registered name.
    select * from table1
    where not exists
    select host, user, name
    from table2
    where table2.host = table1.host and
    table2.user = table1.user and
    table2.name = table1.name
    TABLE 1
    HOST | USER | NAME
    ==============
    1 | A | A1
    1 | A | A1
    1 | A | A1
    1 | A | D1
    TABLE 2
    HOST | USER | NAME
    =============
    1 | A | A1
    1 | A | B1
    1 | A | C1
    Result:
    HOST | USER | NAME
    ===============
    1 | A | D1
    Thanks. :)Hi,
    Question is not clear, really.
    Do you want that, I don't sure?
    CREATE TABLE t1 ( CHOST NUMBER,  CUSER VARCHAR2(10), CNAME VARCHAR2(10));
    INSERT INTO t1 VALUES(1,'A','A1');
    INSERT INTO t1 VALUES(1,'A','A1');
    INSERT INTO t1 VALUES(1,'A','A1');
    INSERT INTO t1 VALUES(1,'A','D1');
    Commit;
    CREATE TABLE t2 AS  SELECT *  FROM t1;
    INSERT INTO t2 VALUES(1,'A','A1');
    INSERT INTO t2 VALUES(1,'A','B1');
    INSERT INTO t2 VALUES(1,'A','C1');
    commit;
    select * from t1  table1
    WHERE NOT EXISTS
    ( SELECT 1 FROM t2 table2
       WHERE table2.chost = table1.chost
         AND table2.cuser = table1.cUSER
         AND table2.cNAME = table1.cNAME
    DECLARE
    P_HOST T1.CHOST%TYPE;
    P_USER T1.CUSER%TYPE;
    P_NAME T1.CNAME%TYPE;
    BEGIN
    select CHOST, CUSER,CNAME INTO P_HOST,P_USER, P_NAME
    from t1  table1
    WHERE NOT EXISTS
    ( SELECT 1 FROM t2 table2
       WHERE table2.chost = table1.chost
         AND table2.cuser = table1.cUSER
         AND table2.cNAME = table1.cNAME
    dbms_output.put_line('HOST | USER | NAME  : '|| TO_CHAR(P_HOST)||' | '||P_USER||' | '||P_NAME);
    END;
    /Regards
    Mahir M. Quluzade

  • Call SQL Server Stored Procedure from BPEL

    Could somebody send me the tutorial on how to use Stored Procedures for SQL Server (as mentioned by mchiocca in this thread: Stored Procedure Support?
    [email protected]
    Thanks!

    This is not a possibility.
    Refer to Support for Non-Oracle Stored Procedures

  • SQL Query in Procedure...

    Hi ,
    I have to build a view dynamically using procedure like this:
    create or replace procedure call_get(arg1 in varchar2 default null,arg2 in varchar2 default null,arg3 in varchar2 default null) is
    begin
    execute immediate 'create or replace view v_get as
    select b.bid,b.name,avg(shipment) from boards b where b.bid in('||arg1||') and '||
    'b.cargo in ('||arg2||') and '||'b.disc in ('||arg3||') group by b.bid,b.name';end;
    This view is to be created for any set of values of arg's.These are number types.
    I am facing a problem, that any of the arg's may not be passed in proc(they can be null).Any help, how to handle this NULL situation?

    Hi ,
    I have to build a view dynamically using procedure
    like this:
    create or replace procedure call_get(arg1 in varchar2
    default null,arg2 in varchar2 default null,arg3 in
    varchar2 default null) is
    begin
    execute immediate 'create or replace view v_get
    as
    select b.bid,b.name,avg(shipment) from boards b where
    b.bid in('||arg1||') and '||
    'b.cargo in ('||arg2||') and '||'b.disc in
    ('||arg3||') group by b.bid,b.name';end;
    This view is to be created for any set of values of
    arg's.These are number types.
    I am facing a problem, that any of the arg's may not
    be passed in proc(they can be null).Any help, how to
    handle this NULL situation?declare
    sqlstring varchar2(4000);
    begin
    sqlstring := '';
    sqlstring := ' create or replace view v_get as';
    sqlstring := sqlstring || ' select b.bid,b.name,avg(shipment) from boards b';
    sqlstring := sqlstring || ' where b.bid in ';
    if arg1 is not null then
    sqlstring: = sqlstring || ''''||arg1||'''';
    end if;
    and so on . ..
    at the end:
    execute immediate sqlstring;
    end;
    /

  • Interactive format IN BATCH FILE CALLING SQL QUERY

    Hi,
    Below code i have written to get some data from file test.txt and O/P the data from database. For this i m running MS-DOS batch file which is calling test.sql and which in turn calls the file test.sql and get desired result from database. The below script works perfectly
    What i want is the more interactive format and not hard coded format esp location and name of the TEXT FILE . How i can make changes that whenever BATCH FILE is run, it ask for file name and location and then passes those information to SQL FILE which in turn fetches the results from database
    BATCH FILE : test.bat
    sqlplus sys/xxxxx as sysdba @test.sqlSQL FILE: test.sql
    SET SERVEROUTPUT ON
    DECLARE
       lc_file_handle        UTL_FILE.file_type;
       lc_file_dir           VARCHAR2 (100);
       lc_file_name          VARCHAR2 (50);
       data                VARCHAR2 (500);
       v1                    ECCSYS.hwcontainer.hwcontainerserialnumber%type;
       v2                    ECCSYS.storagedevice.devicename%type;
       s2                    ECCSYS.storagedevice.isreserved%type;
    BEGIN
       lc_file_dir := 'DATA_PUMP_DIR';
       lc_file_name := 'test.txt';
       lc_file_handle := UTL_FILE.fopen (lc_file_dir, lc_file_name, 'R');
       LOOP
          BEGIN
             UTL_FILE.get_line (lc_file_handle, data);
         v1 := SUBSTR (data,1,INSTR (data, ',', 1) - 1);
         v2 := substr(data, INSTR (data, ',', 1, 1) + 1, length(data) - INSTR (data,',', 1, 1));
           select isreserved into s2 from ECCSYS.storagedevice where devicename=v2 and storagearrayid = (select hwcontainerid from ECCSYS.hwcontainer where hwcontainerserialnumber =v1);
         DBMS_OUTPUT.PUT_LINE(v1 ||' '|| v2 ||' '|| s2);
          EXCEPTION
             WHEN NO_DATA_FOUND
             THEN
                EXIT;
          END;
       END LOOP;
    EXCEPTION
       WHEN OTHERS
       THEN
          UTL_FILE.fclose (lc_file_handle);
    END;
    EXIT;TEXT FILE : test.txt
    000190300153,170
    000190300153,171

    Hi,
    I have made some changes in the batch and sql file but problem is , still test.sql is seeking name of the file even though its passed from batch file to sql file.
    BATCH FILE : test.bat
    @echo off
    set /P id=Enter THE FILE NAME: %=%
    echo %id%
    sqlplus sys/xxxx as sysdba @test.sql %idSQL FILE : test.sql
    SET SERVEROUTPUT ON
    DECLARE
       lc_file_handle        UTL_FILE.file_type;
       lc_file_dir           VARCHAR2 (100);
       lc_file_name          VARCHAR2 (50);
       data                VARCHAR2 (500);
       v1                    ECCSYS.hwcontainer.hwcontainerserialnumber%type;
       v2                    ECCSYS.storagedevice.devicename%type;
       s2                    ECCSYS.storagedevice.isreserved%type;
    BEGIN
       lc_file_dir := 'DATA_PUMP_DIR';
       lc_file_name := '&id';
       lc_file_handle := UTL_FILE.fopen (lc_file_dir, lc_file_name, 'R');
       LOOP
          BEGIN
             UTL_FILE.get_line (lc_file_handle, data);
         v1 := SUBSTR (data,1,INSTR (data, ',', 1) - 1);
         v2 := substr(data, INSTR (data, ',', 1, 1) + 1, length(data) - INSTR (data,',', 1, 1));
           select isreserved into s2 from ECCSYS.storagedevice where devicename=v2 and storagearrayid = (select hwcontainerid from ECCSYS.hwcontainer where hwcontainerserialnumber =v1);
         DBMS_OUTPUT.PUT_LINE(v1 ||' '|| v2 ||' '|| s2);
          EXCEPTION
             WHEN NO_DATA_FOUND
             THEN
                EXIT;
          END;
       END LOOP;
    EXCEPTION
       WHEN OTHERS
       THEN
          UTL_FILE.fclose (lc_file_handle);
    END;
    EXIT;

  • How to view the sql queries generated by EJB (CMP)

    Hello,
    I'm using Oracle9iAS (9.0.2.1.0) Containers for J2EE (build 020827.1652) & Oracle 8.1.7 database.
    I have a CMP that has about 400 fields and the corrsoponding table has about 800 fields. I'm able to call create and add a row in database.
    Now when I call update method to set the remaining fields of this row (I get the proper instance by calling findByPrimaryKey()) I'm getting an exception ORA-00957 duplicate column name.
    I'm using reflection to set all the fields by passing my update method a HashMap and setting those fields that this HashMap contains. And as HashMap cannot contain duplicate keys the possiblility of having duplicates is eliminated.
    But why am I getting ORA-00957 duplicate column name.
    Is there a way I can configure somehow to view what sql query is being generated by the OC4j container when its firing this query to update the database table.
    Any help will be greatly appriciated.
    Vipin.

    Install IronTrack SQL as described in the following link
    http://www.irongrid.com/documentation/irontracksql/install.html#install_oracle9iAS

  • Set date as MM/dd/yyyy as in parameter for SQL Server stored procedure

    I have string date in MM/dd/yyyy .
    My requirement is to send date as in parameter to stored procedure in format MM/dd/yyyy .
    CallableStatement cstmt=null;
    cstmt = connection.prepareCall("{......
    How this to be done .I am Using SQL server.
    If i do like below data field is not updated by my code.
    cstmt.setTimestamp
    cstmt.setDate
    But if procedure is executed from SQL Query Anylaxer procedure is updating

    Hi,
    The format that appears by Default for date printing in the List is picked from SU01 parameters or SU3
    You can change the defaults by going into ur system profile.
    Su01 - Change - Go into Defaults tab.
    U can see various details like Start Menu, Logon lamguage, Decimal notation and date format. Choose the format u want and save .
    But the Date Format Is not reflected just by changing the format, you need to Log Off and Log In again to see the changed format in the output.
    also see the link
    http://web.mit.edu/sapr3/docs/webdocs/getstarted/gsSETTINGS.html
    Hope this helps.
    Thanks
    Ruchika

  • Need sql query or pl/sql query urgent

    Hi Experts,
    The requirement is that
    SELECT 'N' flag, sysdate init_date,
    '' vendor_name,
    DECODE (pa.address_type,
    'P', 'Present Address',
    'R', 'Permanent Address',
    pa.address_type
    ) address_type,
    pa.address_line1
    || ','
    || pa.address_line2
    || ','
    || pa.town_or_city
    || ','
    || meaning
    || ','
    || pa.POSTAL_CODE "Address",
    TRUNC (TO_CHAR (pa.date_from, 'YYYY')) YEAR,
    TO_CHAR (pa.date_from, 'MON') MONTH,''station
    FROM per_addresses pa, fnd_lookup_values, per_all_people_f pf
    WHERE (pf.employee_number = :1 or pf.APPLICANT_NUMBER = :2)
    and pf.EFFECTIVE_END_DATE='31-DEC-4712'
    AND pa.person_id = pf.person_id
    AND pa.business_group_id = 42
    --AND pa.date_to IS NULL
    AND lookup_type = 'PER_US_COUNTRY_CODE'
    AND lookup_code = pa.country
    AND enabled_flag = 'Y'
    AND (end_date_active IS NULL OR end_date_active > SYSDATE)
    if i run the above query the output is coming like that
    Present Address |     Flat No. 1201, OC - 15, Orange County, Plot No. GH - 4,Ahinsa Khand 1st, Indrapuram,Ghaziabad,India,201010|     2,010|     JUL
    Permanent Address |     Q.No. 354, Sector - 3 / B,,Bokaro Steel City,India,827003     |2,010     |JUL
    Present Address |     4, Sitara,Chandra Reddy layout, S.T. Bed,Bangalore,India,0|     2,006|     JAN
    Present Address |     101,,Ushma Urja Apartments,Noida,India,201301 |     2,006 |     JUL
    Permanent Address |     F-19, Maccon Colony, Opp. DAV Shyamali School,,Ranchi,India,834002 |     2,009 |     FEB
    Present Address |     Flat no. 604, B - 1, Krishna Apra Gardens,Vaibhav Khand, Plot - 7,Ghaziabad,India,201010 |     2,009     FEB
    But the requirement is the output should come like that
    Permanent Address     |Q.No. 354, Sector - 3 / B,,Bokaro Steel City,India,827003|     2,010     |JUL                    
    Permanent Address 1|     F-19, Maccon Colony, Opp. DAV Shyamali School,,Ranchi,India,834002|     2,009 |     FEB
    Present Address |     Flat No. 1201, OC - 15, Orange County, Plot No. GH - 4,Ahinsa Khand 1st, Indrapuram,Ghaziabad,India,201010|     2,010 |     JUL                    
    Present Address 1 |     Flat no. 604, B - 1, Krishna Apra Gardens,Vaibhav Khand, Plot - 7,Ghaziabad,India,201010|     2,009 |     FEB                    
    Present Address 2 |     101,,Ushma Urja Apartments,Noida,India,201301|     2,006|     JUL     
    Present Address 3 |     4, Sitara,Chandra Reddy layout, S.T. Bed,Bangalore,India,0 |     2,006|     JAN     
    Please provide logice how i need to write a sql query or procedure or function or package
    Thanks & Regards
    Venu

    You can use analytics here :
    SELECT
        flag,
        init_date,
        vendor_name,
        address_type   ||' ' ||rn AS address_type,
        Address,
        YEAR,
        MONTH,
        station
    FROM
            SELECT
                'N' flag,
                sysdate init_date,
                '' vendor_name,
                DECODE (pa.address_type, 'P', 'Present Address', 'R','Permanent Address', pa.address_type ) address_type,
                row_number() over(partition BY pa.address_type order by 1) AS rn,
                pa.address_line1
                || ','
                || pa.address_line2
                || ','
                || pa.town_or_city
                || ','
                || meaning
                || ','
                || pa.POSTAL_CODE "Address",
                TRUNC (TO_CHAR (pa.date_from, 'YYYY')) YEAR,
                TO_CHAR (pa.date_from, 'MON') MONTH,
                '' station
            FROM
                per_addresses pa,
                fnd_lookup_values,
                per_all_people_f pf
            WHERE
                    pf.employee_number  = :1
                 OR pf.APPLICANT_NUMBER = :2
            AND pf.EFFECTIVE_END_DATE='31-DEC-4712'
            AND pa.person_id         = pf.person_id
            AND pa.business_group_id = 42
                --AND pa.date_to IS NULL
            AND lookup_type  = 'PER_US_COUNTRY_CODE'
            AND lookup_code  = pa.country
            AND enabled_flag = 'Y'
            AND
                    end_date_active IS NULL
                 OR end_date_active  > SYSDATE
        );

  • How to return SQL query results as resultset

    I am developing a site in ASP to support back end as oracle or SQL server.
    In SQL Server, from stored procedure it is possible to return resultset by writing sql query in procedure using input parameters as filters (where condition).
    Is there a way to return a resultset from oracle procedures or functions.

    http://asktom.oracle.com/~tkyte/ResultSets/index.html
    In 9i or above you no longer need to define your own weak ref cursor type in a package spec, you can use the built-in SYS_REFCURSOR.

Maybe you are looking for

  • Purchased music from multiple itunes accounts on the same computer

    I mistakenly opened up two itune accounts and have purchased music using both accounts. The problem is that itunes won't let me download my purchased music from one of the accounts to my ipod. It will download all of the music from account "a" but no

  • What's the best way to move a project from my hard drive to someone else's hard drive?

    I've read lots of related discussions concerning problems after copying/importing/whatever, so I want to avoid those.  I have worked on a project since its inception.  It is currently in RoboHelp 8 HTML with several dozen LINKED Word documents and a

  • SAP Script need to display main window two times on single page.

    Hello Guru's, So here is my requirement, we need to print check. We are using F110_PRENUM_CHCK and linked with driver prog RFFOUS_C. We have Letter size paper with three sections, 1. Check 2. Voucher Section (containing table of element 515, 525 and

  • Best Practice for Laptop in Field, Server at Home

    I'm sure this is a common workflow. If somebody has a link to the solution, please pass it along here. I keep all my images on a server at home. I would like to keep that as the repository for all my images. I also have a laptop that I am going to us

  • Enviroment Variable settings

    Hello       How to set the Environment Variable parameter settings done ?       I want to install ECC - 6 in windows Xp professionel ,       Kindly send me to how to set Enviroment Variables before starting installation . Regards Selvan