Results 1 to 6 of 6
  1. #1
    Join Date
    Apr 2009
    Posts
    3

    Red face Unanswered: Export text file from table via form

    I am writing following procedure behind the button,but facing errors, please let me correct, I will be grateful
    PROCEDURE WRITE_TO_FILE IS
    BEGIN
    DECLARE
    CURSOR cuProcess IS
    SELECT EMPNO,ENAME,JOB,MGR,HIREDATE,SAL,COMM,DEPTNO FROM EMP;
    rProcess cuProcess%ROWTYPE;
    cOut VARCHAR2(2000);
    N_FILE VARCHAR2(2000);
    OPEN cuProcess;
    --FETCH cuProcess INTO rProcess;
    WHILE cuProcess%FOUND; --LOOP
    FETCH cuProcess INTO cOut--rProcess;
    cOut := rProcess.EMPNO || ';'
    || rProcess.ENAME || ';'
    || rProcess.JOB || ';'
    || rProcess.MGR || ';'
    || rProcess.HIREDATE || ';'
    || rProcess.SAL || ';'
    || rProcess.COMM || ';'
    || rProcess.DEPTNO || ';'
    END LOOP BeginLoop;
    CLOSE cuProcess;
    WRITE_TO_FILE('E:\filename', cOut);
    EXCEPTION
    WHEN OTHERS THEN
    IF cuProcess%ISOPEN THEN
    CLOSE cuProcess;
    END IF;
    END;


  2. #2
    Join Date
    Aug 2003
    Location
    Where the Surf Meets the Turf @Del Mar, CA
    Posts
    7,776
    Provided Answers: 1
    >but facing errors
    ERRORS? What Errors? I do not see any errors.
    You can lead some folks to knowledge, but you can not make them think.
    The average person thinks he's above average!
    For most folks, they don't know, what they don't know.
    Good judgement comes from experience. Experience comes from bad judgement.

  3. #3
    Join Date
    Sep 2002
    Location
    UK
    Posts
    5,171
    Provided Answers: 1
    Your BEGIN is misplaced. It goes after the declarations and before the executable code.

    Please use [code] tags around your code to preserve formatting like this:
    Code:
    begin
       null;
    end;

  4. #4
    Join Date
    Mar 2009
    Location
    New Delhi - India
    Posts
    22
    Make the following change in your code:


    CREATE OR REPLACE PROCEDURE WRITE_TO_FILE IS
    DECLARE
    CURSOR cuProcess IS
    SELECT EMPNO,ENAME,JOB,MGR,HIREDATE,SAL,COMM,DEPTNO FROM EMP;
    rProcess cuProcess%ROWTYPE;
    cOut VARCHAR2(2000);
    N_FILE VARCHAR2(2000);

    BEGIN

    OPEN cuProcess;
    --FETCH cuProcess INTO rProcess;
    WHILE cuProcess%FOUND; --LOOP
    FETCH cuProcess INTO cOut--rProcess;
    cOut := rProcess.EMPNO || ';'
    || rProcess.ENAME || ';'
    || rProcess.JOB || ';'
    || rProcess.MGR || ';'
    || rProcess.HIREDATE || ';'
    || rProcess.SAL || ';'
    || rProcess.COMM || ';'
    || rProcess.DEPTNO || ';'
    END LOOP BeginLoop;
    CLOSE cuProcess;
    WRITE_TO_FILE('E:\filename', cOut);
    EXCEPTION
    WHEN OTHERS THEN
    IF cuProcess%ISOPEN THEN
    CLOSE cuProcess;
    END IF;
    END;

  5. #5
    Join Date
    Apr 2009
    Posts
    3
    Dear Manik, it didn't work , I will be grateful, if you just provide me a procedure that I could export a text file from table (selected rows) please note that all have to run from :When-Button-Pressed".

    Thanks and regards,

  6. #6
    Join Date
    Apr 2009
    Posts
    3
    Quote Originally Posted by manik019
    Make the following change in your code:


    CREATE OR REPLACE PROCEDURE WRITE_TO_FILE IS
    DECLARE
    CURSOR cuProcess IS
    SELECT EMPNO,ENAME,JOB,MGR,HIREDATE,SAL,COMM,DEPTNO FROM EMP;
    rProcess cuProcess%ROWTYPE;
    cOut VARCHAR2(2000);
    N_FILE VARCHAR2(2000);

    BEGIN

    OPEN cuProcess;
    --FETCH cuProcess INTO rProcess;
    WHILE cuProcess%FOUND; --LOOP
    FETCH cuProcess INTO cOut--rProcess;
    cOut := rProcess.EMPNO || ';'
    || rProcess.ENAME || ';'
    || rProcess.JOB || ';'
    || rProcess.MGR || ';'
    || rProcess.HIREDATE || ';'
    || rProcess.SAL || ';'
    || rProcess.COMM || ';'
    || rProcess.DEPTNO || ';'
    END LOOP BeginLoop;
    CLOSE cuProcess;
    WRITE_TO_FILE('E:\filename', cOut);
    EXCEPTION
    WHEN OTHERS THEN
    IF cuProcess%ISOPEN THEN
    CLOSE cuProcess;
    END IF;
    END;

    Dear Manik, I will be grateful, if you provide me the procedure that I could export a text file from table (selected rows), via oracle form.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •