Home » SQL & PL/SQL » SQL & PL/SQL » passing FILE ID in PL SQL (WINDOWS)
passing FILE ID in PL SQL [message #421438] Tue, 08 September 2009 05:19 Go to next message
pradeepsakti
Messages: 37
Registered: May 2009
Member

Hi,

can anyone pls tell me can we pass file ids between two procedures of different packages in PLSQL??

I am passing file id "v_file UTL_FILE.FILE_TYPE" from package A to package B and in package B iam trying to write into th efile using utl_file.put_line(v_file, 'Hi ....');

but I am getting the error as ORA-29282: invalid file ID

Do I need to use the file ids in same package?

Is there anyway to open a file id in one package say A and then pass it different package say B then write into the file in B??

Thanks alot...
Re: passing FILE ID in PL SQL [message #421440 is a reply to message #421438] Tue, 08 September 2009 05:39 Go to previous messageGo to next message
JRowbottom
Messages: 5933
Registered: June 2006
Location: Sunny North Yorkshire, ho...
Senior Member
What you're describing works:
create or replace package pkg_test_055_b as
 procedure write_data   (p_file   IN utl_file.file_type
                        ,p_text   in varchar2);
end pkg_test_055_b;
/

create or replace package body pkg_test_055_b as
  procedure write_data   (p_file   IN utl_file.file_type
                         ,p_text   in varchar2) is
  begin
    utl_file.put_line (p_file,p_text);
  end;
end pkg_test_055_b;
/

create or replace package pkg_test_055_a as
  procedure test_1;
end pkg_test_055_a;
/

create or replace package body pkg_test_055_a as

  procedure test_1 is
    v_handle   utl_file.file_type;
  begin
    v_handle := utl_file.fopen('TEXT_DIR','test_055.txt','w');
    
    pkg_test_055_b.write_data(v_handle,'FISH!!!!');
    
    utl_file.fclose(v_handle);
  end test_1;
end pkg_test_055_a;
/

begin
  pkg_Test_055_a.test_1;
end;
/


You'll need to create the directory TEXT_DIR and grant Write on it to the user that you run the test from.
Re: passing FILE ID in PL SQL [message #421474 is a reply to message #421440] Tue, 08 September 2009 10:20 Go to previous message
pradeepsakti
Messages: 37
Registered: May 2009
Member

THANK YOU SOOOOO MUCH for the reply..

It was problem with the rights.. its working fine now..
Previous Topic: Filter Data for uniqueness
Next Topic: Calling a funcion in SQL Select stmt
Goto Forum:
  


Current Time: Wed Dec 07 08:40:57 CST 2016

Total time taken to generate the page: 0.08489 seconds