Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.misc -> Re: UTL_FILE on multiple platforms

Re: UTL_FILE on multiple platforms

From: Rauf Sarwar <rs_arwar_at_hotmail.com>
Date: 28 Feb 2003 23:11:34 -0800
Message-ID: <92eeeff0.0302282311.51ca680f@posting.google.com>


greg_fenton_at_yahoo.com (mobiGeek) wrote in message news:<ea61f029.0302280734.685870cb_at_posting.google.com>...
> I need to have my PL/SQL package run on both Windows and Solaris. In
> my code, I am using utl_file to log debugging info.
>
> Currently my code looks like:
>
> v_dbg_file := utl_file.FOPEN( 'c:\tmp',
> 'utl_file_SetSynchScripts.txt', 'a' );
>
> Is there a generic way to have FOPEN create its file without
> specifying the directory?
>
> Failing that, is there a way that I can programmatically determine the
> OS (or the machine name) on which the code is running so I can do
> something like:
> IF [running_on_windows] THEN
> v_my_utl_directory := 'c:\tmp';
> ELSE
> v_my_utl_directory := '/tmp';
> END IF;
>
> Thanks in advance,
> greg_fenton.

Another solution is using Java. if you are on 8i or above, create a small java stored procedure which will return file separator "\" for Windows and "/" for *nix.

SQL> create or replace and compile java source   2 named "CheckOS"
  3 AS

  4     import java.io.*;
  5     public class CheckOS {
  6        public static String getSeparator ()
  7           throws Exception {
  8              return File.separator;
  9        }
 10     }

 11 /

Java created.

SQL> create or replace function Check_OS return varchar2   2 as
  3 language java name 'CheckOS.getSeparator () return java.lang.String';
  4 /

Function created.

SQL> select Check_OS from dual;

CHECK_OS



\

I ran this on Windows.

Regards
/Rauf Sarwar Received on Sat Mar 01 2003 - 01:11:34 CST

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US