UrbanPro
true

Learn Oracle PL/SQL from the Best Tutors

  • Affordable fees
  • 1-1 or Group class
  • Flexible Timings
  • Verified Tutors

Search in

How To Create The Java Souce In Oracle PLSQL?

Murali Krishna
30/06/2017 0 0

Requirement: How to find the list of files in specified directory?

Step1 : First find the JDK Install or not in the oracle, to find jdk version please run the below sql.

SELECT  dbms_java.get_ojvm_property(PROPSTRING=>'java.version') FROM dual

Step2: Once get the output above then only we can create the java source. If the output is diaplyed then perform the below task

CREATE OR REPLACE AND RESOLVE JAVA SOURCE NAMED "list_of_files" AS

import java.io.File;

public class list_of_files {

public static String getFileList(String idir)

// public static void main(String[] args)
{
//System.out.println("testing");

File aDirectory = new File(idir);
File[] filesInDir = aDirectory.listFiles();
String result = "";
for ( int i=0; i<filesInDir.length; i++ )
{
if ( filesInDir[i].isFile()
&& !filesInDir[i].isHidden() )
{
result = result + "," +filesInDir[i].getName();
System.out.println("result="+result);

}
}
return result;
}

}

--------------------------------

Compile the above code.

3. create or replace function test_fun(p_dir varchar2) return varchar2
AS LANGUAGE JAVA NAME
'list_of_files.getFileList(java.lang.String) return String';

----------------

Compile the above code

4.select test_fun('c:\jars') from dual;

 run the above sql command.

 

 

 

 

 

 

0 Dislike
Follow 0

Please Enter a comment

Submit

Other Lessons for You


Common mistake even experienced programmers make in Plsql.
Hope, you are aware of Procedures in Plsql. Let us discuss one simple thing which we should always remember while writing the datatype of a parameter for a procedure or a function. Eg: Create or replace...

SQL Subqueries - Used in various ways
If you master the concepts of subqueries, you would gain a lot of flexibility in writing complex SQL queries. Let's not get into Correlated subqueries, let us see the different versions of nested subquery...

Interview questions on Packages in Oracle
Let me list few standard questions asked in the interviews on plsql package. 1. Why packages are used? What are it's advantages? 2. Name few bulin-in Oracle packages. 3. Can we have a function or procedure...

New features of Oracle 23ai
2 of the new features of Oracle 23ai (previously Oracle 23c) with respect to SQL are discussed. 1. Boolean datatype included in SQL. Previously, boolean was not part of SQL, but belonged to Oracle...
X

Looking for Oracle PL/SQL Classes?

The best tutors for Oracle PL/SQL Classes are on UrbanPro

  • Select the best Tutor
  • Book & Attend a Free Demo
  • Pay and start Learning

Learn Oracle PL/SQL with the Best Tutors

The best Tutors for Oracle PL/SQL Classes are on UrbanPro

This website uses cookies

We use cookies to improve user experience. Choose what cookies you allow us to use. You can read more about our Cookie Policy in our Privacy Policy

Accept All
Decline All

UrbanPro.com is India's largest network of most trusted tutors and institutes. Over 55 lakh students rely on UrbanPro.com, to fulfill their learning requirements across 1,000+ categories. Using UrbanPro.com, parents, and students can compare multiple Tutors and Institutes and choose the one that best suits their requirements. More than 7.5 lakh verified Tutors and Institutes are helping millions of students every day and growing their tutoring business on UrbanPro.com. Whether you are looking for a tutor to learn mathematics, a German language trainer to brush up your German language skills or an institute to upgrade your IT skills, we have got the best selection of Tutors and Training Institutes for you. Read more