How to write a Timestamp in an Oracle table?

Hi,
I am pretty new to SAP IdM and therefore have a very basic question.
I am using SAP IdM 7.2 SP8 on Oracle.
I was creating a job where I calculated some values from the database with a 'From Database' path.
Then I wanted to store these values in a temporary table together with the timestamp when these were stored/calculated.
Doing this in the Destination-Tab of the 'From Database'-path I got following error message...
java.sql.SQLException: Missing IN or OUT parameter at index::2
I did several tests and created a little test which recreates the problem...
1. Create a Job with a 'From Database'-path
2. In the source statement, insert...
select
  'Test' AS Message,
  systimestamp AS TempDate
from dual;
3. In the destination tab add a temp Table and two columns. Since I want to add a date/timestamp-value I create a column of type 'DATE' here.
4. After running the Job the error appears. (Here in german)
Doing some additional tests I am able to add the date as a varchar2 if I convert the TempDate using a to_char()-function.
Thus it seems like I misusing the Timestamp/Date data type.
Do you have recommendations how I can add the Timestamp as a Date/Timestamp value to my table?
Kind Regards, Andreas

Hi,
I really never got this to work properly and most of what follows is just my own rant caused by the annoyance of not getting this seemingly simple thing to work and are strictly my own theories not based on facts or actual knowledge of how Oracle or JDBC works, nor representing my employer in any way. Anyhow :-)
Its possible that cause of the problem is that the timestamp is "destroyed" by NLS/JDBC when transferred from the database to the client. This is also one of the issues that varies a bit from version to version of the jdbc driver. Also the DATE datatype does not include fractional seconds, so you need to create the column as TIMESTAMP if you want that.
The real fun thing with Oracle (or their jdbc driver) is that you can read a timestamp in the source and jdbc/NLS will convert it according to your locality setting, but you can't write what you read from Oracle back to Oracle.
Just the same way you can use to_char to get a timestamp in a nice enough format, but when writing it to_date may not be able to parse the date back when using the exact same conversion mask...
Example:
     select TO_CHAR(current_timestamp,'YYYYMMDD HH24:MI:SS.FFTZHTZM') from dual;
Gives: 20140314 12:41:03.320000+0100. But both
     select TO_DATE('20140314 12:41:03.320000+0100','YYYYMMDD HH24:MI:SS.FFTZHTZM') from dual;
and
     select TO_TIMESTAMP('20140314 12:41:03.320000+0100','YYYYMMDD HH24:MI:SS.FFTZHTZM') from dual;
give errors.
Rather than argue and fight with it I usually just end up using a To Database pass, check SQL Updating and write the Create Table and update/insert statements myself. Alternativly you can create the table with a trigger that automatically adds the timestamp on inserts/updates.
1st To Database pass has no source, creates the temp table:
The next pass has the source to read the data and insert it into the temp table:
Then just use the current_timestamp function in the insert statement to keep it local and unconverted in the database engine...
Br
Chris
Message was edited by: Per Krabsetsve

Similar Messages

  • How to write jsp select record from Oracle  divide per page , about 50 reco

    Dear Expert,
    How to write jsp select record from Oracle divide per page , about 50 record per page.
    Thank you very much.

    I wish I could, but there is no single sign on module available for Fusion, also, so called Fusion is yet another Word With Big Letters, behind it there is yet another OC4J ( now Oracle switched to Weblogic though) container with bunsh of Oracle apps residing in it.
    Generally speaking, neither Fusion nor Oracle Apps user database does not have any single authentication module available out of the box to integrate user database.
    It's a long sad story running straight from Oracle Apps 11.0.5.
    That's why I've created JAAS single sign on login module and used it ever since at OC4J 10.2 and onwards at OC4J 10.3
    Back to the topic: to develop Apps and test them externally using the session bean I've isted above, one need to copy certain libraries from Oracle Apps server, then add them as libraries for JDeveloper project.
    Here is the complete list:
    oracle.apps.fnd.cache
    oracle.apps.fnd.cache
    oracle.apps.fnd.common
    oracle.apps.fnd.functionSecurity
    oracle.apps.fnd.metadata
    oracle.apps.fnd.security
    oracle.apps.fnd.util
    oracle.apps.jtf.cache
    oracle.apps.jtf.security
    Edited by: Faceless on Nov 26, 2009 3:04 AM

  • "how to load a text file to oracle table"

    hi to all
    can anybody help me "how to load a text file to oracle table", this is first time i am doing, plz give me steps.
    Regards
    MKhaleel

    Usage: SQLLOAD keyword=value [,keyword=value,...]
    Valid Keywords:
    userid -- ORACLE username/password
    control -- Control file name
    log -- Log file name
    bad -- Bad file name
    data -- Data file name
    discard -- Discard file name
    discardmax -- Number of discards to allow (Default all)
    skip -- Number of logical records to skip (Default 0)
    load -- Number of logical records to load (Default all)
    errors -- Number of errors to allow (Default 50)
    rows -- Number of rows in conventional path bind array or between direct path data saves (Default: Conventional path 64, Direct path all)
    bindsize -- Size of conventional path bind array in bytes (Default 256000)
    silent -- Suppress messages during run (header, feedback, errors, discards, partitions)
    direct -- use direct path (Default FALSE)
    parfile -- parameter file: name of file that contains parameter specifications
    parallel -- do parallel load (Default FALSE)
    file -- File to allocate extents from
    skip_unusable_indexes -- disallow/allow unusable indexes or index partitions (Default FALSE)
    skip_index_maintenance -- do not maintain indexes, mark affected indexes as unusable (Default FALSE)
    commit_discontinued -- commit loaded rows when load is discontinued (Default FALSE)
    readsize -- Size of Read buffer (Default 1048576)
    external_table -- use external table for load; NOT_USED, GENERATE_ONLY, EXECUTE
    (Default NOT_USED)
    columnarrayrows -- Number of rows for direct path column array (Default 5000)
    streamsize -- Size of direct path stream buffer in bytes (Default 256000)
    multithreading -- use multithreading in direct path
    resumable -- enable or disable resumable for current session (Default FALSE)
    resumable_name -- text string to help identify resumable statement
    resumable_timeout -- wait time (in seconds) for RESUMABLE (Default 7200)
    PLEASE NOTE: Command-line parameters may be specified either by position or by keywords. An example of the former case is 'sqlldr scott/tiger foo'; an example of the latter is 'sqlldr control=foo userid=scott/tiger'. One may specify parameters by position before but not after parameters specified by keywords. For example, 'sqlldr scott/tiger control=foo logfile=log' is allowed, but 'sqlldr scott/tiger control=foo log' is not, even though the position of the parameter 'log' is correct.
    SQLLDR USERID=GROWSTAR/[email protected] CONTROL=D:\PFS2004.CTL LOG=D:\PFS2004.LOG BAD=D:\PFS2004.BAD DATA=D:\PFS2004.CSV
    SQLLDR USERID=GROWSTAR/[email protected] CONTROL=D:\CLAB2004.CTL LOG=D:\CLAB2004.LOG BAD=D:\CLAB2004.BAD DATA=D:\CLAB2004.CSV
    SQLLDR USERID=GROWSTAR/[email protected] CONTROL=D:\GROW\DEACTIVATESTAFF\DEACTIVATESTAFF.CTL LOG=D:\GROW\DEACTIVATESTAFF\DEACTIVATESTAFF.LOG BAD=D:\GROW\DEACTIVATESTAFF\DEACTIVATESTAFF.BAD DATA=D:\GROW\DEACTIVATESTAFF\DEACTIVATESTAFF.CSV

  • How to store the zip file in oracle table?

    hi,
    How to store the zip file in oracle table ?
    is it possible to unzip and read the file ?
    Thanks
    Rangan S

    SQL> DESC BLOB_TABLE;
    Name Type Nullable Default Comments
    A INTEGER Y
    B BLOB Y
    SQL> INSERT INTO BLOB_TABLE VALUES(5,BLOB('MWDIR_TST','TEST.ZIP'));
    INSERT INTO BLOB_TABLE VALUES(5,BLOB('MWDIR_TST','TEST.ZIP'))
    ORA-00904: "BLOB": invalid identifier
    SQL> INSERT INTO BLOB_TABLE VALUES(5,('MWDIR_TST','TEST.ZIP'));
    INSERT INTO BLOB_TABLE VALUES(5,('MWDIR_TST','TEST.ZIP'))
    ORA-00907: missing right parenthesis
    SQL> INSERT INTO BLOB_TABLE VALUES(5,('\\MWDIR_TST\TEST.ZIP'));
    INSERT INTO BLOB_TABLE VALUES(5,('\\MWDIR_TST\TEST.ZIP'))
    ORA-01465: invalid hex number
    SQL> INSERT INTO BLOB_TABLE VALUES(5,('\\MWDIR_TST\TEST.ZIP'));

  • How to write a procedure for update the table

    Hi all
    can any body please tell me how to write a procedure to update the table......
    I have a table with about 10,000 records...........Now I have add a new column and I want to add values for that like
    registration Code Creidits
    13213 BBA
    1232 MCS
    I had add the creidit now i want to update the table.........the new value want to get by SQL like
    Creidit = select creidit from othere_table...........
    Hope u can understand my problem
    Thanks in advance
    Regards
    Shayan
    [email protected]

    Please try the following --
    update Program_reg a
    set TotalCreidit = ( select tot_cr <Accroding to your logic>
                                from Program_reg b
                                where a.Registration = b.Registration
                                and    a.Enrollment = b.Enrollment
                                and    a.code = b.code
    where a.Registration in ( select distinct Registration
                                        from Program_reg );
    N.B.: Not Tested....
    Regards.
    Satyaki De.

  • How to write XML with attributes to a table in Oracle?

    I tried to find solutions over the internet. Some of the stuff I looked at:https://forums.oracle.com/thread/2182669 http://www.club-oracle.com/forums/how-to-insert-data-from-xml-to-table-t2845/
    In all these cases, the solution considers XML structure with only nodes and child nodes but not attributes. In fact, one of the solutions suggests transforming the XML into a canonical form with only nodes w/o attributes.
    This is a sample of xml structure I am working with:
    Sample XML
    <rep type="P" title="P List"> <as> <a id="3" /> <a id="4" /> </as> </rep>
    I am working with oracle client 11.2 and SQL developer
    My question is: how to write XML data into a table with attributes also as column values, beside the nodes?

    My question is: how to write XML data into a table with attributes also as column values, beside the nodes
    The question you should be asking is : "how do I access attributes in the XPath language?"
    and the answer to that is easily found in any XPath tutorial you may find over the Internet, it is not related to Oracle in particular.
    Short answer : you use an "attribute::" axis before the attribute name, or more commonly a "@", e.g. @type, @id etc.
    Using the method described in the first link, something like this will extract the root attributes :
    SELECT x.*
    FROM XMLTable(
           '/rep'
           passing <xmltype variable/column goes here>
           columns type  varchar2(1)  path '@type'
                 , title varchar2(30) path '@title'
    ) x ;
    For deeper levels, use additional XMLTable calls as described in the mentioned post.

  • Sybase datetime col...how to generate as timestamp col in oracle ddl

    i'm having trouble understanding the date mapping...
    i'm taking the defaults (per http://dermotoneill.blogspot.com/2008/06/offline-data-move-dates.html)...
    but my sybase datetime columns are being generated as date columns in the oracle ddl. (so i lose the milliseconds)
    is there a way to tell the tool to generate datetime cols as timestamp in the oracle ddl?
    thanks!

    If you want to keep the milliseconds you have to make sure you don't map it to datatype date. You need to change the default mapping to TIMESTAMP:
    Open SQLDev Migration Workbench
    - click on the capture model
    - right mouse click on the captured Sybase database
    => set data mapping
    Make sure you change the deafult of DATETIME to TIMESTAMP(6).
    Then recreate the Oracle model and you'll see the data type is now timestamp which includes the milliseconds.

  • How to read RMAN data into an ORACLE Table?

    Hallo,
    With regards to RMAN, how should we store the data into a database table, from the commands which can run only on RMAN prompt without using Recovery Catalog?
    For Example:
    RMAN> Report need backup days 3;
    RMAN DATA:
    RMAN-03022: compiling command: report
    Report of files whose recovery needs more than 3 days of archived logs
    File Days Name
    1 1203 D:\ORACLE\ORADATA\TEST\SYSTEM01.DBF
    2 1203 D:\ORACLE\ORADATA\TEST\RBS01.DBF
    3 1203 D:\ORACLE\ORADATA\TEST\USERS01.DBF
    Should it done via UTL_FILE?
    If so, could someone give simple example/code how to do that, in order to write this RMAN data into an Oracle Database table?
    I also set the utl_file_dir parameter to a particular directory in my database.
    Thanks
    W.Benvort

    Actually, I am not using Recovery Catalog, so the views like RC_database, Rc_tablespaces etc , which are specific to recovery catalog are not available.
    r.- this make sense at 100% because those views belong to the recovery catalog.
    So, I wanted that these information, which we can get via using the commands like above, transfer into an Oracle table
    r.- If you want to access the views of the Recovery Catalog to store part of that information in tables you have to have the database registered in a Recovery Catalog.
    Should we keep the Recovery Catalog in Control file? Instead of using separate Schema.
    r.- I recommend you to create a catalog for your database because the space the controlfile to store information regarding RMAN is reused and you can lose important information about your backups.
    Can we run Catrman.sql script as a sys in order to keep the recovery catalog in sys schema?
    r.- As you know, this is not recommended at all.
    Conclusion : Create a Recovery Catalog and you will be able to perform all that you want regardind what you mentioned above.
    I have a thread for this:
    RMAN ( CATALOG CREATION ) STEP BY STEP by Joel Pérez
    Joel Pérez
    http://otn.oracle.com/experts

  • How to Load file name in to Oracle table column

    hi,
    I am loading data from flat file(TEST_GRET.DMP) to oracle table.
    while the Target Oracle table has four coloumns, in which one is File_name.
    I want to load the FILE NAME into that table too. as there is no ????
    how it can be done???
    Regards,

    If you are loading multiple files using a single interface, using variables, Bhabani's first solution and my solution are good.
    If you only have one interface with your datastore, you know the file name and it won't change, you can use Bhabani's second solution or mine.
    I did not test my solution but it is quite simple to test.
    Just put the code provided for the mapping of your target column.
    This solution has the advantage it should always work.
    Regards

  • How to associate hardware information into an Oracle Table?

    Hi,
    I am new on Windows 2000 .
    I am using the following script in order to get the windows 2000
    hardware information.
    I am using 8.1.7 version of ORACLE.
    I am using a table "Server Hardware"(Server list,Network Adapter,RAM).
    I would like to ask that how should or where should I use this script
    in order to associate its information into my table "Server Hardware".
    Could someone give me hints that how to use this script?
    Thanks
    Lee
    Following script returns the name and version number of the operating
    system installed on a computer
    Script Code
    strComputer = "."
    Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer &
    "\root\cimv2")
    Set colOperatingSystems = objWMIService.ExecQuery _
    ("Select * from Win32_OperatingSystem")
    For Each objOperatingSystem in colOperatingSystems
    Wscript.Echo objOperatingSystem.Caption & " " &
    objOperatingSystem.Version
    Next

    Actually, I am not using Recovery Catalog, so the views like RC_database, Rc_tablespaces etc , which are specific to recovery catalog are not available.
    r.- this make sense at 100% because those views belong to the recovery catalog.
    So, I wanted that these information, which we can get via using the commands like above, transfer into an Oracle table
    r.- If you want to access the views of the Recovery Catalog to store part of that information in tables you have to have the database registered in a Recovery Catalog.
    Should we keep the Recovery Catalog in Control file? Instead of using separate Schema.
    r.- I recommend you to create a catalog for your database because the space the controlfile to store information regarding RMAN is reused and you can lose important information about your backups.
    Can we run Catrman.sql script as a sys in order to keep the recovery catalog in sys schema?
    r.- As you know, this is not recommended at all.
    Conclusion : Create a Recovery Catalog and you will be able to perform all that you want regardind what you mentioned above.
    I have a thread for this:
    RMAN ( CATALOG CREATION ) STEP BY STEP by Joel Pérez
    Joel Pérez
    http://otn.oracle.com/experts

  • How to change the datatype in the oracle table?

    Hi,
    I need to change the datatype of the column in Oracle table. That column contains some data. I do not want to loose those data.
    For altering a table/column condition are:
    1. either table should not contain any data.
    2. either that column should not contain any data.
    Please suggest how i can handle this situation.
    Thanks.

    Hello,
    Suppose you have currently datatype of column as VARCHAR and you want to convert it in NUMBER. Do following
    1-Add another column with NUMBER datatype in your table.
    ALTER table tablename
    ADD testcolumn NUMBER;2-Update your actual column data to this test column.
    UPDATE tablename
    SET testcolumn = actualcolumn;
    COMMIT;3-Update your actual column data to null;
    UPDATE tablename
    SET actualcolumn = NULL;
    COMMIT;4-Change Datatype of actual column.
    ALTER table tablename
    MODIFY actualcolumn NUMBER;5-Update actualcolumn to testcolumn
    UPDATE tablename
    SET actualcolumn = testcolumn;
    COMMIT;
    please mark if it help you or correct
    Regards,
    Danish

  • How To Write A Matrix Query in Oracle 10g

    Hi All,
    I need to write a query displaying total of each Month and each quarter total. Here is example:
    CREATE TABLE T_CUST_REG(
    CUST_ID NUMBER,
    CUST_NAME VARCHAR2(255),
    REGDATE  DATE);
    INSERT INTO T_CUST_REG VALUES (1, 'A','01-JAN-2012');
    INSERT INTO T_CUST_REG VALUES (2, 'B','01-FEB-2012');
    INSERT INTO T_CUST_REG VALUES (3, 'C','01-MAR-2012');
    INSERT INTO T_CUST_REG VALUES (4, 'D','01-APR-2012');
    INSERT INTO T_CUST_REG VALUES (5, 'E','01-MAY-2012');
    INSERT INTO T_CUST_REG VALUES (6, 'F','01-JUN-2012');
    INSERT INTO T_CUST_REG VALUES (7, 'G','01-JUL-2012');
    INSERT INTO T_CUST_REG VALUES (8, 'H','01-AUG-2012');
    INSERT INTO T_CUST_REG VALUES (9, 'I','01-SEP-2012');
    INSERT INTO T_CUST_REG VALUES (10, 'J','01-OCT-2012');
    INSERT INTO T_CUST_REG VALUES (11, 'K','01-NOV-2012');
    INSERT INTO T_CUST_REG VALUES (12, 'L','01-DEC-2012');
    Output REQUIRED:
    JAN
    FEB
    MAR
    Q1
    APR
    MAY
    JUN
    Q2
    JUL
    AUG
    SEP
    Q3
    OCT
    NOV
    DEC
    Q4
    1
    1
    1
    3
    1
    1
    1
    3
    1
    1
    1
    3
    1
    1
    1
    3
    I am able to create matrix with following query, but issue is how to put Quarter(total) in between.
    Select Count(1), TO_CHAR(REGDATE, 'MON') MON 
    FROM T_CUST_REG T
    GROUP BY TO_CHAR(REGDATE, 'MON');
    Regards

    Hi,
    The query you posted will produce a separate row for each month, not a separate column.  Is that what you want?
    If so, you can add the quarterly totals with GROUPING SETS, like this:
    SELECT    COUNT (*)    AS cnt
    ,         CASE
                  WHEN  GROUPING (TRUNC (regdate, 'MONTH')) = 0
                  THEN  TO_CHAR (TRUNC (regdate, 'MONTH'), 'YYYY MON')
                  ELSE  TO_CHAR (TRUNC (regdate, 'Q'),     'YYYY "Q"Q')
              END          AS label
    FROM      t_cust_reg
    GROUP BY  GROUPING SETS ( (TRUNC (regdate, 'MONTH'))
                            , (TRUNC (regdate, 'Q'))
    Instead of calling TRUNC over and over, you might want to do it just 2 times, in a sub-query, giving aliases to the results, and then use the aliases over and over in the main query.
    I hope this answers your question.
    If not, post a little sample data (CREATE TABLE and INSERT statements, relevant columns only), and the exact results you want from that data.
    Explain, using specific examples, how you get those results from that data.
    Always say what version of Oracle you're using (e.g. 11.2.0.2.0).
    See the forum FAQ: https://forums.oracle.com/message/9362002

  • How to write this sql  query to oracle

    Hi sir,
    i am using one query in my sql stored procedure that is:
    select @maxtime=CONVERT(Time,Out_Time+DATEADD(n,60,0)) from shift where Shift_Code = @ShiftCode
    so here i am getting this value 01/01/1900 12:00 AM
    the same i used in oracle my query is :
    to_char(Out_Time,'1900-01-01' + 0/(24*60),'DD/MM/YYYY HH:MI AM')
    INTO v_maxtime
    FROM shift
    WHERE Shift_Code = v_ShiftCode;
    but getting error that is: Encountered the symbol INTO when expecting one of the following :=(%;
    am i doing any thing wrong.
    thanks

    APC wrote:
    The error you're getting is a syntax error. In this case because you've mangled the TO_CHAR syntax. Alas I cannot give you the correct version because I cannot unpick what you're trying to do with that statement.
    It would be easier if you expalined what business logic you're trying to implement instead of asking us to interpret a piece of shonky SQL.It's yet another of the OP's questions about how to do DATEs in Oracle (so many threads it can get very confusing - even though the OP has been asked to stick to one thread!).
    The code looks like it's based on the answer I gave here:
    How to get exact query of sql in oracle?
    but clearly he doesn't understand the basic syntax of Oracle or the datatypes he's using. Sometimes you just have to give up... (I know I have)

  • How to write a dynamic SQL in Oracle Portal

    Hello
    I am running portal on instance C.
    I have instance A and B
    From instance C I want to run a report where I will select the instance name.
    then the when I execute the query must be dynamically generated adn executed.
    for example: in the case of instance A;
    the query must be
    select * from scott.emp@A
    in the case of instance B
    the query must be
    select * from scott.emp@B
    I already have database links A and B pointing to instances A and B respectively.
    How do I achieve this. Any code samples, suggestions appreciated.
    Thanks
    Ganesh

    Hallo,
    I don't understand why you need a database link, if you are already on that instance ?
    BUT for your solution : put your database links in a view and select from this view.
    In the view you can do something like this :
    create or replace view test
    (col1, col2, col3)
    as
    select .., 'A' location
    from taba@A
    where ...
    union
    select .., 'C' location
    from taba@C
    where ...
    union
    select .., 'B' location
    from taba@B
    where ...
    The only thing you have to do is to give the instance name to the view as the column location.
    Good luck.
    Filip Huysmans.

  • How to write REF-CURSOR Query in Oracle Reports

    Hello Guys!!
    I have a form in which you can select regions/divisions/locations etc by the use of check boxes. And the selected values will be inserted into a table, and based on the selected values of the table the report is run.
    The issue I have is with the query inside the Oracle reports(attached to this file).
    The query works fine until the last two EXISTS conditions.
    IF a region exists In the table report_param then it works fine but if there are no divisions in it , then the query returns no values, which is not correct.
    Someone has advised me to use a ref-cursor query inside reports tool, which I am not aware off. So, anykind of suggestions or advises are welcome. Please let me know about it as it is very urgent issue for me. Anykind of help would be greatly
    appreciated.
    Thanks,
    Vishal
    -------------------------------------------------------Query in Oracle Reports---------------------------------------------------------
    select c.key_segment, p.supplier_id,
    decode(:in_col_nm, 'BRAND',nvl(p.product_brand,'<Unknown Brand>'), 'PLN',nvl(p.product_legal_name,'<Unknown Legal Name>')) COL_NM,
    sum(a.ext_price) sales_dols,
    sum(comp_allow_pkg.get_comp_allow_stddiv(a.control_loc_id, a.product_id, a.sold_to_customer_id,
    a.doc_dt, a.ext_price, a.units)) cust_reb_dols,
    sum(a.units) units,
    sum(a.ext_cost) cost_dols
    from sales a, key_segment_plns c, product p, rep_wrtr_dw_cust h
    where a.doc_dt between :in_start_dt and :in_end_dt
    and a.customer_oc = h.control_loc_id
    and a.sold_to_customer_id = h.sold_to_cust_id
    and a.ship_to_customer_id = h.ship_to_cust_id
    and ((:in_dg_cd = 'B' and h.dealer_grower_cd in ('D','G')) or h.dealer_grower_cd = :in_dg_cd)
    and a.product_id = p.product_id
    and p.product_gl_class_cd = 'CHEM'
    and p.product_legal_name = c.product_legal_name
    and c.key_segment in ('GLYPHOSATE','PLANT HEALTH/RUST FUNGICIDES','PYRETHROIDS','STROBI FUNGICIDES')--&IN_KEY_SEGMENTS
    -- and (:in_oc = 'ALL' or (a.control_loc_id in (select control_loc from control_loc_comb_ocs where control_loc_comb = :in_oc)))
    -- SALES DATA FILTERS TO MATCH ACCUM_SALES_DG_MV
    and a.sale_type_cd in ('02','08')
    and a.document_type_cd in ('I','C','D')
    and (substr(a.product_id,-1) in ('0','1') OR nvl(upper(trim(p.product_brand)),'X') = 'TECH FEE')
    and a.units <> 0
    and a.unit_cost <> 0
    and a.unit_price <> 0
    -- NEW FILTERS ADDED 9/11/07: LOCATION(BRANCH), BUSINESS TYPE, RSM/ASM/REP
    and ((:in_loc = 'ALL') or (nvl(a.warehouse_id,'<blank>') in (SELECT param_value
    FROM report_param
    WHERE report_id = :IN_REPORT_ID
    AND session_id= :IN_SESSION_ID
    AND USER_ID = :IN_USER_ID
    AND param_name='LOCATION_TYPE')))
    and ((:in_uhs_ag = 'ALL') or (:in_uhs_ag = 'NA' and p.product_uhs_ag != 'A') or (p.product_uhs_ag = :in_uhs_ag))
    and ((:in_sales_rep = 'ALL') or (nvl(a.territory_id,'<blank>') in (SELECT param_value
    FROM report_param
    WHERE report_id = :IN_REPORT_ID
    AND session_id= :IN_SESSION_ID
    AND USER_ID = :IN_USER_ID
    AND param_name='SALES_REP_TYPE')))
    and EXISTS
    (SELECT '1'
    FROM locations l, report_param rp
    WHERE rp.report_id = :IN_REPORT_ID
    AND rp.session_id= :IN_SESSION_ID
    AND rp.user_id = :IN_USER_ID
    AND rp.param_value = l.region
    AND rp.param_name = 'REGION_TYPE'
    AND a.warehouse_id = L.ARS_LOCATION)
    and EXISTS
    (SELECT '1'
    FROM locations l, report_param rp
    WHERE rp.report_id = :IN_REPORT_ID
    AND rp.session_id= :IN_SESSION_ID
    AND rp.user_id = :IN_USER_ID
    AND rp.param_value = l.region
    AND rp.param_name = 'DIVISION_TYPE'
    AND a.warehouse_id = L.ARS_LOCATION)
    group by c.key_segment, P.supplier_id,
    decode(:in_col_nm, 'BRAND',nvl(p.product_brand,'<Unknown Brand>'), 'PLN',nvl(p.product_legal_name,'<Unknown Legal Name>'))

    Hi,
    I need your help to create a report using Ref-Cursor. please see the below thread
    Report using ref cursor or dynamic Sql

Maybe you are looking for