How to return PL/SQL tables to JAVA

Can we return tables from PL/SQL stored procedures to JAVA?
I know that we could use REF CURSOR in PL/SQL, but regarding the performance I heard that its not that good.
This is the PL/SQL code I need to execute. I need to execute this in Java.
package table_type_pkg AS
TYPE t_select_rec_type IS RECORD
( state_id fnd_flex_values.flex_value_id%TYPE
,state_code fnd_flex_values.flex_value%TYPE
,state_desc fnd_flex_values_tl.description%TYPE
TYPE table_type IS table of t_select_rec_type INDEX BY BINARY_INTEGER;
table_type_rec table_type;
empty_table table_type;
-- get_state_details procedure used to get the details of the state
PROCEDURE get_state_details(v_table_type OUT table_type_pkg.table_type);
-- get_records_out procedure to check how the table is intialized in above procedure and what are the values in that table
PROCEDURE get_records_out;
END table_type_pkg;
PACKAGE BODY table_type_pkg AS
PROCEDURE get_state_details(v_table_type OUT table_type_pkg.table_type) AS
CURSOR c_rec IS
SELECT
ffv.flex_value_id
,ffv.flex_value
,fftl.description
FROM
fnd_flex_value_sets ffvs,
fnd_flex_values ffv,
fnd_flex_values_tl fftl
WHERE
ffv.flex_value_set_id= ffvs.flex_value_set_id
AND ffv.flex_value_id=fftl.flex_value_id
AND ffvs.flex_value_set_name = 'BellSouth State';
v_rec_count number:= 1;
v_table_type_recs_out table_type_pkg.table_type;
-- v_emp_rec table_type_pkg.t_select_rec_type%TYPE;
BEGIN
FOR c_get_rec IN c_rec
LOOP
v_table_type_recs_out (v_rec_count) := c_get_rec;
v_rec_count := v_rec_count + 1;
END LOOP;
-- dbms_output.put_line('Last Record of get_records_table is'| |v_table_type_recs_out(v_rec_count
v_table_type := v_table_type_recs_out;
END get_state_details;
PROCEDURE get_records_out IS
v_count_rec NUMBER :=1;
v_table_recs table_type_pkg.table_type;
BEGIN
get_state_details(v_table_recs);
IF v_table_recs.COUNT > 0 THEN
FOR i IN v_table_recs.FIRST .. v_table_recs.LAST
LOOP
DBMS_OUTPUT.PUT_LINE('State id is '| |v_table_recs(i).state_id| |' and State_code is'| |v_table_recs(i).state_code
| |'Description is '| |v_table_recs(i).state_desc);
END LOOP;
END IF;
END get_records_out;
END table_type_pkg;
Thanks,
-Rao Repaka
null

these pl/sql contains all HTML and java code insideJava or JavaScript. They are not the same. I wouldn't expect to see Java inside html, whereas JavaScript would be intermixed. On the other hand you might have a java stored proc (Oracle 9/10) which is generating HTML.
>
Does any body has any idea:Refactor.
I doubt it just has html and JavaScript/Java. So what you have is a mess that mixes several things that should have been seperate in the first place.

Similar Messages

  • Function returning pl/sql table of dynamic structure

    Hi,
    I use oracle11g/windows platform.
    I have a requirement to be coded like this:
    A function to return pl/sql table(cant use ref cursor) whose columns varies everytime it runs i.e.,
    means
    type pl_tab_type is object(col1 varchar2(1000), col2 varchar2(1000))
    type pl_tab is table of pl_tab_type
    func f return pl_tab
    as
    end;
    note : pl_tab_type will vary for each run of function f
    i.e.,for example, pl_tab_type can be changd to as follows:
    type pl_tab_type is object(col1 varchar2(1000), col2 varchar2(1000),col3 varchar2(1000))
    how to return pl/sql table of dynamic type from func, thanks for help in advance.

    WRONG FORUM!
    Please mark this question ANSWERED and repost it in the SQL and PL/SQL forum.
    PL/SQL

  • Who know how to handle pl/sql table return from stored procedure calling from jsp

    I have some stored procedure which return pl/sql table (index by table), It is look like an array. how jdbc handle this?
    CallableStatement cs = con.prepareCall("EXECUTE bill.getcountry(?,?)");
    cs.setInt(1, cid);
    cs.registerOutParameter(2, java.sql.Types.VARCHAR);// ARRAY?
    ResultSet rs = cs.executeQuery();
    Array array = (Array) rs.getObject (1);
    ResultSet array_rset = array.getResultSet ();

    Not that familiar with the OCI (Oracle Call Interface), but I think this call will be problematic - the OCI deals with SQL data types and not with PL/SQL structures.
    The OCI has since Oracle 8i sported an object call interface (see OCI Runtime Environment for Objects for details).
    This allows you to use the CREATE TYPE command to create advance user data types - and these are supported by the SQL engine, PL/SQL engine and external languages via the OCI.
    So you need to have a look at the Perl-DBI documentation to see how it supports Oracle object types and consider using these. As for internal PL/SQL data structures. These are not supported by the SQL engine and I would expect limited or no support in the OCI for these. Anyway, using SQL data types makes a lot more sense ito flexibility and transparency across languages and environments.

  • How to return a OCI Table * (nested table) from OCI application to sqlplus

    Hi,
    How to return a OCI Table * (nested table) from OCI application to sqlplus prompt : OCITAble * shows up as empty on the SQLPLUS prompt.
    The ODCIAggregateTerminate member function's OUT parameter is OCITable * returnValue. After completion of this member function it displays data on the sqlplus prompt.
    My problem is that eventhough my OCITable(returnvalue) has elements appended or added to it. But when I return the OCITAble after completion
    of this member function the OCITable shows up as empty collection on the SQLPLUS prompt. But in the OCI code if I iterate through the collection
    I can print out the elements and see their values or data.
    Can any one let me know how I can make the elements or data in the collection available at SQLPLUS prompt after the completion of this member function.
    If my return value or OUT parameter of this member function is OCINumber * returnValue : then I can see the corresponding value assigned in the OCI Code
    and the same value is returned and visible on the SQLPLUS prompt. But when I use the OUT parameter as OCITAble * : then it shows up as empty collection.
    I don't really know why is it happening so.
    member function ODCIAggregateTerminate(
    self IN OUT MinDistanceImpl, returnValue OUT table_out1,
    flags IN number)
    return number
    as language C
    library custagg name "ODCIAggregateTerminate"
    with context
    parameters (
    context,
    self,
    self INDICATOR STRUCT,
    returnValue ,
    returnValue INDICATOR,
    flags,
    flags INDICATOR ,
    RETURN ),
    typedef OCITable table_out1;
    struct ntab_type
    OCINumber empno;
    OCINumber salary;
    OCIString * tst;
    OCIString * te;
    typedef struct ntab_type ntab_type;
    struct ntab_type_ind
    OCIInd _atomic;
    OCIInd empno;
    OCIInd salary;
    OCIInd tst;
    OCIInd te;
    typedef struct ntab_type_ind ntab_type_ind;
    extern "C" OCINumber * ODCIAggregateTerminate(
    OCIExtProcContext *context,
    MinDistanceImpl * self,
    MinDistanceImpl_ind * self_ind,
    table_out1 * returnValue,
    short * returnValue_ind,
    OCINumber * flags,
    short flags_ind)
    ocitypename for collection..
    ocitypename for element
    ociobjectnew for collection
    ociobjectNew's for elements
    ocicollappend of elements to collection
    then iterate thru collection
    and at them collection as those elements and we return that collection
    But is empty : on SQLPLUS prompt :
    Select Mindis(TT) from table1;
    TT(empno, salary, tstart, te)
    Table_Out1()

    > Can anyone pls let me know if there is some way to return an entire table from a function which
    is called from a stored procedure?
    For what purpose?
    Do you realise that this means pulling Megabytes (or even many Gugabytes) of data from disk, into the buffer cache, and then copying that data into PL/SQL memory (using a function) in order to give a stored proc that data?
    This is just plain crazy.. resource wise, performance wise, scalability wise.. this is exactly how NOT to use Oracle.
    Why don't you instead tell us what problem you want to solve. Forget for the moment what you think the solution should be. (and asking us how to get a potentially flawed solution, to work)
    Let's get an accurate problem definition so that we can provide you with suggestions and recommendation on what Oracle features can be used to address that problem.

  • How to write a SQL query in Java

    Hi, I'm writing a program that pulls all data from the database with a simple "SELECT * FROM [TABLE NAME]. The problem is that I don't know how to set it up properly. My code will only connect to the database but not execute the query. Please help.
    {code}import java.sql.*;
    import java.util.Properties;
    import java.sql.*;
    public class DatabaseSelect {
    public static void main(String[] args) {
    System.out.println("Connected to the database!");
    Connection conn = null;
    String url = "jdbc:oracle://localhost:1571/";
    String dbName = "jdbc";
    String driver = "com.oracle.jdbc.Driver";
    String userName = "HR";
    String password = "database";
    String query = "SELECT * FROM HR";
    try {
    Class.forName(driver).newInstance();
    conn = DriverManager.getConnection(url+dbName,userName,password);
    System.out.println("Connected to the database");
    } catch (Exception e) {
    e.printStackTrace();
    }{code}

    pbsacct_1 wrote:
    I added it between my System.out statement and the catch exception. This is what I put, but I'm getting the same result. I looks like a lot of errors. The only thing that prints is the "Connected to database".
    Statement stmt = con.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,
    ResultSet.CONCUR_READ_ONLY);
    ResultSet srs = stmt.executeQuery("SELECT * FROM HR");Here is what displays in the console.
    Connected to the database!
    java.lang.ClassNotFoundException: com.oracle.jdbc.Driver
         at java.net.URLClassLoader$1.run(URLClassLoader.java:200)
         at java.security.AccessController.doPrivileged(Native Method)
         at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
         at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
         at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:268)
         at java.lang.ClassLoader.loadClass(ClassLoader.java:251)
         at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:319)
         at java.lang.Class.forName0(Native Method)
         at java.lang.Class.forName(Class.java:164)
         at Discussion10.DatabaseSelect.main(DatabaseSelect.java:26)You are not connecting.
    Because you aren't even loading the driver.
    To be honest if you can't decipher a stack trace with "java.lang.ClassNotFoundException" on your own you are not ready for JDBC anyway.

  • How to return a entire table from a Function in Oracle?

    Can anyone pls let me know if there is some way to return an entire table from a function which is called from a stored procedure?
    Thanks

    > Can anyone pls let me know if there is some way to return an entire table from a function which
    is called from a stored procedure?
    For what purpose?
    Do you realise that this means pulling Megabytes (or even many Gugabytes) of data from disk, into the buffer cache, and then copying that data into PL/SQL memory (using a function) in order to give a stored proc that data?
    This is just plain crazy.. resource wise, performance wise, scalability wise.. this is exactly how NOT to use Oracle.
    Why don't you instead tell us what problem you want to solve. Forget for the moment what you think the solution should be. (and asking us how to get a potentially flawed solution, to work)
    Let's get an accurate problem definition so that we can provide you with suggestions and recommendation on what Oracle features can be used to address that problem.

  • How to return an internal table with methods ?

    Hi,
    I am an Java programmer and very new to ABAP.
    How do I return a internal table with a method? I have the table GP1_PRODUCTS and want to return a copy of this table as an internal table called PRODUCTS.
    Here is my code that does not work:
    class PRODUCTS definition
      public
      final
      create public .
    public section.
    *"* public components of class PRODUCTS
    *"* do not include other source files here!!!
      methods GET_PRODUCT_LIST
        returning
          value(PRODUCTS) type GP1_PRODUCTS .
    protected section.
    *"* protected components of class PRODUCTS
    *"* do not include other source files here!!!
    private section.
    *"* private components of class PRODUCTS
    *"* do not include other source files here!!!
    ENDCLASS.
    CLASS PRODUCTS IMPLEMENTATION.
    * <SIGNATURE>---------------------------------------------------------------------------------------+
    * | Instance Public Method PRODUCTS->GET_PRODUCT_LIST
    * +-------------------------------------------------------------------------------------------------+
    * | [<-()] PRODUCTS                       TYPE        GP1_PRODUCTS
    * +--------------------------------------------------------------------------------------</SIGNATURE>
    method GET_PRODUCT_LIST.
    DATA: it_products TYPE STANDARD TABLE OF GP1_PRODUCTS.
    select * from GP1_PRODUCTS into table it_products.
    PRODUCTS = it_products.
    endmethod.
    ENDCLASS.

    You have to create a table type for your table GP1_PRODUCTS.
    If you use global class (created in SE24), than:
    Create a Table Type in SE11
    Go to SE11, Enter a name like ZPRODUCTS in the Data Type
    There will be popup when you press the Create button to decide a type. Select the Table Type
    Enter  GP1_PRODUCTS  in the Line Type.
    * method declaration
      methods GET_PRODUCT_LIST
        returning
          value(PRODUCTS) type ZPRODUCTS.
    If you use local class:
    TYPES: ty_products type standard table of GP1_PRODUCTS..
    * method declaration
      methods GET_PRODUCT_LIST
        returning
          value(PRODUCTS) type ty_products
    Regards,
    Naimesh Patel

  • Calling PL/SQL-package, returning PL/SQL-table

    Hi,
    I'm trying to call a PL/SQL-function returning a PL/SQL-table with two numbers. The below code gives me the cryptic error 'Invalid column index'. Does anyone know how to do this ? I want to display tab_innlogginger (1) and tab_innlogginger (2) in the report...
    <dataSet id="Innlogginger">
    <sql dataSourceRef="DWH-PL">
    <![CDATA[
    declare
    tab_innlogginger dwh_lib.tabdef_innlogginger;
    begin
    tab_innlogginger := dwh_lib.tellinnlogginger (:l_fra_dato, :l_til_dato);
    end
    ]]>
    </sql>
    <input id="l_fra_dato" value="${l_fra_dato}" dataType="xsd:date"/>
    <input id="l_til_dato" value="${l_til_dato}" dataType="xsd:date"/>
    </dataSet>
    The dwh_lib.tabdef_innlogginger is defined as:
    type tabdef_innlogginger is table of number index by binary_integer;
    Regards
    Erik

    OK, found something here:
    Re: steps to create BI publisher report through oracle stored procedure
    Seems pipelined functions using Oracle-objects should work.

  • How to use PL/SQL table

    Hi all,
    can you guys suggest me how can I use pl/sql tables for the below query to incresing the performance.
    DECLARE
        TYPE cur_typ IS REF CURSOR;
        c           cur_typ;
        total_val varchar2(1000);
        sql_stmt varchar2(1000);
        freeform_name NUMBER;
        freeform_id NUMBER;
        imgname_rec EMC_FTW_PREVA.EMC_Image_C_Mungo%rowtype;
        imgval_rec  EMC_FTW_PREVA.EMC_Content_C_Mungo%rowtype;
        CURSOR imgname_cur IS
            select * from EMC_FTW_PREVA.EMC_Image_C_Mungo
            where cs_ownerid in (
                        select id from EMC_FTW_PREVA.EMC_Image_C
                        where updateddate > '01-JUN-13'
                        and path is not null
                        and createddate != updateddate)
            and cs_attrid = (select id from EMC_FTW_PREVA.EMC_ATTRIBUTE where name = 'Image_Upload');
    BEGIN
        OPEN imgname_cur;
        LOOP
          FETCH imgname_cur INTO imgname_rec;
          EXIT WHEN imgname_cur%NOTFOUND;
          total_val := 'EMC_Image_C_' || imgname_rec.cs_ownerid;
          sql_stmt := 'SELECT instr(textvalue,''' || total_val || '''), cs_ownerid FROM EMC_FTW_PREVA.EMC_Content_C_Mungo a Where cs_attrid = (select id from EMC_FTW_PREVA.EMC_ATTRIBUTE where name = ' || '''' || 'Body_freeform' || '''' || ')';
            OPEN c FOR sql_stmt;
            LOOP
              FETCH c INTO freeform_id,freeform_name;
              EXIT WHEN c%NOTFOUND;
                                      IF freeform_id > 0 THEN
                dbms_output.put_line (imgname_rec.cs_ownerid || ',' || total_val || ',' || freeform_id || ',' || freeform_name);
                                      END IF;
            END LOOP;
            CLOSE c;     
       END LOOP;
       CLOSE imgname_cur;
    END;
    Thanks in Advance.

    can you guys suggest me how can I use pl/sql tables for the below query to incresing the performance.
    There would be absolutely no point at all in improving the performance of code that has NO benefit.
    The only result of executing that code is to possibly produce some lines of output AFTER the entire procedure if finished:
    dbms_output.put_line (imgname_rec.cs_ownerid || ',' || total_val || ',' || freeform_id || ',' || freeform_name);
    So first you need to explain:
    1. what PROBLEM you are trying to solve?
    2. why you are trying to use PL/SQL code to solve it.
    3. why are you using 'slow by slow' (row by row) processing and then, for each row, opening a new cursor to query more data?
    You should be using a single query rather than two nested cursors. But that begs the question of what the code is even supposed to be doing since the only output is going to a memory buffer.

  • How to convert pl/sql code into java/j2ee

    Hi,
    We have a PL/SQL Oracle App server application that we will support if we can convert in j2ee/java. But when i did take a look at the code, these pl/sql contains all HTML and java code inside the stored procedures.
    And iam looking to explore some tools and mechanisms that can convert these pl/sql in a JAVA application so that i can deploy this new app into my BEA81 environment.
    Does any body has any idea:
    a) How to convert from pl/sql > java ?
    b) Any plugins or tools of BEA that can run these pl/sql (the way thay are currently...i.e w/o converting) in BEA 81 container ?
    thanks, sangita

    these pl/sql contains all HTML and java code insideJava or JavaScript. They are not the same. I wouldn't expect to see Java inside html, whereas JavaScript would be intermixed. On the other hand you might have a java stored proc (Oracle 9/10) which is generating HTML.
    >
    Does any body has any idea:Refactor.
    I doubt it just has html and JavaScript/Java. So what you have is a mess that mixes several things that should have been seperate in the first place.

  • Can anyone help me in a problem with PL/SQL Tables & the Java getArray()

    The problem is the following:
    I would tike to get a PL/SQL Table (a table of varchar2) into a Java String Array.
    It works very well except that instead of getting the characters in the PL/SQL Table
    I receive the character codes in each string.
    In the following example i should get:
    spring
    summer
    outumn
    winter
    Instead I get:
    0x737072696E67
    0x73756D6D6572
    0x6F7574756D6E
    0x77696E746572
    Steps to try the sample
    1)Creating the following type
    create or replace TYPE CHAR_ARRAY IS TABLE OF VARCHAR(32767);
    2)Creating the following stored procedure
    create or replace PROCEDURE MQ_MSG_PROCESSOR
       MessageText in VARCHAR2,
       QueueName out VARCHAR2,
       RplyMessage out CHAR_ARRAY,
       HastoCommit out NUMBER
    AS
       RMessage CHAR_ARRAY;
    BEGIN
       QueueName:='DEV_OUT';
       RMessage:=CHAR_ARRAY();
       RMessage.Extend(4);
       RMessage(1):='spring';
       RMessage(2):='summer';
       RMessage(3):='outumn';
       RMessage(4):='winter';
       HastoCommit:=1;
       RplyMessage:=RMessage;
    END;
    3)Copiling and running the following java class
    import java.sql.*;
    import oracle.sql.*;
    import oracle.jdbc.oracore.Util;
    import oracle.jdbc.driver.*;
    import java.util.Dictionary;
    public class ArrayExample
       public static void main (String args[]) throws Exception
          MSG Msg=null;
          oracle.sql.ARRAY RMsg=null;
          DriverManager.registerDriver(new oracle.jdbc.driver.OracleDriver());
          Connection conn = DriverManager.getConnection ("jdbc:oracle:oci8:@test","test", "test");
          conn.setAutoCommit (false);
          try
             String []array={};
             ArrayDescriptor desc=ArrayDescriptor.createDescriptor("CHAR_ARRAY",conn);
             ARRAY CHAR_ARRAY=new ARRAY(desc,conn,array);
             OracleCallableStatement sproc = (OracleCallableStatement)conn.prepareCall("{call GSM.MQ_TST.MQ_MSG_PROCESSOR(?, ?, ?, ?)}");
             sproc.setString(1, "hello"); //MessageText
             sproc.registerOutParameter(2, OracleTypes.VARCHAR);   //QueueName
             sproc.registerOutParameter(3, OracleTypes.ARRAY,"CHAR_ARRAY");   //RplyMessage
             sproc.registerOutParameter(4, OracleTypes.NUMBER);      //HastoCommit
             sproc.execute();
             CHAR_ARRAY=(oracle.sql.ARRAY)sproc.getARRAY(3);
             array = (String [])CHAR_ARRAY.getArray();
             for(int i=0;i<array.length;i++)
                System.out.println(array);
          catch(SQLException e)
             System.out.println("Error while trying to execute MQ_MSG_PROCESSOR");
             System.out.println(e);
          conn.close();

    Hi,
    I tried the code with same procedure.
    That works out fine for me..
    and it prints out exactly the same words as you mentioned..:))
    may be you must have changed something later on.. which started printing character codes..
    but for me it works perfectly fine..
    All The Best..
    Regards
    Gurudatt
    The problem is the following:
    I would tike to get a PL/SQL Table (a table of
    varchar2) into a Java String Array.
    It works very well except that instead of getting the
    characters in the PL/SQL Table
    I receive the character codes in each string.
    In the following example i should get:
    spring
    summer
    outumn
    winter
    Instead I get:
    0x737072696E67
    0x73756D6D6572
    0x6F7574756D6E
    0x77696E746572
    Steps to try the sample
    1)Creating the following type
    create or replace TYPE CHAR_ARRAY IS TABLE OF
    VARCHAR(32767);
    2)Creating the following stored procedure
    create or replace PROCEDURE MQ_MSG_PROCESSOR
    ���MessageText in VARCHAR2,
    ���QueueName out VARCHAR2,
    ���RplyMessage out CHAR_ARRAY,
    ���HastoCommit out NUMBER
    AS
    ���RMessage CHAR_ARRAY;
    BEGIN
    ���QueueName:='DEV_OUT';
    ���RMessage:=CHAR_ARRAY();
    ���RMessage.Extend(4);
    ���RMessage(1):='spring';
    ���RMessage(2):='summer';
    ���RMessage(3):='outumn';
    ���RMessage(4):='winter';
    ���HastoCommit:=1;
    ���RplyMessage:=RMessage;
    END;
    3)Copiling and running the following java class
    import java.sql.*;
    import oracle.sql.*;
    import oracle.jdbc.oracore.Util;
    import oracle.jdbc.driver.*;
    import java.util.Dictionary;
    public class ArrayExample
    ���public static void main (String
    args[]) throws Exception
    ���{
    ������MSG Msg=null;
    ������oracle.sql.ARRAY
    RMsg=null;
    ������DriverManager.regis
    erDriver(new oracle.jdbc.driver.OracleDriver());
    ������Connection conn =
    DriverManager.getConnection
    ("jdbc:oracle:oci8:@test","test", "test");
    ������conn.setAutoCommit
    (false);
    ������try
    ������{
    ���������S
    ring []array={};
    ���������A
    rayDescriptor
    desc=ArrayDescriptor.createDescriptor("CHAR_ARRAY",conn
    ���������A
    RAY CHAR_ARRAY=new ARRAY(desc,conn,array);
    ���������O
    acleCallableStatement sproc =
    (OracleCallableStatement)conn.prepareCall("{call
    GSM.MQ_TST.MQ_MSG_PROCESSOR(?, ?, ?, ?)}");
    ���������s
    roc.setString(1, "hello"); //MessageText
    ���������s
    roc.registerOutParameter(2,
    OracleTypes.VARCHAR);���//QueueName
    ���������s
    roc.registerOutParameter(3,
    OracleTypes.ARRAY,"CHAR_ARRAY");���//Rpl
    Message
    ���������s
    roc.registerOutParameter(4,
    OracleTypes.NUMBER);������
    //HastoCommit
    ���������s
    roc.execute();
    ���������C
    AR_ARRAY=(oracle.sql.ARRAY)sproc.getARRAY(3);
    ���������a
    ray = (String [])CHAR_ARRAY.getArray();
    ���������f
    r(int i=0;i<array.length;i++)
    ���������{
    System.out.println(array);
    ���������}
    ������}
    ������catch(SQLException
    e)
    ������{
    ���������S
    stem.out.println("Error while trying to execute
    MQ_MSG_PROCESSOR");
    ���������S
    stem.out.println(e);
    ������}
    ������conn.close();
    ���}

  • How to isolate the Sql Statement from Java Code

    Hi
    I Need to know that can we segregate the Sql Statements and convert them to Stored Procedures so as to isolate the Sql statements from Java Code.
    So i have one static web page which uses four select Statements so what i want is to create a stored procedure encapsulating these queries. So that the Java Web Developer will simply call the Stored Procedure instead of using four different SQL Statements.
    Suppose the developer has these four Statements
    Select ename,empno,sal,job from emp;
    select empno,ename,mgr from emp;
    select deptno,dname from dept;
    select emp.ename,emp.empno,emp.deptno,dept,dname fromemp,dept;
    So can i encapsulate these four Sql Statements in one Procedure and the Web developer can call the Store procedure and dont need to write the Sql Statements in his code.
    Can Anybody guide me how to write this Stored type of Store procedure.
    Thanks

    http://www.google.com/search?q=java+windows+registry
    Next time, search yourself. It might be beyond your belief, but you're really, really not the first person to wonder about this.

  • How i connect to SQL server using java?

    hi every body
    i need to connect to a sql server database using java
    i do not know sql driver in java
    plz help me
    thanks

    This is certainly the wrong forum for that question. Search in the JDBC forum. This has been asked and answered many times.

  • Passing pl/sql table to Java using Oracle JDBC and vice - versa

    A small article on the given topic with sample code and comments, to make code crystal:
    http://mukx.blogspot.com/2007/12/passing-plsql-table-to-java-using.html
    --Mukul                                                                                                                                                                                                                                                                                                                                                           

    Tapash,
    I have seen people using Rosetta in almost all projects in previous years, frequently in couple of projects. I was not aware that Rosetta is an internal thing, anyways if that is the case y oracle is shipping rosetta jar file to customers?
    --Mukul                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

  • How to invoke PL/SQL Table parameter in the query string?

    Hello,
    I've met a problem invoking PL/SQL Table parameter in the query string, in OWS 3.0.
    What I'm going to do is, to invoke a stored procedure to generate a web page using PL/SQL Web Toolkit 2.0, like: "http://.../owa/test_proc".
    But there is a IN parameter for this procedure, and it's a PL/SQL Table variable. So I can't invoke the procedure sucessfully just using "http://.../owa/test_proc?v_plsql=i_plsql".
    Did someone have met this kind of problem or have the answer to it? Thanks so much for your help.

    When using procedures with pl/sql-tables as parameter they should be overloaded, e.g.:
    procedure my_procedure (my_var in varchar2)...
    and
    procedure my_procedure (my_var in owa_util.ident_arr)
    the procedure then can be called with:
    http://..../my_procedure?my_var=Scott, which invokes the version with the varchar2 parameter, or
    http://..../my_procedure?my_var=Scott&my_var=Miller......
    which invokes the version with the pl/sql-Table
    Another solution might be the use of flexible parameters, passing pairs of parameter_name, parameter_value to your procedure. Your procedure looks like:
    procedure my_procedure (name_array IN owa.vc_arr, value_array IN owa.vc_arr)..
    and is invoked (note the ! )
    http://..../!my_procedure?ename=Scott&sal=200&job=clerk.....
    looping through the pl/sql tables will retrieve values of ename, sal and job for name_array and Scott, 200 and clerk for value_array
    Hth
    null

Maybe you are looking for

  • 2G iPod Touch won't synch or charge with computer.

    I have a 2nd gen. iPod Touch and when i plug it into my computer it won't recognize it, charge it, or synch it. The only thing that happens when you plug it in is the computer makes 3 fast, same pitched tones. It's kind of like when you would normall

  • Problem In The Query

    Hai All,            I have created a login form in screen painter (which contains two textbox and a login button). When login button is clicked, I want to check whether the username and password matches in the table (@EMPA). I have a problem while ch

  • Problem with Yahoo search infringing trademarks, very disappointed that you moved away from Google.

    Google is responsive to trademark infringement complaint for its ADWORDS program. Yahoo's advertising program constantly permits advertisers to infringe trademarks and does not respond to complaints. Reflects really poorly on FireFox, which we used t

  • Sending google map contact via email

    In the last keynote (and in the mobile me video) we can see an email with a link to a restaurant via google map. How do the sedn such email with the iphone (or with a computer) ?? Coudnt find how they did that.. Thanks..

  • NW 7.01 Sp0 ABAP Trial-  MAXDB is not installing anymore

    Hi All,     I tried to install SAP Netweaver 7.01 trial version without MS loopback adapter  and it got failed with error code-200. I have uninstalled the MAXDB and ran Cleanup tool . I tried to install the trial after installing the MS loopback adap