Use PL/SQL procedure to guard against malformed CSV files before upload

Hi all,
In my CSV upload utility, I've implemented error checking procedures, but they are invoked only AFTER data has been uploaded to temp table. This doesn't catch the following sample scenarios:
1. The CSV is malformed, with some rows shifted due to fields and separators missing here and there.
2. User has chosen a wrong CSV to upload (most likely number of fields mismatch)
I'm wondering if it is a good idea to have procedure to read in the CSV, scan each line, count the number of fields (null fields but with delimiters showing the field exist is ok) for each record. If every single record matches the required number of fields for that table, then the CSV is ok, and the insert from external table to temp table is allow. This will ensure at least the CSV file has a valid matrix size for the target table, but rest of error checking is left until after temp table is populated.
One of my concerns is, I specify "missing field values are null" in the external table parameters, which is necessary since not all fields are required. Does this specification causes a row with missing trailing separators still considered valid? If so then the stored procedure must be programmed to omit such a case.
What do you think? Many thanks.

Hi, Cuauhtemoc Amox
Thank you for your advice. I have set web adi  using PL SQL interface.
I have decided to go futher
i have a procedure like that
procedure delete_old_data ( p_id in number, p_description in varchar2)
as
begin
               begin
               if g_flag ='N' then
               delete from xx_test;
                g_flag='Y';
                else null;
                end if;
                end;
insert into xx_test (p_id,p_descriptiom);
end;
G_FLAG is a global variable with default value ='N'  in my package. When web_adi upload
first row from excel sheet, then procedure delete all data from table and change g_flag to 'Y'.
All other rows uploads succesfully; it  works fine.
But when user change data in excel sheet and try to upload second time. DELETE_OLD_DATA procedure doesnt work in proper way.
I have found what problem is. when user use same template and try to upload data several times there is same SESSION_ID in database.
i.e. g_flag ='Y' when user try to upload second time. But when user log off and create template again it is work properly.
My question is: How i can different upload attempts? May be there is some id for each upload proccess.
if i can use this ID in my procedure user will have opportunity to use same template.
Thank you

Similar Messages

  • Display data in log file using PL/SQL procedure

    Just as srw.message is used in Oracle RDF Reports to display data in log file in Oracle Apps, similarly how it is possible to display data in log file using PL/SQL procedure?
    Please also mention the syntax too.

    Pl post details of OS, database and EBS versions.
    You will need to invoke the seeded FND_LOG procedure - see previous discussions on this topic
    Enable debug for pl/sql
    https://forums.oracle.com/forums/search.jspa?threadID=&q=FND_LOG&objID=c3&dateRange=all&userID=&numResults=15&rankBy=10001
    HTH
    Srini

  • How to insert BLOB datatype image using PL/SQL Procedure and SQL Loader

    Hi,
    How to insert an image into database using PL/SQL Procedure and also how to insert using SQL Loader. Please help by giving sample code and process description.
    Thanks,
    Vijay V

    http://asktom.oracle.com/pls/apex/f?p=100:11:0::::P11_QUESTION_ID:232814159006

  • Retrive perticular mail using PL-SQL procedure

    Hi all,
    Anyone knows, how to retrive mails from outlook using PL-SQL procedure?
    Thanks and Regards
    Nilay

    The Java library needed by UTL_TCP is not created properly. You may just run $ORACLE_HOME/rdbms/admin/initplsj.sql as SYS to install it:
    cd $ORACLE_HOME/rdbms/admin
    sqlplus sys/<sys-password> @initplsj.sql

  • How can i return object from oracle in my java code using pl/sql procedure?

    How can i return object from oracle in my java code using pl/sql procedure?
    And How can i returned varios rows fron a pl/sql store procedure
    please send me a example....
    Thank you
    null

    yes, i do
    But i can't run this examples...
    my problem is that i want recive a object from a PL/SQL
    //procedure callObject(miObj out MyObject)
    in my java code
    public static EmployeeObj callObject(Connection lv_con,
    String pv_idEmp)
    EmployeeObj ret = new EmployeeObj();
    try
    CallableStatement cstmt =
    lv_con.prepareCall("{call admin.callObject(?)}");
    cstmt.registerOutParameter(1, OracleTypes.STRUCT); // line ocurr wrong
    //registerOutParameter(int parameterIndex, int sqlType,String sql_name)
    cstmt.execute();
    ret = (EmployeeObj) cstmt.getObject(1);
    }//try
    catch (SQLException ex)
    System.out.println("error SQL");
    System.out.println ("\n*** SQLException caught ***\n");
    while (ex != null)
    System.out.println ("SQLState: " + ex.getSQLState ());
    System.out.println ("Message: " + ex.getMessage ());
    System.out.println ("Vendor: " + ex.getErrorCode ());
    ex = ex.getNextException ();
    System.out.println ("");
    catch (java.lang.Exception ex)
    System.out.println("error Lenguaje");
    return ret;
    Do you have any idea?

  • DBI Reports Using PL/SQL Procedure

    Hi all,
    Is there anyone who worked on Creating a DBI report using a PL/SQL Procedure.
    I want to customize a Report that is using Data Source as of type PL/SQL Procedure.
    Please Reply to me If anyone has any Idea on this..
    Thanks in Advance..

    Hi Blushadow
    Now if i want to update say only 10 records at a time what should i put into my Proc?
    Please go thru my Proc below..
    CREATE OR REPLACE PROCEDURE PRTS.UPDT_ISSUE_USR_ROLE
    As
    Cursor cur_user_role Is
    Select a.org_id,a.user_id
    from prts_user a,issue_user_role b
    where a.user_id=b.user_id;
    upd_rec cur_user_role%rowtype;
    v_rows_processed Number:=0;
    Begin
    Open cur_user_role;
    Loop
    Fetch cur_user_role into upd_rec;
    If cur_user_role%NOTFOUND
    Then
    Exit;
    Else
    update Issue_user_role
    set User_org_nm=(Select full_org_nm from VW_Org where org_id=upd_rec.org_id)
    Where Issue_User_Role.rowid in
    (select issue_user_role.rowid
    FROM issue_user_role,issue,issue_workflow,Issue_step_dtl_wrkflw
    Where Issue_User_Role.Issue_Id=Issue.Issue_id
    And Issue_User_Role.Issue_id=issue_workflow.issue_id
    And Issue_User_Role.Workflow_compnt_id=Issue_Workflow.CURR_STEP_WORKFLOW_COMPNT_ID
    And Issue_User_Role.Workflow_compnt_id=Issue_Step_Dtl_wrkflw.Workflow_compnt_id
    And Issue_User_Role.Issue_id=Issue_Step_Dtl_wrkflw.Issue_Id
    And Issue.Issue_id=Issue_workflow.Issue_Id
    And Issue.Issue_id=Issue_Step_Dtl_Wrkflw.Issue_id
    And Issue_workflow.Issue_id=Issue_Step_Dtl_Wrkflw.Issue_id
    And Issue_Workflow.CURR_STEP_WORKFLOW_COMPNT_ID=Issue_Step_Dtl_wrkflw.Workflow_compnt_id
    And issue_workflow.primry_workflow_flag='Y'
    And issue_user_role.user_id = upd_rec.user_id
    And issue.issue_status_id in (1636,50738,275,50737,2090)
    And issue_step_dtl_wrkflw.Issue_step_status_id in (61248,61249,61250));
    v_rows_processed :=v_rows_processed + SQL%ROWCOUNT;
    If Mod (v_rows_processed,v_rows_processed)=10
    then
    COMMIT;
    End if;END IF;
    End Loop;
    Commit;
    dbms_output.enable(1000000);
    dbms_output.put_line('There were '||v_rows_processed||' rows updated');
    Close cur_user_role;
    End;
    I would appreciate if you can let me know any other alternative way to meet this requirment.
    Cheers
    Vineet

  • How to use pl/sql procedure or function as part of validate the entity obj?

    Hi,
    we are migrating from oracle forms to jdeveloper 11g.
    I have a req. that,i wanted to use oracle pl/sql procedure to validate a attribute in an entity created with ADF BC?
    Is it possible to implement this?
    And how to show the error message from pl/sql procedure?
    Regards
    Murali.

    Hi,
    It is possible by using a method validator for the entity attribute.
    Create a transient attribute 'X'.
    In the validation section of the attribute to be validate, choose method validator.
    In the Error Message tab set error message as {0}.
    Below the value for tokentoken should source.X (X is the transient attribute name)
    In the java code of method validator, call the stored procedure and set the value of transient attribute X with the error message from SP.
    Use setX("ErrorMessage").
    Regards,
    Srinidhi

  • Retrieve online file as CSV via HTTPS using PL/SQL procedure

    Hi all,
    Situation:
    Server A (not ORACLE)_: accesed via URL, generates dynamically a CSV file and returns to the requestor.
    Server B (ORACLE)_: which runs the PL/SQL script. It is the requestor. Read the CSV and store it within ORACLE.
    (1) I want to connect from Server B (ORACLE) to an external URL via HTTPS which generates dynamically the CSV file. Subdomain.domain it is the Server A which contains this CSV file.
    https://dubdomain.domain/csv_generator.php?query=q1
    (2) This file is downloaded to the Server B (ORACLE). A PL/SQL script executed in this machine do the task.
    (3) After that, I load this CSV to an ORACLE table which a common CSV PL/SQL parser.
    Doubts:
    Is it possible to retrieve an online file (a CSV) dynamically created and hosted in a third party server (Not ORACLE) via HTTPS using a PL/SQL procedure executed in a ORACLE server? If the answer is yes, what technology could I use? Any ideas?
    Thanks in advance,
    Yago

    An CSV example in {message:id=10158148}.
    For https, two actions are needed in addition.
    Firstly, the certificate of the https web server needs to be loaded in an Oracle Wallet on your database server. The wallet will have a specific directory location on the server, and will be protected by a password.
    Secondly, the PL/SQL procedure making web call, needs to open the wallet (using <i>UTL_HTTP.set_wallet</i>) using the location and password. Example of that in {message:id=10820182}.

  • Unable to update BPEL workflow task using pl/sql procedure

    All,
    I am on a project which involves APEX/BPEL integration. There is a need to update a workflow task created using pl/sql block of code.
    This uses the out of the box TaskQueryService webservice calls and I am getting the below exception.
    7,380> <ERROR> <default> <::>
    <2009-11-02 04:21:37,380> <ERROR> <default> <::> Cipher decryption error.
    <2009-11-02 04:21:37,380> <ERROR> <default> <::> Failed to decrypt cipher text with transformation "DESede/ECB/PKCS5Padding"; exception reported is Input length (with padding) not multiple of 8 bytes.
    <2009-11-02 04:21:37,380> <ERROR> <default.collaxa.cube.services> <::>
    <2009-11-02 04:21:37,380> <ERROR> <default.collaxa.cube.services> <::> at com.collaxa.cube.util.DESService.decrypt(DESService.java:74)
    <2009-11-02 04:21:37,380> <ERROR> <default.collaxa.cube.services> <::> at oracle.bpel.services.workflow.verification.impl.VerificationService.decryptString(VerificationService.java:2112)
    <2009-11-02 04:21:37,380> <ERROR> <default.collaxa.cube.services> <::> ... 33 more
    <2009-11-02 04:21:37,381> <ERROR> <oracle.bpel.services.workflow> <::> Cipher decryption error.
    Failed to decrypt cipher text with transformation "DESede/ECB/PKCS5Padding"; exception reported is Input length (with padding) not multiple of 8 bytes.
    ORABPEL-00007
    As an alternative I tried to call the procedure from a Java client and it throws the same exceptions (the workflow context is gotten from the Java API call
    workflowContext = taskQueryService.authenticate(WF_MANANAGER_UN, WF_MANANAGER_PW, null, worklistUser);),
    however updating the Task from Java using the ora.bpel library API's works perfectly fine.
    But the client's requirement is to update taskoutcome from pl/sql.
    Please find the exceptions and the code below............. your help is much appreciated.
    Procedure Code and details exceptions below...........:
    REATE OR REPLACE PROCEDURE PR_UPDATE_TASK_FLOW (P_CONTEXT VARCHAR2, P_TASK_ID VARCHAR2)
    AS
    soap_respond VARCHAR2(30000);
    http_req UTL_HTTP.REQ;
    http_resp UTL_HTTP.RESP;
    launch_url VARCHAR2(240);
    l_task_id varchar2(200) := '01647e0505013d7c:25e029b2:124ae1076ef:-7d29';
    l_context varchar2(2000) := '9xReYA5T2NJegzDAVBQl8qNFjFxETMKVK6Y7L5Tz+ZmEG/Mu3BIfABrZG4UeLDlSqqFy/nvYWsjhPoDR+qdgoMBgfEhokt93rPOA/tChlGcI2lOCp5ww0FqKdjii99QFjOjO3c9Vqwghax2h+IvK0hWshBja0lecuc05epm6gpiHt3FFKILOMXbmZ6nR3P+eRAhWsTR7B6FBnw3Xr5QOHQ==';
    l_endpoint_url VARCHAR2(200);
    l_bpel_action VARCHAR2(100);
    l_soap_envelop VARCHAR2(2000) := '<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
    <soap:Body xmlns:ns1="http://xmlns.oracle.com/bpel/workflow/taskService">
    <updateOutcomeOfTasks xmlns="http://xmlns.oracle.com/bpel/workflow/taskService">
    <workflowContext xmlns="http://xmlns.oracle.com/bpel/workflow/common">
    <token xmlns="http://xmlns.oracle.com/bpel/workflow/common">P_CONTEXT</token>
    </workflowContext>
    <taskId xmlns="http://xmlns.oracle.com/bpel/workflow/taskService">P_TASK_ID</taskId>
    <outcome xmlns="http://xmlns.oracle.com/bpel/workflow/taskService">COMPLETE</outcome>
    </updateOutcomeOfTasks>
    </soap:Body>
    </soap:Envelope>';
    BEGIN
    HTTP_REQ:= UTL_HTTP.BEGIN_REQUEST
    TRIM('http://soaapn1.mrc.co.la.ca.us:7777/integration/services/TaskService/TaskServicePort')
    ,'POST'
    ,'HTTP/1.1'
    UTL_HTTP.SET_HEADER(http_req, 'Content-Type', 'text/xml') ;
    UTL_HTTP.SET_HEADER(http_req, 'Content-Length', LENGTH(l_soap_envelop)) ;
    UTL_HTTP.SET_HEADER(http_req, 'SOAPAction', 'updateOutcomeOfTasks');
    UTL_HTTP.WRITE_TEXT(http_req, l_soap_envelop) ;
    http_resp:= UTL_HTTP.GET_RESPONSE(http_req) ;
    UTL_HTTP.READ_TEXT(http_resp, soap_respond) ;
    UTL_HTTP.END_RESPONSE(http_resp) ;
    EXCEPTION WHEN OTHERS THEN
    dbms_output.put_line(sqlerrm);
    END PR_UPDATE_TASK_FLOW;
    EXCEPTION MESSAGE:
    <2009-11-02 04:21:37,379> <ERROR> <default.collaxa.cube.services> <::> ORABPEL-30504
    <2009-11-02 04:21:37,379> <ERROR> <default.collaxa.cube.services> <::>
    <2009-11-02 04:21:37,379> <ERROR> <default.collaxa.cube.services> <::> Internal Error in Verification Service.
    <2009-11-02 04:21:37,379> <ERROR> <default.collaxa.cube.services> <::> Internal Error in Verification Service for user {0}. {1}
    <2009-11-02 04:21:37,379> <ERROR> <default.collaxa.cube.services> <::> Check the underlying exception and correct the error. Contact oracle support if error is not fixable.
    7,380> <ERROR> <default.collaxa.cube.services> <::>
    <2009-11-02 04:21:37,380> <ERROR> <default.collaxa.cube.services> <::> Cipher decryption error.
    <2009-11-02 04:21:37,380> <ERROR> <default.collaxa.cube.services> <::> Failed to decrypt cipher text with transformation "DESede/ECB/PKCS5Padding"; exception reported is Input length (with padding) not multiple of 8 bytes.
    <2009-11-02 04:21:37,380> <ERROR> <default.collaxa.cube.services> <::>
    <2009-11-02 04:21:37,380> <ERROR> <default.collaxa.cube.services> <::> at com.collaxa.cube.util.DESService.decrypt(DESService.java:74)
    <2009-11-02 04:21:37,380> <ERROR> <default.collaxa.cube.services> <::> at oracle.bpel.services.workflow.verification.impl.VerificationService.decryptString(VerificationService.java:2112)
    <2009-11-02 04:21:37,380> <ERROR> <default.collaxa.cube.services> <::> ... 33 more
    <2009-11-02 04:21:37,381> <ERROR> <oracle.bpel.services.workflow> <::> Cipher decryption error.
    Failed to decrypt cipher text with transformation "DESede/ECB/PKCS5Padding"; exception reported is Input length (with padding) not multiple of 8 bytes.
    ORABPEL-00007

    All,
    I am on a project which involves APEX/BPEL integration. There is a need to update a workflow task created using pl/sql block of code.
    This uses the out of the box TaskQueryService webservice calls and I am getting the below exception.
    7,380> <ERROR> <default> <::>
    <2009-11-02 04:21:37,380> <ERROR> <default> <::> Cipher decryption error.
    <2009-11-02 04:21:37,380> <ERROR> <default> <::> Failed to decrypt cipher text with transformation "DESede/ECB/PKCS5Padding"; exception reported is Input length (with padding) not multiple of 8 bytes.
    <2009-11-02 04:21:37,380> <ERROR> <default.collaxa.cube.services> <::>
    <2009-11-02 04:21:37,380> <ERROR> <default.collaxa.cube.services> <::> at com.collaxa.cube.util.DESService.decrypt(DESService.java:74)
    <2009-11-02 04:21:37,380> <ERROR> <default.collaxa.cube.services> <::> at oracle.bpel.services.workflow.verification.impl.VerificationService.decryptString(VerificationService.java:2112)
    <2009-11-02 04:21:37,380> <ERROR> <default.collaxa.cube.services> <::> ... 33 more
    <2009-11-02 04:21:37,381> <ERROR> <oracle.bpel.services.workflow> <::> Cipher decryption error.
    Failed to decrypt cipher text with transformation "DESede/ECB/PKCS5Padding"; exception reported is Input length (with padding) not multiple of 8 bytes.
    ORABPEL-00007
    As an alternative I tried to call the procedure from a Java client and it throws the same exceptions (the workflow context is gotten from the Java API call
    workflowContext = taskQueryService.authenticate(WF_MANANAGER_UN, WF_MANANAGER_PW, null, worklistUser);),
    however updating the Task from Java using the ora.bpel library API's works perfectly fine.
    But the client's requirement is to update taskoutcome from pl/sql.
    Please find the exceptions and the code below............. your help is much appreciated.
    Procedure Code and details exceptions below...........:
    REATE OR REPLACE PROCEDURE PR_UPDATE_TASK_FLOW (P_CONTEXT VARCHAR2, P_TASK_ID VARCHAR2)
    AS
    soap_respond VARCHAR2(30000);
    http_req UTL_HTTP.REQ;
    http_resp UTL_HTTP.RESP;
    launch_url VARCHAR2(240);
    l_task_id varchar2(200) := '01647e0505013d7c:25e029b2:124ae1076ef:-7d29';
    l_context varchar2(2000) := '9xReYA5T2NJegzDAVBQl8qNFjFxETMKVK6Y7L5Tz+ZmEG/Mu3BIfABrZG4UeLDlSqqFy/nvYWsjhPoDR+qdgoMBgfEhokt93rPOA/tChlGcI2lOCp5ww0FqKdjii99QFjOjO3c9Vqwghax2h+IvK0hWshBja0lecuc05epm6gpiHt3FFKILOMXbmZ6nR3P+eRAhWsTR7B6FBnw3Xr5QOHQ==';
    l_endpoint_url VARCHAR2(200);
    l_bpel_action VARCHAR2(100);
    l_soap_envelop VARCHAR2(2000) := '<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
    <soap:Body xmlns:ns1="http://xmlns.oracle.com/bpel/workflow/taskService">
    <updateOutcomeOfTasks xmlns="http://xmlns.oracle.com/bpel/workflow/taskService">
    <workflowContext xmlns="http://xmlns.oracle.com/bpel/workflow/common">
    <token xmlns="http://xmlns.oracle.com/bpel/workflow/common">P_CONTEXT</token>
    </workflowContext>
    <taskId xmlns="http://xmlns.oracle.com/bpel/workflow/taskService">P_TASK_ID</taskId>
    <outcome xmlns="http://xmlns.oracle.com/bpel/workflow/taskService">COMPLETE</outcome>
    </updateOutcomeOfTasks>
    </soap:Body>
    </soap:Envelope>';
    BEGIN
    HTTP_REQ:= UTL_HTTP.BEGIN_REQUEST
    TRIM('http://soaapn1.mrc.co.la.ca.us:7777/integration/services/TaskService/TaskServicePort')
    ,'POST'
    ,'HTTP/1.1'
    UTL_HTTP.SET_HEADER(http_req, 'Content-Type', 'text/xml') ;
    UTL_HTTP.SET_HEADER(http_req, 'Content-Length', LENGTH(l_soap_envelop)) ;
    UTL_HTTP.SET_HEADER(http_req, 'SOAPAction', 'updateOutcomeOfTasks');
    UTL_HTTP.WRITE_TEXT(http_req, l_soap_envelop) ;
    http_resp:= UTL_HTTP.GET_RESPONSE(http_req) ;
    UTL_HTTP.READ_TEXT(http_resp, soap_respond) ;
    UTL_HTTP.END_RESPONSE(http_resp) ;
    EXCEPTION WHEN OTHERS THEN
    dbms_output.put_line(sqlerrm);
    END PR_UPDATE_TASK_FLOW;
    EXCEPTION MESSAGE:
    <2009-11-02 04:21:37,379> <ERROR> <default.collaxa.cube.services> <::> ORABPEL-30504
    <2009-11-02 04:21:37,379> <ERROR> <default.collaxa.cube.services> <::>
    <2009-11-02 04:21:37,379> <ERROR> <default.collaxa.cube.services> <::> Internal Error in Verification Service.
    <2009-11-02 04:21:37,379> <ERROR> <default.collaxa.cube.services> <::> Internal Error in Verification Service for user {0}. {1}
    <2009-11-02 04:21:37,379> <ERROR> <default.collaxa.cube.services> <::> Check the underlying exception and correct the error. Contact oracle support if error is not fixable.
    7,380> <ERROR> <default.collaxa.cube.services> <::>
    <2009-11-02 04:21:37,380> <ERROR> <default.collaxa.cube.services> <::> Cipher decryption error.
    <2009-11-02 04:21:37,380> <ERROR> <default.collaxa.cube.services> <::> Failed to decrypt cipher text with transformation "DESede/ECB/PKCS5Padding"; exception reported is Input length (with padding) not multiple of 8 bytes.
    <2009-11-02 04:21:37,380> <ERROR> <default.collaxa.cube.services> <::>
    <2009-11-02 04:21:37,380> <ERROR> <default.collaxa.cube.services> <::> at com.collaxa.cube.util.DESService.decrypt(DESService.java:74)
    <2009-11-02 04:21:37,380> <ERROR> <default.collaxa.cube.services> <::> at oracle.bpel.services.workflow.verification.impl.VerificationService.decryptString(VerificationService.java:2112)
    <2009-11-02 04:21:37,380> <ERROR> <default.collaxa.cube.services> <::> ... 33 more
    <2009-11-02 04:21:37,381> <ERROR> <oracle.bpel.services.workflow> <::> Cipher decryption error.
    Failed to decrypt cipher text with transformation "DESede/ECB/PKCS5Padding"; exception reported is Input length (with padding) not multiple of 8 bytes.
    ORABPEL-00007

  • Using SQL LOADER in Oracle to import CSV file

    I'm pretty new to databases and programming. Im not very good with the computer lingo so stick with me. I have a csv file that I'm trying to load into my oracle database. It contains account information such as name telephone number service dates ect. I've installed Oracle 11g Release 2. This is what I've done so far step by step..
    1) Ran SQL Loader
    I created a new table with the columns that I needed. For example
    create table Billing ( TAP_ID char(10), ACCT_NUM char(10), MR_ID char(10), HOUSE_NUM char(10), STREET char(30), NAME char(50)
    2) It prompted me that the Table was created. Next I created a control file for the data in notepad which was located in the same directory as my Billing table and has a .ctl extension. GIS.csv is the file im getting the data from and is also in the same directory and named it Billing.ctl, which looked like so..
    load data
    infile GIS.csv
    into table Billing
    fields terminated by ','
    (TAP_ID, ACCT_NUM, MR_ID, HOUSE_NUM, STREET, NAME)
    3) Run sqlldr from command line to use the control file
    sqlldr myusername/mypassword Billing.ctl
    This is where I am stuck. Ive seen video tutorials of exactly what I'm doing but I get this error:
    SQL*Loader-350: Syntax error at line 1.
    Expecting keyword LOAD, found "SERV TAP ID". "SERV TAP ID","ACCT NUMBER","MTR ID","SERV HOUSE","SERV STREET","SERV ^'
    I dont understand why its coming up with that error. My billing.ctl has a load.
    load data
    infile GIS.csv
    into table Billing
    fields terminated by ','
    (TAP_ID, ACCT_NUM, MTR_ID, SERV_HOUSE, SERV_STREET, SERV_TOWN, BIL_NAME, MTR_DATE_SET, BIL_PHONE, MTR_SIZE, BILL_CYCLE, MTR_RMT_ID)
    Any thoughts?

    938115 wrote:
    I also got this text file after the command was executed along with the GIS.bad file
    SQL*Loader: Release 11.2.0.1.0 - Production on Fri Jun 1 09:56:52 2012
    Copyright (c) 1982, 2009, Oracle and/or its affiliates. All rights reserved.
    Control File: bill.ctl
    Data File: GIS.csv
    Bad File: GIS.bad
    Discard File: none specified
    (Allow all discards)
    Number to load: ALL
    Number to skip: 0
    Errors allowed: 50
    Bind array: 64 rows, maximum of 256000 bytes
    Continuation: none specified
    Path used: Conventional
    I have thousands of records in this file and only 64 of them updated.How many record were in the table before and after? I doubt the difference is 64, unless you have exactly 64 rows but you said thousands. I believe you are probably misinterpreting the log file. can you share the full log file? As a test, create a empty table, use the same script and load same data file in this empty table. Once loading is complete, check if it has 64 rows or more. I believe what log file is saying, it is 'commiting after every 64 rows', not 'stopping after loading 64 rows'.
    So, unless you show us the log file there is no way to be certain, feel free to mask confidential info, at-least top 15 and bottom 15 lines ?

  • Validating CSV File BEFORE importing and moving using an SSIS package

    I'm trying to come up with a process (I'm used to doing this kind of stuff in T-SQL) in SSIS to grab a collection of .csv files from a folder, validate them, then depending on if they pass validation, import them into my database and move them into an archive
    folder. If the .csv does not pass validation, then it does not get imported, and instead gets placed into an error folder. The validation requirements is that the Column2 of my .csv contains a WKT text field and the file is considered valid if every record
    can be successfully converted into a Geometry/Geography type field. 
    Column0 Column1 Column2
    abcd efgh LINESTRING (-71.4555487 41.6079686, -71.4550113 41.6088851)
    ijkl mnop LINESTRING (-70.0748669 48.6634506, -70.0499 48.6548479)
    qrst uvwx LINESTRING (-70.3159285 48.4199802, -70.3168512 48.4187551)

    FOr that what you can do is dump the records to staging table and use STisValid function
    see
    http://technet.microsoft.com/en-us/library/bb933890.aspx
    finally take the count of failed ones and if cnt > 0 set boolean value as true/false. Then for true cases move data to final table and for false cases (invalid values), move it to error folder
    So package will look like below
    1. Data flow task to transfer data to staging
    2. execute sql task to call a procedure which does validation on staging data and returns a bit result. Set it to SSIS variable using output variable from procedure
    3. Connect to data flow task to do transfer from staging to destination. the precedence constraint option would be Expression And Constraint with expression as 
    @BooleanVariable == True
    and constraint as OnSuccess
    4. Connect to file system task to archive the file. the precedence constraint option would be Expression And Constraint with expression as 
    @BooleanVariable == False
    and constraint as OnSuccess
    Please Mark This As Answer if it helps to solve the issue Visakh ---------------------------- http://visakhm.blogspot.com/ https://www.facebook.com/VmBlogs

  • SQL* Loader Loading specific column from CSV file to the table

    Dear All,
    Iam Loading specific column from .CSV file to the oracle table.
    Could pls help how i can load only that cols into the table
    Eg: CSV file having id, Frst_name,Last_name, Address,Phone,Insurance etc
    out of this I want to load only Frst_name,Last_name columns to oracle table say fname and lname.
    Thanks in Adv.
    Junu

    Lily,
    I made some changes to your table def but you will get the idea
    -- Table EMPLOYEE
    CREATE TABLE EMPLOYEE
      EMPID        NUMBER                           NOT NULL,
      EMPNICKNAME  VARCHAR2(10 BYTE)                    NULL,
      FNAME        VARCHAR2(20 BYTE)                NOT NULL,
      MI           VARCHAR2(20 BYTE)                    NULL,
      LNAME        VARCHAR2(20 BYTE)                NOT NULL,
      FULLNAME     VARCHAR2(20 BYTE)                NOT NULL,
      HIREDATE     DATE                             DEFAULT SYSDATE               NOT NULL
    --  data file employee.dat
    1,amy,b,amy b
    2,cindy,d,cindy d
    3,eric,f,eric f
    4,gary,h,gary
    -- Control file : Employee.ctl ( you can use truncate, replace or append , see sqlldr for more options)
    load data
    Truncate into table employee
    fields terminated by ","
    optionally enclosed by '"'
    TRAILING NULLCOLS
    empId INTEGER EXTERNAL,
    FName char(20),
    LName char(20),
    FullName char(30)
    now to load use following or you can speicify infile in control fle
    sqlldr username/passowrd control=employee.ctl  data=employee.dat log=employee.log
    {code}
    Hope this help.
    Regards                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

  • How to get sql query data and write into csv file?

    I am writing to seek help, in how can I create bat. script which can execute the following logic:
    connection to the database
    run sql query
    create CSV file
    output query data, into CSV file
    save the CSV file
    osql
    -S 84.18.111.111
    -U adw
    -P rem
    -i "c:\query.sql"
    send ""
    sed -e 's/,\s\+/,/g' MCI_04Dec2014.csv > localNoSpaces.csv
    -o "c:\MCI_04Dec2014.csv"
    This what i have so far, and I am little struggling with the logic after creating CSV file. I am unable to get the above script to work, please advice further, where I may be going wrong. 
    Can you create if statement logic within window's script, to check for null parameters or data feeds?
    Any hints would be most appreciated. 

    Thank you for your reply. 
    Apology for posting the code irrelevant to the forum, as I am still novice scripting user.  
    My goal is to create window's script which can compute the above logic and send the final output file (csv), to FTP folder. 
    Can this logic be implemented via bat. script, if so, is there a example or tutorial i could follow, in order to achieve my task. 
    Any help would be much appreciated. 

  • Start one job after another complets using PL/SQL procedure and DBMS_JOB

    All,
    I am attempting to refresh a materialized view using DBMS_JOB and having a PL/SQL program loop through each materialized view name that resides in a table I created. We do the table because they have to be refreshed in a specific order and I utilize the ORDER_OF_REFRESH column to dictate which MV comes first, second, third, etc.
    Now - I have this working to the extent that it kicks off 4 materialized views (currently set the procedure to only do 4 MVs for testing purposes) but I would ultimately like the procedure to create a new DBMS_JOB that calls DBMS_MVIEW.REFRESH of the next view in line ONLY after the preceeding materialized view DBMS_JOB completes.
    The purpose of all of this is to do a few things. One - if I simply create a procedure with the DBMS_MVIEW.REFRESH call to each materialized view in order - that works but if one fails, the job starts over again and will up to 16 times - BIG PROBLEM. Secondly, we want the job that will call this procedure to fail if it encounters 2 failures on any one materialized view (because some MVs may be dependant upon that data and cannot use old stale data).
    This may not be the "best" approach but I am trying to make the job self-sufficient in that it knows when to fail or not, and doesn't kick off the materialized views jobs all at once (remember - they need to start one after the other - in order).
    As you can see near the bottom, my logic doesn't work quite right. It kicks off all four jobs at once with the date of the whatever LAST_REFRESH is in my cursor (which ultimately is from the prior day. What I would like to happen is this:
    1.) 1st MV kicks off as DBMS_JOB and completes
    2.) 2nd MV kicks off with a start time of 3 seconds after the completion of 1st MV (based off LAST_REFRESH) date.
    3.) This conitnues until all MVs are refresh or until 2 failures are encountered, in which no more jobs are scheduled.
    - Obviously I am having a little bit of trouble with #2 and #3 - any help is appreciated.
    CREATE OR REPLACE PROCEDURE Next_Job_Refresh_Test2 IS
    V_FAILURES NUMBER;
    V_JOB_NO NUMBER;
    V_START_DATE DATE := SYSDATE;
    V_NEXT_DATE DATE;
    V_NAME VARCHAR2(30);
    V_DELIMITER VARCHAR2(1);
    CURSOR MV_LIST IS SELECT DISTINCT A.ORDER_OF_REFRESH,
                                  A.MV_OBJECT_NAME
                        FROM CATEBS.DISCO_MV_REFRESH_ORDER A
                        WHERE A.ORDER_OF_REFRESH < 5
                   ORDER BY A.ORDER_OF_REFRESH ASC;
    CURSOR MV_ORDER IS SELECT B.ORDER_OF_REFRESH,
                                  B.MV_OBJECT_NAME,
                                  A.LAST_REFRESH
                             FROM USER_SNAPSHOTS A,
                                  DISCO_MV_REFRESH_ORDER B
                             WHERE A.NAME = B.MV_OBJECT_NAME
                        ORDER BY B.ORDER_OF_REFRESH ASC;
    BEGIN
    FOR I IN MV_LIST
    LOOP
    IF I.ORDER_OF_REFRESH = 1
    THEN V_START_DATE := SYSDATE + (30/86400); -- Start job one minute after execution time
              ELSE V_START_DATE := V_NEXT_DATE;
    END IF;
         V_FAILURES := 0;
         V_JOB_NO := 0;
         V_NAME := I.MV_OBJECT_NAME;
         V_DELIMITER := '''';
    DBMS_JOB.SUBMIT(V_JOB_NO,'DBMS_MVIEW.REFRESH(' || V_DELIMITER || V_NAME || V_DELIMITER || ');',V_START_DATE,NULL);
              SELECT JOB, FAILURES INTO V_JOB_NO, V_FAILURES
              FROM USER_JOBS
              WHERE WHAT LIKE '%' || V_NAME || '%'
              AND SCHEMA_USER = 'CATEBS';
    IF V_FAILURES = 3
    THEN DBMS_JOB.BROKEN(V_JOB_NO,TRUE,NULL); EXIT;
    END IF;
    FOR O IN MV_ORDER
    LOOP
    IF I.ORDER_OF_REFRESH > 2
    THEN V_NEXT_DATE:= (O.LAST_REFRESH + (3/86400)); -- Start next materialized view 3 seconds after completion of prior refresh
    END IF;
    END LOOP;
    END LOOP;
    EXCEPTION
    WHEN NO_DATA_FOUND
         THEN
              IF MV_LIST%ISOPEN
                   THEN CLOSE MV_LIST;
              END IF;
    NULL;
    END Next_Job_Refresh_Test2;
    ---------------------------------------------------------------------------------------------------------------------

    Justin,
    I think I am getting closer. I have a procedure shown just below this that updates my custom table with information from USER_SNAPSHOTS to reflect the time and status of the refresh completion:
    CREATE OR REPLACE PROCEDURE Upd_Disco_Mv_Refresh_Order_Tbl IS
    V_STATUS VARCHAR2(7);
    V_LAST_REFRESH DATE;
    V_MV_NAME VARCHAR2(30);
    CURSOR MV_LIST IS SELECT DISTINCT NAME, LAST_REFRESH, STATUS
                             FROM USER_SNAPSHOTS
                        WHERE OWNER = 'CATEBS';
    BEGIN
    FOR I IN MV_LIST
    LOOP
         V_STATUS := I.STATUS;
         V_LAST_REFRESH := I.LAST_REFRESH;
         V_MV_NAME := I.NAME;
    UPDATE DISCO_MV_REFRESH_ORDER A SET A.LAST_REFRESH = V_LAST_REFRESH
    WHERE A.MV_OBJECT_NAME = V_MV_NAME;
    COMMIT;
    UPDATE DISCO_MV_REFRESH_ORDER A SET A.REFRESH_STATUS = V_STATUS
    WHERE A.MV_OBJECT_NAME = V_MV_NAME;
    COMMIT;
    END LOOP;
    END Upd_Disco_Mv_Refresh_Order_Tbl;
    Next, I have a "new" procedure that does the job creation and refresh show just below this which, when starting the loop, sets the LAST_REFRESH date in my table to NULL and the STATUS = 'INVALID'. Then if the order of refresh = 1 then it uses SYSDATE to submit the job and start right away, else if it's not the first job, it uses V_NEXT_DATE. Now, V_NEXT_DATE is equal to the LAST_REFRESH date from my table when the view has completed and the V_PREV_STATUS = 'VALID'. I think tack on 2 seconds to that to begin my next job.... See code below:
    CREATE OR REPLACE PROCEDURE Disco_Mv_Refresh IS
    V_FAILURES NUMBER;
    V_JOB_NO NUMBER;
    V_START_DATE DATE := SYSDATE;
    V_NEXT_DATE DATE;
    V_NAME VARCHAR2(30);
    V_PREV_STATUS VARCHAR2(7);
    CURSOR MV_LIST IS SELECT DISTINCT A.ORDER_OF_REFRESH,
                                  A.MV_OBJECT_NAME,
                                  A.LAST_REFRESH,
                                  A.REFRESH_STATUS
                        FROM CATEBS.DISCO_MV_REFRESH_ORDER A
                        WHERE A.ORDER_OF_REFRESH <= 5
                   ORDER BY A.ORDER_OF_REFRESH ASC;
    BEGIN
    FOR I IN MV_LIST
    LOOP
    V_NAME := I.MV_OBJECT_NAME;
    V_FAILURES := 0;
    UPDATE DISCO_MV_REFRESH_ORDER SET LAST_REFRESH = NULL WHERE MV_OBJECT_NAME = V_NAME;
    UPDATE DISCO_MV_REFRESH_ORDER SET REFRESH_STATUS = 'INVALID' WHERE MV_OBJECT_NAME = V_NAME;
    IF I.ORDER_OF_REFRESH = 1
    THEN V_START_DATE := SYSDATE;
    ELSE V_START_DATE := V_NEXT_DATE;
    END IF;
    DBMS_JOB.SUBMIT(V_JOB_NO,'DBMS_MVIEW.REFRESH(' || '''' || V_NAME || '''' || '); BEGIN UPD_DISCO_MV_REFRESH_ORDER_TBL; END;',V_START_DATE,NULL);
    SELECT A.REFRESH_STATUS, A.LAST_REFRESH INTO V_PREV_STATUS, V_NEXT_DATE
    FROM DISCO_MV_REFRESH_ORDER A
    WHERE (I.ORDER_OF_REFRESH - 1) = A.ORDER_OF_REFRESH;
    IF I.ORDER_OF_REFRESH > 1 AND V_PREV_STATUS = 'VALID'
    THEN V_NEXT_DATE := V_NEXT_DATE + (2/86400);
    ELSE V_NEXT_DATE := NULL;
    END IF;
    END LOOP;
    EXCEPTION
    WHEN NO_DATA_FOUND
         THEN
              IF MV_LIST%ISOPEN
                   THEN CLOSE MV_LIST;
              END IF;
    NULL;
    END Disco_Mv_Refresh;
    My problem is that it doesn't appear to be looping to the next job. It worked succesfully on the first job but not the subsequent jobs (or materialized views in this case).... Any ideas?

  • Using PL/SQL procedure and function

    In a page i have a VO that uses a Where clause that looks like this
    WHERE attr=package.function
    where the function returns a value of an internal variable valued by another procedure in the package which considers only the Dbuser DBSchema as parameters.
    Do i have to call the procedure in a method like initializeBindigsForPage or i have to put it in another place? And in which mode?
    Thanks Marco

    hi satish,
    i tried ur suggestion, but its shows error like
    declare
    o1 number;
    total_bytes number;
    o3 number;
    unused_bytes number;
    o5 number;
    o6 number;
    o7 number;
    b number:=0;
    str varchar2(2000);
    cursor name is select TNAME FROM TAB WHERE TABTYPE='TABLE';
    begin
    FOR VAL IN name
    LOOP
    DBMS_SPACE.UNUSED_SPACE('XMLUSER',VAL.TNAME,'TABLE',o1,total_bytes,o3,unused_bytes,o5,o6,o7);
    --dbms_output.put_line(VAL.TNAME);
    --dbms_output.put_line(total_bytes);
    --dbms_output.put_line(unused_bytes);
    EXECUTE IMMEDIATE 'select count(*) from '||VAL.TNAME||' ' RETURNING into b;
    --select count(*) into b from VAL.TNAME;
    --execute immediate(str);
    dbms_output.put_line(b);
    insert into space values(VAL.TNAME,total_bytes,unused_bytes,b);
    END LOOP;
    end;
    SQL> @space.sql
    declare
    ERROR at line 1:
    ORA-06547: RETURNING clause must be used with INSERT, UPDATE, or DELETE
    statements
    ORA-06512: at line 19
    wat goes wrong satish?

Maybe you are looking for