Restrict records in CSV file based on condition

Greetings. I searched the forum for my issue and didn't find an answer or the right search terms. I am running APEX 4.1.1
I have a report on a page. I am showing all records for a given SQL statement in my table, but in the "Export to CSV" I need to limit the output based on one of the fields. So for example, if I had a report like:
SELECT x, y, Z
FROM Table1
I would like the Export to CSV for that table to limit the output such as:
SELECT x, y, Z
FROM Table1
WHERE Z = 1
Is that possible?
Thanks!
John

Hi John,
I have tested the login now and the above works for Interactive report only and for Classic report you need to do something like this because the request is set to different value
SELECT x, y, Z
FROM Table1
WHERE ((Z = 1 and nvl(:REQUEST,'X') like 'FLOW_EXCEL_OUTPUT%') OR nvl(:REQUEST,'X') not like 'FLOW_EXCEL_OUTPUT%')See this working example http://apex.oracle.com/pls/apex/f?p=46417:25
When you export to csv you will only get dept 10 records

Similar Messages

  • Split records into two files based on lookup table

    Hi,
    I'm new to ODI and want to know on how I could split records into two files based on a value in one of the columns in the table.
    Example:
    Table:
    my columns are
    account name country
    100 USA
    200 USA
    300 UK
    200 AUS
    So from the 4 records I maintain list of countries in a lookup file and split the records into 2 different files based on values in the file...
    Say I have records AUS and UK in my lookup file...
    So my ODI routine should send all records with country into file1 and rest to file2.
    So from above records
    File1:
    300 UK
    200 AUS
    File2:
    100 USA
    200 USA
    Can you help me how to achieve this?
    Thanks,
    Sam

    1. where and how do i create filter to restrict countries? In source or target? Should I include some kind of filter operator in interface.
    You need to have the Filter on the Source side so that we can filter records accordingly the capture the same in the File. To have a Filter . In the source data store click and drag the column outside the data store and you will have Cone shaped icon and now you can click and type the Filter.
    Please look into this link for ODI Documentation -http://www.oracle.com/technetwork/middleware/data-integrator/documentation/index.html
    Also look into this Getting started guide - http://download.oracle.com/docs/cd/E15985_01/doc.10136/getstart/GSETL.pdf . You can find information as how to create Filter in this guide.
    2. If I have include multipe countries like (USA,CANADA,UK) to go to one file and rest to another file; Can I use some kind of lookup file...? Instead of modifying filter inside interface...Can i Update entries in the file?
    there are two ways of handling your situation.
    Solution 1.
    1. Create Variable Country_Variable
    2. Create a Filter in the Source datastore in the First Interface ( SOURCE.COLUMN = #Country_Variable)
    3. Create a new Package Country File Unload
    4. Call the Variable in Country_Variable in Set Mode and provide the Country (USA )
    5. Next call the First Interface
    6. Next call the Second Interface where the Filter condition will be ( SOURCE.COLUMN ! = #Country_Variable )
    7. Now run the package .
    Solution 2.
    If you need a solution to handle through Filer.
    1. Use this Method (http://odiexperts.com/how-to-refresh-odi-variables-from-file-%E2%80%93-part-1-%E2%80%93-just-one-value ) to call the File where you wish to create store the country name into the variable Country_Variable
    2. Pretty much the same Create a Filter in the Source datastore in the First Interface ( SOURCE.COLUMN = #Country_Variable)
    3.Create a new Package Country File Unload
    4.Next call the Second Interface where the Filter condition will be ( SOURCE.COLUMN ! = #Country_Variable )
    5. Now run the package .
    Now through this way using File you can control the File.
    Please try and let us know , if you need any other help.

  • How we can restrict record in CTL file on the basis of other table ?

    Hello all,
    How we can restrict record in CTL file on the basis of other table ?
    Eg.
    I have following control file to load the records in the table through the sql loader.
    LOAD DATA
    INTO TABLE THIST APPEND
    FIELDS TERMINATED BY "|" TRAILING NULLCOLS
    LNUM POSITION(1) Char "substr(:LOAN_NUM, 4, 13)",
    TSRNUM Char "rtrim:TRAN_SR_NUM)" ,
    TPROCDT Char "to_char(to_date rtrim:TRAN_PROC_DT), 'MMDDYYYY'), 'YYYYMMDD')"      
    I have another table c all TFILE in which I have LNUM. I want to import only those records from input text file using the control file and sql loader in which LNUM is exist in the TFILE.
    So how i can restrict it in the Control File.
    Thanks
    Kamlesh Gujarathi
    [email protected]

    Hello Satyaki De.
    Thank you very much for your suggestion but my Private information is totally apart from this question & I already I have changed each and every information from the question.
    Thanks
    Kamlesh Gujarathi
    [email protected]

  • Count total no of records in csv file

    hello
    i made a function which count total no of records in csv file.
    but it always return 0 goes in the exception when no data found which
    it also display the total no of records in another parameter.
    code is here
    CREATE OR REPLACE FUNCTION COUNT_RECORDS_CSV (storeid1 number ) RETURN NUMBER
    IS
    wfile_handl UTL_FILE.FILE_TYPE;     
    v_file varchar(100);
    S VARCHAR2(32767);
    c number :=0;
    v_dir VARCHAR2 (50) := 'REPORTS';
    BEGIN
    v_file :='DATA_'||storeid1 ||'.CSV';
    DBMS_OUTPUT.PUT_LINE('V_FILE='||v_file);
    wfile_handl := UTL_FILE.FOPEN(v_dir,'DATA_5138.CSV','R');
    LOOP
    UTL_FILE.GET_LINE(wfile_handl,S);
    C := C + 1;
    END LOOP;
    UTL_FILE.FCLOSE(wfile_handl);
    RETURN C;
    EXCEPTION
    WHEN NO_DATA_FOUND THEN
    RETURN 0;
    END COUNT_RECORDS_CSV;
    if i print the values of c it show me correct result but it always return 0 can any body told me why its happening.
    thanks

    The fact that you have written this:
    EXCEPTION
      WHEN NO_DATA_FOUND THEN
        RETURN 0;means you didn't bother to read this.

  • How to create additional Line in file based on condition available as part of ZINVOIC02 Idoc segment

    Scenario Details:
    Receiving Zinvoic02 Idoc in PI. Idoc to file translation creates comma separated file with .csv extn
    The logic was kept in such a way that how many E1EDP01 (items) are available in IDoc that many no of records will be created in csv file.
    The file logic for some the fields is as below:
    No of records
    InvNumber
    InvDate
    CusNumber
    LineitemDesc
    Tax1Type
    Tax1%
    for 1st E1EDP01
    E1EDK01-BELNR
    E1EDK03-DATUM
    E1EDK01-PARTN
    Populate when E1EDP04/MSKWZ=O2 or O4 with E1EDP19/KTEXT
    Hardcode when E1EDP04/MSKWZ=O2 or O4
    Sum all E1EDP04 /MSATZ when E1EDP04/MSKWZ=O2 or O4
    for 2nd E1EDP01
    E1EDK01-BELNR
    E1EDK01-DATUM
    E1EDK01-PARTN
    same as above
    same as above
    same as above
    for 3rd E1EDP01
    E1EDK01-BELNR
    E1EDK03-DATUM
    E1EDK01-PARTN
    same as above
    same as above
    same as above
    Additional Line to be created when one or more of E1EDP01 is having E1EDP04/MSKWZ = O3
    same as above
    same as above
    same as above
    Hardcode "REIM for USE TAX"
    Hardcode ""
    Hardcode ""
    Now we have got addition requirement to add a new lineitem when tax code is equal to O3 for any of the E1EDP01.
    Is it possible to create additional lineitem based on condition. If yes, please share what should be the approach.
    How we can create the additional lineitem?
    Currently we are using E1EDP01 to do context handling.
    The target structure is :
    MT_FILE
         INVOICE     0..unbounded
              InvNumber     0..1
              InvDate          0..1
              CusNumber     0..1
              LineitemDesc     0..1
              Tax1Type          0..1
              Tax1%               0..1

    Hello,
    Please add one extra field in the data structure of the target mapping and let its occurrence be 0..unbounded under the root node 'MT_ADP_Invoice'.
    Apply the condition, if tax code MSKWZ (with its context changed to E1EDP01) equalsS to '03', then map it to the newly created target field whose occurrence is 0..unbounded.
    This will then create an additional field which is your requirement.
    The above is one way.
    But if you want to have the same target field name as ADP_File appended for tax field being '03'.
    Then in that case you can you two message mapping for one common operational mapping / interface.
    In the first message mapping you need to have one target data structure created with the source data structure remaining the same as the one shown by you in scrn shot. Now this target data structure will be similar to the source, except that you need to add one more field at the end(name different from other fields) in target (whose occurrence should be 0..unbounded), and it needs to be mapped to E1EDP01 provided the tax code field MSKWZ(its context changed to E1EDP01) equalsS to constant '03'.
    In the second message mapping you need to map the target structure of previous message mapping to the actual required structure. The newly added field should be mapped to ADP_File of your final target structure.
    This will then create the same structure as required.
    Note : Please change the occurence of ADP_File to 0..unbounded.
    Regards,
    Souvik

  • File adapter SyncRead Operation adds "???" to first record of csv file

    Hi All,
    One interface is reading one CSV file (containing two fields only) using SyncRead Operation of File Adapter. But I found, when file adapter parsed the data it appends "???" to first field of the first record which cause further data validation in the process.
    Test.csv file
    123456,159357
    147258,987654
    Trace of the FileAdapter:
    <messages>
    <Invoke_FILE_Inbound_InputVariable>
    <part  name="Empty">
    <empty/>  
    </part>
    </Invoke_FILE_Inbound_InputVariable>
    <Invoke_FILE_Inbound_OutputVariable>
    <part  name="body">
    <Root-Element>
    <TestElements>
    <Emplid>���123456</Emplid>  
    <SupId>159357</SupId>
    </TestElements>
    <HRRespIDElements>
    <Emplid>147258</Emplid>  
    <SupId>987654</SupId>
    </TestElements>
    </Root-Element>
    </part>
    </Invoke_FILE_Inbound_OutputVariable>
    </messages>
    Can anyone help me to understand , what is reason? Or I missed anything.
    Thanks & Regards,
    Sharmistha

    Unfortunately, this is documented bahaviour (solution/workaround anyone?!):
    Elapsed Time Exceeds:
    Specify a time which, when exceeded, causes a new outgoing file to be created.
    Note:
    The Elapsed Time Exceeds batching criteria is evaluated and a new outgoing file is created, only when an invocation happens.
    For example, if you specify that elapsed time exceeds 15 seconds, then the first message that is received is not written out, even after 15 seconds, as batching conditions are not valid. If a second message is received, then batching conditions become valid for the first one, and an output file is created when the elapsed time exceeds 15 seconds.

  • Loading records from .csv file to SAP table via SAP Program

    Hi,
    I have a .csv file with 132,869 records and I am trying to load it to an SAP table with a customized SAP program.
    After executing the program, only 99,999 records are being loaded into the table.
    Is there some setting to define how many records can be loaded into a table? Or what else could be the problem?
    Pls advice.
    Thanks!!!

    hi Arun ,
    A datasource need a extract structure to fetch data .It is nothing but a temp table to hold data.
    First you need to create atable in SE11 with fields coming from CSV file.
    Then you need to write a report program to read you CSV file and populate your table in BW .
    Then you can create a datasource on top of this table .
    After that replicate and load data at PSA and use to upper flow.
    Regards,
    Jaya Tiwari

  • SSIS package to order all the CSV files based on their date of creation/modification mentioned in a filename and load the least recent file in oracle Destination

    HI,
    I need a help for creating SSIS package which has flat file source (specifically , delimited csv files) which are placed in a shared folder
    having file names as  File_1_2015-04-30 08:54:13.900.csv, File_2_2015-04-30 07:54:13.900.csv.
    So, I wanted to use foreach loop to find out the oldest file amongst that(through script task) and need to transform that file in Oracle Destination. After that, I want to archive that file and need to continue this action uptil the most recent file gets
    loaded in destination.
    So, Could you guys please guide me?
    Thanks in advance

    I'd say you need two loops, one to cycle through all the files and collect their names. Then sort them based on your criterion
    Perhaps you can start by seeing http://www.sqlis.com/sqlis/post/Looping-over-files-with-the-Foreach-Loop.aspx
    Collect the file names into a Recodset Destination, then shred it http://www.sqlis.com/sqlis/post/Shredding-a-Recordset.aspx
    perhaps you need an outer loop to iterate over each file to compare the files for dates.
    Do each piece and post here where you needed to stop.
    Arthur
    MyBlog
    Twitter

  • Spliting files based on condition using multi mapping with BPM

    Hi All,
    Can any one please let me know How to <b>Splite the outbound records based on condition using multi mapping with Integration Process in BPM</b>?
    Thanks
    Govindu.

    Hi All,
    Sorry for mistake this question for Exchange infrastructure guys.
    Thanks,
    Govindu

  • IDoc to file. Grouping and generation of files based on condition

    Hi All,
    I am working on a scenario, Idoc to File. I need to create number of files based on  occurrence of a field(vendor) in the idoc. Also the condition is to group by the field(vendor) and create as many files as the number of groups formed.
    For e.g.: In an Idoc if there are ten items present and 3 vendors who are supplying it. <b>The vendor and items can repeat in any order within the same idoc. </b>
    I need to group the items by the vendors and create a file separately for each vendor.  Like :   
    Item         Vendor
    Item1       V1
    Item2         V1
    Item3         V2
    Item4       V2
    Item5        V2
    Item6         V2
    Item1      V2
    Item2         V2
    Item3        V3
    Item6        V3
    What we have to achieve is, to group by the vendors irrespective of the order of the items or number of reoccurrence of the items.  As you see, the Item1 is supplied by both V1 and V2. I need to generate 3 files as follows:
    V1.xml with Item1 and Item2 details.
    V2.xml with Item3, Item4, Item5, Item6, Item1 Item2 details.
    V3.xml with Item3 and Item6 details.
    Can someone please help me with achieving this without using BPM?

    Hi Shashi,
    For this scenario you have to use multimaping without BPM using this blog.
    /people/jin.shin/blog/2006/02/07/multi-mapping-without-bpm--yes-it146s-possible
    And while doing your message mapping you have to use <b>removeContext</b> & <b>SplitByValue</b> (double clike the on splitbyvalue and select <b>value changed</b>) function. This function you have to use with the node in which your Vendor is coming. Example:
    if required to sort the vendor, then first sort the vendor in the below mapping.
    Vendor (NODE) -
    > removeContext -
    > SplitByValue (value Changed) -
    > IDOC.
    By doing this your vendor will be grouped and you will get new IDOC on change of  Vendor.
    Regards,
    Sarvesh

  • Checking for existence of a record in csv file

    Hey all, I have two csv files residing on the server that I will be processing using the UTL_FILE package. One of these files (File A) has only one column and the other one (File B) has over ten. The data in file A is the same as the one in column 2 of File B. File A is mainly there for a lookup purpose whereas File B is the one that has all the data that will be processed. The following example should describe better:
    File A[b]
    Number
    "TR_56575"
    "TY_76756"
    etc
    File B
    Column1, Number, Column3, Column4
    "Mine","TR_56575","uhsht","76744"
    "Yours","TY_76756","nghdjd","45645"
    What I have to do is check whether a Number in File B exists anywhere in File A. If it does then I just skip that record and move on to the next. So basically, I wanted to find out if there is any way to compare the two columns on the server side. I know there is a dbms_lob.fileexists function to check the existence of a file on a server, just wanted to see if there is an extension to that or something that checks the existence of a string in file. Any feedback would be appreciated. Thanks.

    Yeah I thought about that. It would be the ideal way to go, however in this case, I already have a Pl/Sql procedure that grabs File B and just processes it from the server. It works fine and everything but now that this extra logic and file is added where I have to check the existence of a corresponding record in File A, I'm just looking for something to add in my code to just make the comparison on the fly and the rest would be the same.

  • Duplicate record in CSV file

    Hi
    Needed your inputs to take forward this scenario
    It is an IDOC - CSV File scenario where WBS elements are sent across in the file to the legacy system
    9 fields are sent in the file and in those 2 fields are mapped with constants .
    Requirement here is to have a duplication of record in the file with only one constant changed  My CSV file should look like this for each IDOC occurence
         AAA,0123.45,Edgbaston,1234,WBS_Code1,,Airline,
         AAA,0123.45,Edgbaston,1234,WBS_Code2,,Airline,
    it would just be the duplication of record with only one field changed (WBS_Code1 and WBS_code2) so that each IDOC occurence would comprise one WBSelement information sent from the IDOC and the generated file  would have 2 lines of the same record
    Thanks
    Anusha

    Hi
    Unable to get you and I have my receiver strcuture as  mentioned below .And only last 2fields are getting populated from the IDOC and rest all mapped with the constants
    <?xml version="1.0" encoding="UTF-8"?>
    <ns0:MT_WBSCodes xmlns:ns0="http://us.abc.com/PI/aaaat">
    <WBSFile> 0..unbounded
    <RecordTypeIdentifier>FIELDLISTVALUES</RecordTypeIdentifier>
    <CompanyID>UNIT_TOP</CompanyID>
    <CustomFieldID>CL_WBS_CODE_1</CustomFieldID>
    <CustomFieldValue1></CustomFieldValue1>
    <CustomFieldValue2></CustomFieldValue2>
    <Status></Status>
    </WBSFile>
    <WBSFile>0..unbounded
    <RecordTypeIdentifier>FIELDLISTVALUES</RecordTypeIdentifier>
    <CompanyID>UNIT_TOP</CompanyID>
    <CustomFieldID>CL_WBS_CODE_2</CustomFieldID>
    <CustomFieldValue1> - </CustomFieldValue1>
    <CustomFieldValue2></CustomFieldValue2>
    <Status></Status>
    </WBSFile>
    </ns0:MT_WBSCodes>
    Edited by: Anusha  Ramsiva on Sep 3, 2010 4:58 PM

  • Inserting Record into CSV file from BizTalk Orchestration

    Scenario:
    1.Receive file from Source system via RecvPipeline
    2.In Orchestration  extracting some values like ENO,Ename,Salary etc.these values to be added in to CSV file from Expression Shape.How to append/add emp records in to CSV with out overriding the rows.
    Ex:If we submitted 10 files then the CSV file should contain 10 rows in CSV.
    Let me know how to create CSV file from Orchestration and how to add rows into that csv value
    Regards BizTalkWorship

    Simple.
    Receive the message through a Receive Port/Location.
    Create a flat-file schema representing the CSV file structure. Ensure each row is delimited by “{CR}{LF}”. 
    This flat-file schema should only contain the element which you want to see in the destination CSV file like ENO,Ename,Salary etc.
    Have a map where the source schema should be the one which represents the received file and destination schema should be the one which is above created flat-file schema.
    Map the source schema to the destination schema mapping the filed 
    ENO,Ename,Salary etc.
    Have a custom send pipeline with flat-file assembler component it. Use this send pipeline in the send port.
    In send port, configure the send filter like “BTS.ReceivePortName == YourReceivePortName”. Configure the send port’s “Outbound Maps” to the map which you have created in
    above step
    Key Point. In your send port, set the “Copy Mode” property to “Append” from default “Create New”
    With your send port’s, “Copy Mode” property configured to “Append” this will append the value of the output to the existing file. Since in your flat-file schema, each record
    is delimited by “{CR}{LF}” and since you’re overwriting the output file you will have one file with records appended. So if 10 files received, instead of 10 output files, you will have 1 CVS file with 10 rows.
    If you want to construct the message in Orchestration as do, you do as opposed to map in send port at outbound map you can still do.
    If this answers your question please mark it accordingly. If this post is helpful, please vote as helpful by clicking the upward arrow mark next to my reply.

  • Loading data into csv file based on the count of data in table in ODI

    Hi,
    I have a requirement like i have data in table and need to be loaded in csv file.
    If the count of the data in the table exceeds the csv data limit then i need to call the same procedure again to
    generate one more csv file and load the remaining data into it.my data in the table may vary all the time.
    I am new to this ODI.Can anyone tell any ways to do it in ODI or tell me any logic to do this?
    Thanks in advance..
    Edited by: 883410 on May 22, 2012 12:01 AM

    What limit on the csv file are you talking about. There isn't a limit (unless you are on Unix where the filesize is limit is 2GB). Are you talking about opening it in earlier versions of Excel where the display limit is 60,000 rows as this is irrelevant for your operation?

  • How to count number  of records for a field based on condition?

    Hi guys,
    I want to know how to find count of records coming from the database for a particular field based on some condition.
    I need to use this count to suppress some headers. Because of this i am not able to use running totals. Is there any other way?
    Ex scenario:
    I have account number and currency fields, those are coming from database. And i need to count the number of accounts whose currency is not Euro.
    Thanks in advance,
    Vijay.

    A simple formula can do that:
    //Formula begin
    if {your account field}<>"Euro" then 1
    //Formula end
    This formula can be summarized. (by group or report)
    Bryan Tsou@Taiwan

Maybe you are looking for