Friday, August 28, 2009

Execute Oracle Stored Procedure with Structure as input parameter

Do you want to execute a stord procedure with Oracle Strucure as an input?. Here is an psuedo code.

Assume below is the api of your stored procedure

PROCEDURE createTable ( p_rottablemap IN MYTABLE, p_retcode OUT NUMBER )

Below is the sample structure details.

create or replace TYPE mytable AS TABLE OF mytablestructure;

create or replace TYPE mytablestructure AS OBJECT ( tablename VARCHAR2(22), columnname VARCHAR2(30), datatype VARCHAR2(35), datalength VARCHAR2(35), isnullable VARCHAR2(35), dataprecision VARCHAR2(35), datadefault VARCHAR2(35))

Here is the code to execute:

DECLARE
l_array MYTABLE;
retcode Number;
BEGIN
retcode := -1;
l_array := MYTABLE();
l_array.extend(2);
l_array(1) := MYTableSTRUCTURE('ORMJOINKEY','ORM_KEY','NUMBER','','N','', '',);
l_array(2) := ROTSTRUCTURE('ORMJOINKEY','ENTITY_ID','NUMBER','','N','', '');
mypkg.createtable(l_array, retcode);
dbms_output.put_line('retcode: ' retcode);
END;

Happy Coding...

Thursday, February 19, 2009

Searching classes inside jars

Do you want to find the jar name containing a particular class from the set of jars in an environment or folder. Here is the same code for you which you can use in your linux environment.

Save the below code as sample.sh

////////////Code////////////

find . -name '*.jar' | while read file
do
  echo "[*] Listing coincidences into ${file}:"
  echo "==================="
  unzip -l "$file" | grep "Enter class name here to search"
done

//////////Code//////////////

Replace the string "Enter class name here to search" with the class name which you are searching for from the present working directory.

Execute the sample.sh and you will get the jar name listing one by one. If your class name is present then it will list your class name along with jar.