PL/SQL table type in Forms 4.5

Hi
I am trying to use a pl/sql table type variable in Oracle forms 4.5 . I am able to compile this and run it on the database that the application connects to but in forms , it gives me a compilation error.
Is there some restriction on using this datatype in forms 4.5
Following is the syntax I am using:
TYPE block_list_type IS TABLE of VARCHAR2(200) INDEX BY BINARY_INTEGER;
block_list block_list_type;
I get fatal syntax error even though the syntax is correct(checked it on the database).
please let me know if I am doing something wrong.
thanks a lot

That explains it!!
Thanks. My company is on oracle 10.7 and is too reluctant to move to higher versions. They finally bought I2 and are developing their own custom java applications and will phase out 10.7 but are not willing to move to the next version of Oracle !!
Seems like they are done with Oracle .
thanks for the input anyways.

Similar Messages

  • Passing parameters to PL/SQL table types

    Hi Everybody,
    I have one question about passing PL/SQL tables types and tabs as IN parameter in procedure.I am working in 11.2.0.2.0 environment. I am stuck on how to pass those values to procedure.Please find below more details:
    Table 1:
    CREATE TABLE ITEMS
    ITEM_ID VARCHAR2(40 BYTE) NOT NULL,
    ITEM_NAME VARCHAR2(40 BYTE),
    SERIAL NUMBER(2),
    ADDED_ON DATE);
    Table 2:
    CREATE TABLE ITEM_ACTIVITY_INFO
    ITEM_ID VARCHAR2(40 BYTE) NOT NULL,
    ACCOUNT_TYPE VARCHAR2(1 BYTE),
    ID_NUMBER NUMBER(3),
    ACTIVATION_DATE DATE);
    Table 3:
    CREATE TABLE ITEM_GROUP
    GROUP_ID NUMBER(2) NOT NULL,
    ITEM_ID VARCHAR2(40 BYTE),
    GROUP_TYPE VARCHAR2(20 BYTE),
    GROUP_DATE DATE);
    Table 4:
    CREATE TABLE ITEM_ADDRESS
    GROUP_ID NUMBER(2) NOT NULL,
    NAME VARCHAR2(60 BYTE),
    ADDRESS VARCHAR2(100));
    Following types are created:
    CREATE OR REPLACE TYPE ITEMS_TYPE AS OBJECT
    ITEM_ID VARCHAR2(40 BYTE),
    ITEM_NAME VARCHAR2(40 BYTE),
    SERIAL NUMBER(2),
    ADDED_ON DATE);
    CREATE OR REPLACE TYPE ITEM_ACTIVITY_TYPE AS OBJECT
    ITEM_ID VARCHAR2(40 BYTE),
    ACCOUNT_TYPE VARCHAR2(1 BYTE),
    ID_NUMBER NUMBER(3),
    ACTIVATION_DATE DATE);
    CREATE OR REPLACE TYPE ITEM_GROUP_COMP_TYPE AS OBJECT
    GROUP_ID NUMBER(2) NOT NULL,
    ITEM_ID VARCHAR2(40 BYTE),
    GROUP_TYPE VARCHAR2(20 BYTE),
    GROUP_DATE DATE
    ITEM_ADDRESS_IN ITEM_ADDRESS_TYPE);
    CREATE OR REPLACE TYPE ITEM_ADDRESS_TYPE AS OBJECT
    GROUP_ID NUMBER(2),
    NAME VARCHAR2(60 BYTE),
    ADDRESS VARCHAR2(100));
    CREATE OR REPLACE TYPE ITEM_GROUP_COMP_TAB AS TABLE OF ITEM_GROUP_COMP_TYPE;
    Create or replace procedure ITEM_ADD_CHANGE(
    ITEM_IN IN ITEMS_TYPE,
    ITEM_ACTIVITY_IN IN ITEM_ACTIVITY_TYPE,
    ITEM_GROUP_IN IN ITEM_GROUP_COMP_TAB,
    ITEM_OUT IN OUT ITEMS.ITEM_ID%TYPE);
    Above are the paramteres we are passing to procedure.
    I need help in how to pass parameters to above procedure. All comments and responses will be highly appreciated. Thanks everyone for going through the post. Please let me know if more more information is required on this problem.
    Regards
    Dev

    Billy  Verreynne  wrote:
    Types used in this fashion, only make sense if the table is based on the type. It makes very little sense to have a table structure and then to duplicate the structure using a type.
    The 2 structures may be defined the same. But they are NOT interchangeable and requires one to be converted to the other to use. This is not sensible in my view. It is far easier in that case to simply use the PL/SQL macro +%RowType+ to create a duplicate structure definition - one that can natively be used for touching that table, without conversions required.
    If you do want to use types, define the type, then define the table of that type, adding the required constraints (pk, fk, not null, check) to the table's definition.Billy:
    Just curious, why do you say it makes very little sense to have a type modeled on a table? I do that a lot. In my case, I am getting the values from an external program, not building them manually, but it makes a lot of sense to me.
    One application where I do this a lot has a java front-end that parses HL7 messages. Each message contains at least minimal information about a variable number of entities (and often several rows for an entity) in the database, and must be processed as a single atomic trasnaction. So, rather than have potentially hundreds of parameters to the "main" driver procedures for different message types I created a set of types more or less identical to the tables representing the entities. The java program parses the mesasge and populates the type, then calls the appropriate stored procedure for the message type passing in the populated types. My stored procedure then does inserts/updates or deletes as appropriate over potentially dozens of tables.
    John

  • Passing PL/SQL table type as IN Parameter to DB Adapter

    Hi,
    I have an requirement to pass multiple record values(array of values) to an API from BPEL process.
    For this,
    1) I have created a package procedure having PL/SQL table type variable as IN Parameter.
    2) In the BPEL process, created a DB adpater pointing to the above API.(Created wrapper API impicitly)
    When I intiated the BPEL process passing multiple values, the API is taking only the first value, ignoring rest of the values.
    Any reason, why only the first value is accepted by the API ?
    Thanks,
    Rapp.

    If I understand correctly, JPublisher generates a wrapper API for an underlying API that takes a PL/SQL table as an IN parameter. The wrapper will generate and use a SQL nested table as the type for the IN parameter of the wrapper procedure.
    The DB adapter DOES support nested tables, varrays, and objects as IN parameters of an API. The problem you are seeing is most likely due to the way you are modeling your BPEL process, specifically with respect to your Assign activities.
    When you Assign TO an IN parameter, make sure that you drill down all the way and choose the parameter name in the InputParameters root element. Similarly, when you Assign FROM the API value, you must drill down and choose the name of the OUT parameter in the OutputParameters root element.
    In a Transform activity, you would use the FOR construct on the target side to get the values of the nested table or varray from the source side.

  • How to retrieve the values from PL/SQL table types.

    Hi Every one,
    I have the following procedure:
    DECLARE
    TYPE t1 IS TABLE OF emp%ROWTYPE
    INDEX BY BINARY_INTEGER;
    t t1;
    BEGIN
    SELECT *
    BULK COLLECT INTO t
    FROM emp;
    END;
    This procedure works perfectly fine to store the rows of employee in a table type. I am not able to retrieve the values from Pl/SQL table and display it using dbms_output.put_line command.
    Can anybody help me please!!!!!
    Thanks
    Ahmed.

    You mean, you can't add this
    for i in t.first..t.last loop
    dbms_output.put_line(t(i).empno||' '||t(i).ename||' '||t(i).job);
    end loop;or you can't add this
    set serveroutput onor maybe, you are working in third party application where dbms_output is not applicable at all?
    You see, not able like very similar it is not working - both are too vague...
    Best regards
    Maxim

  • Database Adapter does not generate proper output for PL/SQL table type

    Hi,
    I have a DB Adapter to invoke a stored procedure on Oracle which returns a table type.
    I am getting the following output from the adapter:
    </DB_Test_InputVariable><DB_Test_OutputVariable><part xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" name="OutputParameters">
    <db:OutputParameters xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:db="http://xmlns.oracle.com/pcbpel/adapter/db/APPS/BPEL_DB_TEST/XXC_KEMET_TEST_PKG-24GETITEMONH/">
    <ITEM_QTY_UOM_OUT>
    <ITEM_QTY_UOM_OUT_ITEM>
    <SERIAL_NUM>1</SERIAL_NUM>
    <ITEM_QTY_OUT>1</ITEM_QTY_OUT>
    <UOM_OUT>BOX</UOM_OUT>
    </ITEM_QTY_UOM_OUT_ITEM>
    <ITEM_QTY_UOM_OUT_ITEM>
    <SERIAL_NUM>2</SERIAL_NUM>
    <ITEM_QTY_OUT>5</ITEM_QTY_OUT>
    <UOM_OUT>BOX</UOM_OUT>
    </ITEM_QTY_UOM_OUT_ITEM>
    </ITEM_QTY_UOM_OUT>
    </db:OutputParameters>
    </part>
    </DB_Test_OutputVariable>
    When I try to transform it, it tries to select /db:OutputParameters/db:ITEM_QTY_UOM_OUT/db:ITEM_QTY_UOM_OUT_ITEM/db:SERIAL_NUM from it and does not give me any output.
    I assume it's the same issue with namespace prefix.
    If anyone has faced a similar issue or knows how to fix this, please let me know.

    I am using a DB adapter to run a stored procedure for a simple Select Query with a table as my out parameter.This creates an XSD when the partner link is created.The elementFormDefault=qualified is by default formed in the xsd.When i change it to unQualified it returns me compilation error.
    Where do i need to change the root element?
    My output of BPEL(P.S. - I have used synchronous BPEL) on the console is
    Your test request was processed synchronously. It took 359.0milliseconds to finish and generated the following output:
    Value: <ProcessResponsehttp://www.w3.org/2001/XMLSchema-instancehttp://www.example.org>
    <null>
    <null>
    <null>database_K_DKL_NW02</null>
    <null>2008-07-07T00:00:00.000+05:30</null>
    <null>2008</null>
    <null>3435</null>
    <null>http://www.google.com</null>
    </null>
    <null>
    <null>database_config.txt</null>
    <null>2006-03-14T00:00:00.000+05:30</null>
    <null>2006</null>
    <null>342345</null>
    <null>\\01hw180464\MOTO\database_config.txt</null>
    </null>
    <null>
    <null>database_help.txt</null>
    <null>2008-07-01T00:00:00.000+05:30</null>
    <null>2008</null>
    <null>68</null>
    <null>\\01hw180464\MOTO\database_help.txt</null>
    </null>
    <null>
    <null>database_search.txt</null>
    <null>2007-12-03T00:00:00.000+05:30</null>
    <null>2007</null>
    <null>365</null>
    <null>\\01hw180464\MOTO\database_search.txt</null>
    </null>
    </null>
    </ProcessResponse>
    whereas the output shown in Invoke in the visual flow is
    <messages>
    -<Invoke_1_Callin_Db_InputVariable>
    -<part xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" name="InputParameters">
    -<InputParameters xmlns="http://xmlns.oracle.com/pcbpel/adapter/db/VODAT/BPEL_CALLIN_DB/MOTOROLA_BSC_DB-24VIEW_MOTOROLA/">
    <IN_FILENAME/>
    </InputParameters>
    </part>
    </Invoke_1_Callin_Db_InputVariable>
    -<Invoke_1_Callin_Db_OutputVariable>
    -<part xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" name="OutputParameters">
    -<db:OutputParameters xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:db="http://xmlns.oracle.com/pcbpel/adapter/db/VODAT/BPEL_CALLIN_DB/MOTOROLA_BSC_DB-24VIEW_MOTOROLA/">
    -<MYCURSOR>
    -<MYCURSOR_ITEM>
    <SOFTWARE_PKGS>database_K_DKL_NW02
    </SOFTWARE_PKGS>
    <CREATION_DATE>2008-07-07T00:00:00.000+05:30
    </CREATION_DATE>
    <CREATION_TIME>2008
    </CREATION_TIME>
    <FILE_SIZE>3435
    </FILE_SIZE>
    <FILE_PATH>http://www.google.com
    </FILE_PATH>
    </MYCURSOR_ITEM>
    -<MYCURSOR_ITEM>
    <SOFTWARE_PKGS>database_config.txt
    </SOFTWARE_PKGS>
    <CREATION_DATE>2006-03-14T00:00:00.000+05:30
    </CREATION_DATE>
    <CREATION_TIME>2006
    </CREATION_TIME>
    <FILE_SIZE>342345
    </FILE_SIZE>
    <FILE_PATH>\\01hw180464\MOTO\database_config.txt
    </FILE_PATH>
    </MYCURSOR_ITEM>
    -<MYCURSOR_ITEM>
    <SOFTWARE_PKGS>database_help.txt
    </SOFTWARE_PKGS>
    <CREATION_DATE>2008-07-01T00:00:00.000+05:30
    </CREATION_DATE>
    <CREATION_TIME>2008
    </CREATION_TIME>
    <FILE_SIZE>68
    </FILE_SIZE>
    <FILE_PATH>\\01hw180464\MOTO\database_help.txt
    </FILE_PATH>
    </MYCURSOR_ITEM>
    -<MYCURSOR_ITEM>
    <SOFTWARE_PKGS>database_search.txt
    </SOFTWARE_PKGS>
    <CREATION_DATE>2007-12-03T00:00:00.000+05:30
    </CREATION_DATE>
    <CREATION_TIME>2007
    </CREATION_TIME>
    <FILE_SIZE>365
    </FILE_SIZE>
    <FILE_PATH>\\01hw180464\MOTO\database_search.txt
    </FILE_PATH>
    </MYCURSOR_ITEM>
    </MYCURSOR>
    </db:OutputParameters>
    </part>
    <part xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" name="response-headers">[]
    </part>
    </Invoke_1_Callin_Db_OutputVariable>
    </messages>
    and the output shown in ReplyOutput is :-
    <outputVariable>
    -<part xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" name="payload">
    -<ProcessResponse xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://www.example.org">
    -<MYCURSOR xmlns="">
    -<MYCURSOR_ITEM>
    <SOFTWARE_PKGS>database_K_DKL_NW02
    </SOFTWARE_PKGS>
    <CREATION_DATE>2008-07-07T00:00:00.000+05:30
    </CREATION_DATE>
    <CREATION_TIME>2008
    </CREATION_TIME>
    <FILE_SIZE>3435
    </FILE_SIZE>
    <FILE_PATH>http://www.google.com
    </FILE_PATH>
    </MYCURSOR_ITEM>
    -<MYCURSOR_ITEM>
    <SOFTWARE_PKGS>database_config.txt
    </SOFTWARE_PKGS>
    <CREATION_DATE>2006-03-14T00:00:00.000+05:30
    </CREATION_DATE>
    <CREATION_TIME>2006
    </CREATION_TIME>
    <FILE_SIZE>342345
    </FILE_SIZE>
    <FILE_PATH>\\01hw180464\MOTO\database_config.txt
    </FILE_PATH>
    </MYCURSOR_ITEM>
    -<MYCURSOR_ITEM>
    <SOFTWARE_PKGS>database_help.txt
    </SOFTWARE_PKGS>
    <CREATION_DATE>2008-07-01T00:00:00.000+05:30
    </CREATION_DATE>
    <CREATION_TIME>2008
    </CREATION_TIME>
    <FILE_SIZE>68
    </FILE_SIZE>
    <FILE_PATH>\\01hw180464\MOTO\database_help.txt
    </FILE_PATH>
    </MYCURSOR_ITEM>
    -<MYCURSOR_ITEM>
    <SOFTWARE_PKGS>database_search.txt
    </SOFTWARE_PKGS>
    <CREATION_DATE>2007-12-03T00:00:00.000+05:30
    </CREATION_DATE>
    <CREATION_TIME>2007
    </CREATION_TIME>
    <FILE_SIZE>365
    </FILE_SIZE>
    <FILE_PATH>\\01hw180464\MOTO\database_search.txt
    </FILE_PATH>
    </MYCURSOR_ITEM>
    </MYCURSOR>
    </ProcessResponse>
    </part>
    </outputVariable>
    Can you please tell me why am i getiing null value in my output xml in my BPEL console??
    What is the solution?where do i need to change the db: prefix?

  • Retrieving PL/SQL Table Type returned by stored procedure using Java.

    Hi All,
    I am facing an issue in a Stored Procedure (SP) which returns Table Type, the PL/SQL complex type.
    Below mentioned is how my stored procedure looks like.
    CREATE OR REPLACE package sp_test_pkg as
    TYPE v_value_table_type is table of SW_VALID_CODE.swValue%Type
    index by binary_integer;
    v_swRMAStatus v_value_table_type;
    procedure sp_test
    (locale      in int,
              name      in SW_CODE.swName%Type,
              v_value_table out v_value_table_type,
    batch_size in int,
    out_batch_size in out int,
    status out int);
    end sp_test_lcode_code_pkg;
    My java program to access this stored procedure is as given below:
    import java.sql.*;
    import oracle.jdbc.driver.*;
    public class OracleTest {       
         public static void main(String args[]) {
         Connection con = null;
    OracleCallableStatement cstmt = null;
    String url = "url";
         String userName = "username";     
         String password = "password";
    try
              DriverManager.registerDriver (new oracle.jdbc.driver.OracleDriver());     
              con = DriverManager.getConnection(url, userName, password);
         cstmt = (OracleCallableStatement)con.prepareCall("begin " +
              "sp_test_pkg.sp_test_pkg(?,?,?,?,?,?); end;");
              cstmt.setInt(1, 1);
         cstmt.setString(2, "Test");
              cstmt.registerOutParameter(3, OracleTypes.ARRAY);
              cstmt.setInt(4, 10);
              cstmt.setInt(5, 1);
              cstmt.registerOutParameter(5, Types.INTEGER);
              cstmt.registerOutParameter(6, Types.INTEGER);
              cstmt.execute();
    } catch(Exception ex) {
    ex.printStackTrace(System.err);
    } finally {
    if(cstmt != null) try{cstmt.close();}catch(Exception _ex){}
    if(con != null) try{con.close();}catch(Exception _ex){}
    When i execute this java program, i get the following error:
    java.sql.SQLException: Parameter Type Conflict: sqlType=2003
         at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:187)
         at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:229)
         at oracle.jdbc.driver.OracleCallableStatement.registerOutParameterBytes(OracleCallableStatement.java:245)
         at oracle.jdbc.driver.OracleCallableStatement.registerOutParameter(OracleCallableStatement.java:389)
         at oracle.jdbc.driver.OracleCallableStatement.registerOutParameter(OracleCallableStatement.java:452)
         at OracleTest.main(OracleTest.java:49)
    I am not sure where i am going wrong. I have never worked on such complex types before. I want to retrieve the complex table type returned by the stored procedure using my java source code.
    Can anyone please help me out in resolving this issue?. This is very urgent.

    JDBC does not recognise types declared in PL/SQL. This is documented in the Dev Guide. [Find out more|http://download-west.oracle.com/docs/cd/B10501_01/java.920/a96654/oraarr.htm#1057625].
    The only work around would be to build a wrapper which calls your existing PL/SQL procedures and returns a SQL type instead. Obviously not knowing your precise scenario I have no idea how much work this entails for you. It may be worth building a code generator.
    Cheers, APC
    blog: http://radiofreetooting.blogspot.com

  • Need help on syntax of PL/SQL Table type

    Hi Everyone
    I have the following Procedure
    DECLARE
    TYPE ln_empno IS TABLE OF NUMBER;
    ln_empno1 ln_empno;
    dml_errors EXCEPTION;
    PRAGMA EXCEPTION_INIT (dml_errors, -24381);
    ERRORS NUMBER;
    BEGIN
    UPDATE emp
    SET empno = empno
    RETURN empno
    BULK COLLECT INTO ln_empno1;
    FORALL idx IN 1 .. ln_empno1.COUNT SAVE EXCEPTIONS
    INSERT INTO t1
    VALUES (ln_empno1 (idx));
    EXCEPTION
    WHEN dml_errors
    THEN
    ERRORS := SQL%BULK_EXCEPTIONS.COUNT;
    FOR i IN 1 .. ERRORS
    LOOP
    DBMS_OUTPUT.put_line ( 'Error '
    || i
    || ' occurred during '
    || 'iteration '
    || SQL%BULK_EXCEPTIONS (i).ERROR_INDEX
    DBMS_OUTPUT.put_line ( 'Oracle error is '
    || SQLERRM (-SQL%BULK_EXCEPTIONS (i).ERROR_CODE
    END LOOP;
    END;
    This will collect the single column, I am not able to get the syntax to create a record containg empno and ename and bulk collect into a collection type.
    Can anyone help me to execute this procedure for ln_empno as a record of empno and ename.
    Thanks in Advance
    -Ahmed

    Also,
    If you want it as an update then why not just alter as per my example... e.g.
    SQL> ed
    Wrote file afiedt.buf
      1  DECLARE
      2    TYPE lt_emp_rec IS RECORD (empno NUMBER, deptno NUMBER);
      3    TYPE lt_emp IS TABLE OF lt_emp_rec INDEX BY PLS_INTEGER;
      4    lr_emp lt_emp;
      5  BEGIN
      6    UPDATE emp
      7    SET deptno = deptno+10
      8    RETURNING empno, deptno
      9    BULK COLLECT INTO lr_emp;
    10    FOR idx IN 1 .. lr_emp.COUNT
    11    LOOP
    12      DBMS_OUTPUT.PUT_LINE('EmpNo: '||to_char(lr_emp(idx).empno)||' ::: DeptNo: '||to_char(lr_emp(idx).deptno));
    13    END LOOP;
    14* END;
    SQL> /
    EmpNo: 7369 ::: DeptNo: 30
    EmpNo: 7499 ::: DeptNo: 40
    EmpNo: 7521 ::: DeptNo: 40
    EmpNo: 7566 ::: DeptNo: 30
    EmpNo: 7654 ::: DeptNo: 40
    EmpNo: 7698 ::: DeptNo: 40
    EmpNo: 7782 ::: DeptNo: 20
    EmpNo: 7788 ::: DeptNo: 30
    EmpNo: 7839 ::: DeptNo: 20
    EmpNo: 7844 ::: DeptNo: 40
    EmpNo: 7876 ::: DeptNo: 30
    EmpNo: 7900 ::: DeptNo: 40
    EmpNo: 7902 ::: DeptNo: 30
    EmpNo: 7934 ::: DeptNo: 20
    PL/SQL procedure successfully completed.
    SQL>Was that so hard?

  • SQL table type - How to retrieve in Java?

    Hello,
    I need to return a SQL object to Java from a PL/SQL function.
    In PL/SQL, sample code to create the scalar types, function and calling script would be:
    CREATE OR REPLACE TYPE tMessage AS OBJECT (tType CHAR(20), tText VARCHAR2 (400));
    CREATE OR REPLACE TYPE tMessage_Table AS TABLE OF tMessage;
    CREATE OR REPLACE FUNCTION Return_Message RETURN tMessage_Table AS
    vTable tMessage_Table;
    BEGIN
    vTable := tMessage_Table(NULL);
    vTable.Extend(1);
    vTable(1) := tMessage ('Header', 'Business Rule');
    vTable.Extend(1);
    vTable(2) := tMessage ('Phn', '9053098461');
    -- Output the data to reporting caller
    RETURN vTable;
    END Return_Message;
    DECLARE
    vTmp_Track tMessage_Table;
    BEGIN
    vTmp_Track := Return_Message;
    FOR i IN 1..vTmp_Track.Count LOOP
    DBMS_OUTPUT.PUT_LINE (vTmp_Track(i).tType);
    DBMS_OUTPUT.PUT_LINE (vTmp_Track(i).tText);
    DBMS_OUTPUT.PUT_LINE (' ');
    END LOOP;
    END;
    Is there a way in Java to declare and retrieve an object of type tMessage_Table?
    The only other way I can think of doing this would be to create a table and a ref cursor to browse over it, which I can read back from Java.
    Thank you.

    25266,
    Following code was executed using JDK 1.4.2_07, Oracle 9i (9.2.0.4) database, and "ojdbc14.jar" JDBC (thin) driver:
    [Note that I used your "type" definitions and PL/SQL function.]
    import java.sql.Array;
    import java.sql.CallableStatement;
    import java.sql.Connection;
    import java.sql.DriverManager;
    import java.sql.Struct;
    import java.sql.Types;
    import java.util.Arrays;
    public class SqlStruc {
      public static void main(String[] args) {
        CallableStatement cs = null;
        Connection dbConn = null;
        String url = "jdbc:oracle:thin:scott/tiger@host:1526:orcl";
        try {
          Class.forName("oracle.jdbc.driver.OracleDriver");
          dbConn = DriverManager.getConnection(url);
          cs = dbConn.prepareCall("{? = call RETURN_MESSAGE()}");
          cs.registerOutParameter(1, Types.ARRAY, "T_MSG_TBL");
          cs.execute();
          Object obj = cs.getObject(1);
          System.out.println(obj);
          if (obj != null) {
            System.out.println("Class: " + obj.getClass().getName());
          Array arr = (Array) obj;
          Object[] objArr = (Object[]) arr.getArray();
          for (int i = 0; i < objArr.length; i++) {
            Struct struct = (Struct) objArr;
    Object[] attrs = struct.getAttributes();
    System.out.println(Arrays.asList(attrs));
    catch (Exception x) {
    System.err.println("SqlStruc: Exception caught.");
    x.printStackTrace();
    finally {
    if (cs != null) {
    try {
    cs.close();
    catch (Exception x) {
    System.err.println("Failed to close statement.");
    x.printStackTrace();
    if (dbConn != null) {
    try {
    dbConn.close();
    catch (Exception x) {
    System.err.println("Failed to close database connection.");
    x.printStackTrace();
    And results were:
    oracle.sql.ARRAY@166a22b
    Class: oracle.sql.ARRAY
    [Header              , Business Rule]
    [Phn                 , 9053098461]Good Luck,
    Avi.

  • 2 sql tables 1 java form...

    so im making a program for my 1st year exam and there is this create user form that is driving me crazy...
    In the form there is these fields Firstname, Lastname, Address, Zipcode, City, Phonenr, EAN Nr, Ref, Username and Password.
    In my MsSQL db i have 2 tables, login and user.
    Table user has a pk that is named userid whch is a identity colum and table login has fk named userid.
    Now what i want is that when the user adds info to the form and presses the okay buttom gets placed in the two different tables.
    But i get this exception com.microsoft.sqlserver.jdbc.SQLServerException: The INSERT statement conflicted with the FOREIGN KEY constraint "FK_login_user". The conflict occurred in database "gruppe1", table "dbo.user", column 'userid'.
    I hope some one can help, i have included a whole lot of code but if you need more say so..
    Method for inserting user
    public User createUser(User u) throws SQLException {
            Connection con = getConnection();
            try {
                PreparedStatement ps = con.prepareStatement("INSERT INTO bruger VALUES (?, ?, ?, ?, ?, ?, ?, ?)", PreparedStatement.RETURN_GENERATED_KEYS);
                ps.setString(1, u.getFirstName());
                ps.setString(2, u.getLastName());
                ps.setString(3, u.getAddress());
                ps.setInt(4, u.getZip());
                ps.setString(5, u.getCity());
                ps.setInt(6, u.getPhone());
                ps.setInt(7, u.getEan());
                ps.setString(8, u.getRefId());
                ps.executeUpdate();
                ResultSet keys = ps.getGeneratedKeys();
                keys.next();
                int usrid = keys.getInt(1);
                return new User(usrid, u.getFirstName(), u.getLastName(), u.getAddress(), u.getZip(), u.getCity(), u.getPhone(), u.getEan(), u.getRefId());
            } finally {
                con.close();
        }Method for inserting login info
        public Login createLogin(Login log) throws SQLException
          Connection con = getConnection();
          try
              PreparedStatement ps = con.prepareStatement("INSERT INTO login VALUES (?, ?, ?, ?)", PreparedStatement.RETURN_GENERATED_KEYS);
              ps.setString(1, log.getBrugernavn());
              ps.setString(2, log.getPassword());
              ps.setInt(3, log.getAccesslevel());
              ps.setInt(4, log.getBrugerid());
              ps.executeUpdate();
              ResultSet keys = ps.getGeneratedKeys();
              keys.next();
              int logid = keys.getInt(1);
              return new Login(logid, log.getBrugernavn(), log.getPassword(), log.getAccesslevel(), log.getBrugerid());
              finally
                  con.close();
          }method for okay button
        private void jButton2MouseClicked(java.awt.event.MouseEvent evt)                                     
            User usr = new User();
            Login log = new Login();
            DBmanager dbman = new DBmanager();
                usr.setFirstName(firstNameField.getText());
                usr.setLastName(lastNameField.getText());
                usr.setAddress(addressField.getText());
                usr.setZip(Integer.parseInt(zipField.getText()));
                usr.setPhone(Integer.parseInt(phoneField.getText()));
                usr.setEan(Integer.parseInt(eanField.getText()));
                usr.setRefId(refField.getText());
                usr.setCity(cityField.getText());
                log.setBrugernavn(userNameField.getText());
                log.setPassword(passWordField.getText());
                log.setBrugerid(usr.getId());
                try {
                    dbman.createUser(usr);
                    dbman.createLogin(log);
                } catch (SQLException ex) {
                    Logger.getLogger(createUserView.class.getName()).log(Level.SEVERE, null, ex);
        }                  It adds the user part into the user table but not the login part, i know it´s because it dosent transfer the userid from user table to login table..
    How to do it?
    I know my code is a bit messy so dont bash me :P
    thank you

    theomi wrote:
    This is what i wanna do in java but i have trouble "translating" it
    use gruppe1
    insert into bruger (firstname, lastname, address, zipcode)
    values ('ib', 'mathiesen', 'kongevej 2', 6510)
    INSERT INTO login (username, userid)
    values ('ib', @@IDENTITY)
    SELECT userid
    FROM user c
    WHERE NOT EXISTS
    SELECT *
    FROM login x
    WHERE x.userid = c.userid
    Yes, I have a problem converting that too, since you have 2 seperate statements here instead of a complex insert--insert from a select.
    You need something along the line of:
    insert into login (username, userid)
      select username, userid from user c where not exists(
        select 1 from login x where x.userid = c.userid and
          c.username = <myUserName>)This is not tested SQL, but is of the form you need to use.

  • DB Adapter not returning all columns from a sql table type

    Using Soa Suite 10.1.3.4.
    Calling DB Adapter from bpel to a database package procedure with an OUT NOCOPY parameter based on a TABLE OF type.
    It works fine except that I only get the first 14 columns out of 55.
    Can query all columns from Sqldeveloper or Sqlplus.
    XML skema reflects all columns correct.
    Same result without NOCOPY in parameter.
    HaveI missed some details/limitations?

    hi
    here is how I solved it.
    first create custom view that will find all requred data.
    in my case it was
    tables :
    ADRCITYT
    ADRCITY
    ADRPCDCITY
    T005S
    T005U
    joins :
    ADRCITY     CLIENT     =     ADRCITYT     CLIENT
    ADRCITY     COUNTRY     =     ADRCITYT     COUNTRY
    ADRCITY     CITY_CODE     =     ADRCITYT     CITY_CODE
    ADRCITY     CLIENT     =     ADRPCDCITY     CLIENT
    ADRCITY     COUNTRY     =     ADRPCDCITY     COUNTRY
    ADRCITY     CITY_CODE     =     ADRPCDCITY     CITY_CODE
    T005S     MANDT     =     ADRCITY     CLIENT
    T005S     BLAND     =     ADRCITY     REGION
    T005S     MANDT     =     T005U     MANDT
    T005S     LAND1     =     T005U     LAND1
    T005S     BLAND     =     T005U     BLAND
    and finaly searh help
    ORT01     3     3     PAD_ORT01
    CITY_CODE     0     2     CITY_CODE
    PSTLZ     1     1     PSTLZ_HR
    STATE     4     4     REGIO
    BEZEI     5     5     BEZEI20
    COUNTRY     0     6     LAND1
    LANGU     0     7     LANGU

  • Using PL/SQL Table in Forms

    Hi,
    I am populating a PL/SQL table by fetching data through a explicit cursor. But when i am accessing the PL/SQL table after population, i am getting a "NO DATA FOUND" error.
    I am attaching the Forms local progam units which have the logic.
    PACKAGE f_get_bike_makers IS
    TYPE prectype_maker_dtls_pll IS RECORD (
    country_code ad_bike_maker_details.abmd_country_code%TYPE,
    country_name table_values.tvs_description%TYPE,
    manu_code ad_bike_maker_details.abmd_manufacturer_code%TYPE,
    maker_name ad_bike_maker_details.abmd_maker_name%TYPE,
    maker_name_kana ad_bike_maker_details.abmd_maker_name_kana%TYPE,
    const_by ad_bike_maker_details.abmd_constructed_by%TYPE,
    const_time ad_bike_maker_details.abmd_construction_time%TYPE,
    update_by ad_bike_maker_details.abmd_updated_by%TYPE,
    update_time ad_bike_maker_details.abmd_updated_time%TYPE
    TYPE ptabtype_maker_dtls_pll IS TABLE OF prectype_maker_dtls_pll
    INDEX BY BINARY_INTEGER;
    FUNCTION f_get_bike_makers_pll RETURN ptabtype_maker_dtls_pll;
    END;
    PACKAGE BODY f_get_bike_makers IS
    FUNCTION f_get_bike_makers_pll
    RETURN ptabtype_maker_dtls_pll
    IS
    CURSOR cur_maker_dtls
    IS
    SELECT abmd.abmd_country_code,
    tvs.tvs_description,
    abmd.abmd_manufacturer_code,
    abmd.abmd_maker_name,
    abmd.abmd_maker_name_kana,
    abmd.abmd_constructed_by,
    abmd.abmd_construction_time,
    abmd.abmd_updated_by,
    abmd.abmd_updated_time
    FROM ad_bike_maker_details abmd,
    table_values tvs
    WHERE abmd.abmd_country_code = tvs.tvs_code
    AND tvs.tvs_tad_code = 'COUNTRIES'
    ORDER BY abmd.abmd_country_code;
    ln_tab_index BINARY_INTEGER := 0;
    ltab_maker_dtls ptabtype_maker_dtls_pll;
    BEGIN
    FOR lcur_maker_dtls IN cur_maker_dtls
    LOOP
    ln_tab_index := ln_tab_index + 1;
    ltab_maker_dtls (ln_tab_index) := lcur_maker_dtls;
    END LOOP;
    RETURN ltab_maker_dtls;
    END f_get_bike_makers_pll;
    END;
    PROCEDURE f_populate_maker_names
    IS
    ltab_maker_dtls f_get_bike_makers.ptabtype_maker_dtls_pll;
    lb_record_group BOOLEAN;
    ln_ltab_maker_dtls_index BINARY_INTEGER;
    BEGIN
    -- read all the vehicle types from table_values
    -- get makers and countries
    ltab_maker_dtls := f_get_bike_makers.f_get_bike_makers_pll ;
    DELETE_GROUP_ROW ('REC_MAKER_NAME', all_rows);
    ln_ltab_maker_dtls_index := ltab_maker_dtls.FIRST;
    begin
    WHILE ln_ltab_maker_dtls_index IS NOT NULL
    LOOP
    lb_record_group := l_record_group.insert_value ('REC_MAKER_NAME',
    'ABMD_MANUFACTURER_CODE',
    ltab_maker_dtls (ln_ltab_maker_dtls_index).manu_code,
    ln_ltab_maker_dtls_index
    lb_record_group := l_record_group.insert_value ('REC_MAKER_NAME',
    'ABMD_MAKER_NAME',
    ltab_maker_dtls (ln_ltab_maker_dtls_index).maker_name,
    ln_ltab_maker_dtls_index
    lb_record_group := l_record_group.insert_value ('REC_MAKER_NAME',
    'COUNTRY_NAME',
    ltab_maker_dtls (ln_ltab_maker_dtls_index).country_name,
    ln_ltab_maker_dtls_index
    lb_record_group := l_record_group.insert_value ('REC_MAKER_NAME',
    'ABMD_COUNTRY_CODE',
    ltab_maker_dtls (ln_ltab_maker_dtls_index).country_code,
    ln_ltab_maker_dtls_index
    ln_ltab_maker_dtls_index := ltab_maker_dtls.NEXT (ln_ltab_maker_dtls_index);
    end;
    END LOOP;
    exception when no_data_found then
    message('ln_ltab_maker_dtls_index :'||ln_ltab_maker_dtls_index);
    message(' ');
    end;
    ltab_maker_dtls.DELETE;
    END;
    SQL> desc ad_bike_maker_details
    Name Null? Type
    ABMD_COUNTRY_CODE NOT NULL VARCHAR2(2)
    ABMD_MANUFACTURER_CODE NOT NULL VARCHAR2(2)
    ABMD_MAKER_NAME VARCHAR2(60)
    ABMD_MAKER_NAME_KANA VARCHAR2(60)
    ABMD_CONSTRUCTED_BY NOT NULL VARCHAR2(20)
    ABMD_CONSTRUCTION_TIME NOT NULL DATE
    ABMD_UPDATED_BY VARCHAR2(20)
    ABMD_UPDATED_TIME DATE
    SQL> desc table_values
    Name Null? Type
    TVS_TAD_CODE NOT NULL VARCHAR2(15)
    TVS_CODE NOT NULL VARCHAR2(15)
    TVS_DESCRIPTION NOT NULL VARCHAR2(70)
    Oracle Database Version
    =======================
    Oracle8 Enterprise Edition Release 8.0.6.1.0 - Production
    PL/SQL Release 8.0.6.1.0 - Production
    Forms Version
    ==============
    Forms [32 Bit] Version 5.0.6.8.0 (Production)
    PL/SQL Version 2.3.4.0.0 (Production)
    Please do let know what could be the possible source of error.
    Thanks in advance.
    Nitin

    But we have to use the PL/SQL table as per our design standards.
    We are implementing the population logic of the PL/SQL table in the database as a
    package function. We are then accessing the PL/SQL table in Forms to populate the record group.It is curious that you would have such a unique requirement -- something that might make forms run a tiny bit faster -- yet you are using an ancient version of Forms.
    Also the "NO DATA FOUND" error is not raised everytime the PL/SQL table is accessed.
    What could be the reason for this erratic behaviour?I wonder if there may be a bug in SQL Net in the Oracle-to-Forms communication where PL/SQL tables are passed as out parameters. I know there is one in Web Forms 6 (6.0.8.19.1) when passing a pl/sql table from the form to Oracle -- I had to write the pl/sql table to a database table to get my process to work.

  • Ps/sql Table in Forms

    Hi all ..
    I am using Forms 6i ....
    on WHEN-BUTTON-PRESSED Trigger i am calling a procedure ..
    pkg_test.display_proc( Code_ID     IN varchar2,
    keyword IN varchar2,
    v_tab_ret OUT tab_type )
    The procedure is returning a PL/SQL table type .... which consist of 5 fields.....
    Problem :- How can i display this v_tab_ret ( PL/SQL Table) in the Display Item in the form canvas ... This v_tab_ret is supposed to return variable number of rows depending on the conditions in the procedure ...
    Thanks ,

    HI,
    In forms6i, you can define the variable based on the PL/SQL table as you do in the packages.
    In the WHEN-BUTTON-PRESSED trigger, do the following
    DECLARE
    v_tab_ret tab_type
    BEGIN
    -- call your procedure:
    pkg_test.display_proc( Code_ID ,
    keyword,
    v_tab_ret
    -- Now you have the pl/sql table populated from the procedure.
    END;
    Depends on the type of block (single / multi record), you can decide how to manipulate and show the value you got in the PL/SQL tabe.
    Regards,
    Venkat

  • How to pass values and see outout of PL/SQL Tables, SYS_REFCURSORs?

    I am new to SQL Developer (Version 3.0.02).
    Our QC division wants to test stored procedures using SQL Developer.
    I tried to test procedures with PL/SQL tables and SYS_REFCURSORS as input and output parameters.
    When we run it by pressing the green arrow we get the Run PL/SQL window.
    How can we:
    - Put values to SYS_REFCURSOR and PL/SQL table type input parameters?
    - How can we display SYS_REFCURSOR and PL/SQL table type output parameters?
    All this time we were using SQL*Navigator. In Navigator the PL Tables and SYS_REFCURSORs outputs are shown in a nice grid.
    Here, in SQL Developer, do we have to WRITE our own code to input and display these types of parameters????

    Hi Channa,
    Yes in SQL Developer 3.0 you will have to write your own code to test out ref cursors.
    I had created test harness scripts for all my procedures having ref cursors as parameters.
    And I had to dbms_output all the values on the screen.
    Probably a limitation of the SQL Developer 3.0 tool.
    In case you come across different solution to this do let me know also.
    Thanks,
    Viju
    blog: http://whizdba.wordpress.com

  • Will the order of elements stored in pl.sql table retains

    Hello Friends,
    I am having a record type and the for each element of record , i am having corresponding pl.sql table type .
    If i am storing the values into the records from a query and also the individual elements in the pl.sql table type will the order of data is stored as it is . ..
    example...
    in a record type the data is stored as ( name1 , age1 , salary1) , (name2, age2, salary2)
    if i store in corresponding pl sql table type name1 , name2
    age1, age2
    salary1, salary2
    can i relate the index of record type with that of pl/sql table type ..
    pls advice
    thanks/kumar

    Kumar,
    Yes, the order of elements will be the same.
    Any specific reason why you would want to create a collection for each individual attribute of the record ?
    You can as well declare another variable of the same record and initialize it.
    A few other suggestions for your code :
    1) The 2nd FOR loop can be modified to accommodate the query of the first cursor there-by eliminating one extra iteration.
    SELECT MINC.FAMID,
                         MINC.MEMBNO,
                         MEMB.AGE,
                         SALARYX,
                         SALARYBX,
                         NONFARMX,
                         NONFRMBX,
                         FARMINCX,
                         FRMINCBX,
                         CU_CODE
                    FROM MINC, MEMB, FMLY
                   WHERE MINC.FAMID = MEMB.FAMID
                     AND MINC.MEMBNO = MEMB.MEMBNO
                     AND MINC.FAMID = FMLY.FAMID
                     AND MEMB.FAMID = FMLY.FAMID
                   ORDER BY MINC.FAMID2) The collections can be alternately initialized as follows :
       v_member_rec(v_member_rec.last).FAMID := j.FAMID;
       max_earnings_tab(max_earnings_tab.last) := v_max_earnings;The tried the below example for confirmation ...
    declare
    type emp_rec is record
    (name emp.ename%TYPE,
      dept emp.edept%TYPE,
      sal  emp.esal%TYPE
    TYPE emp_rec_tab is table of emp_rec;
    ert emp_rec_tab := emp_rec_tab();
    TYPE ename_tab is table of varchar2(20);
    ent  ename_tab := ename_tab();
    TYPE edept_tab is table of number;
    edt  edept_tab := edept_tab();
    begin
    for i in (select * from emp)
    loop
         ert.extend;
         ent.extend;
         edt.extend;
         ert(ert.last).name := i.ename;
         ert(ert.last).dept := i.edept;
         ert(ert.last).sal := i.esal;
         ent(ent.last) := i.ename;
         edt(edt.last) := i.edept;
    end loop;
    for i in 1..ert.count
    loop
         dbms_output.put_line(ert(i).name||','||ent(i));
         dbms_output.put_line(ert(i).dept||','||edt(i));
         dbms_output.put_line('');
    end loop;
    end;

  • Need help with pl/sql tables

    i am trying but iam not understanding this....
    Evaluate this program fragment:
    DECLARE
    TYPE user_tab_rec IS RECORD (
    db_user dba_users.username%TYPE,
    DBA_TAB dba_tables%ROWTYPE);
    TYPE user_rec_tab IS TABLE OF test_rec
    INDEX BY BINARY_INTEGER;
    Tab_rec dba_tables%ROWTYPE;
    Obj_owner dba_objects.owner%TYPE;
    begin
    (processing)
    end;
    What line will generate an error?
    1.
    TYPE user_tab_rec IS RECORD (
    2.
    db_user dba_users.username%TYPE,
    3.
    DBA_TAB dba_tables%ROWTYPE);
    4.
    TYPE user_rec_tab IS TABLE OF test_rec
    5.
    INDEX BY BINARY_INTEGER;
    6.
    Tab_rec dba_tables%ROWTYPE;
    7.
    Obj_owner dba_objects.owner%TYPE;
    The correct answer is b. The line in b attempts to define a PL/SQL TABLE TYPE using a record that contains a composite datatype, which is not allowed. Answers a, c, and d are incorrect because they will not generate any errors when compiled.
    how can line b attempt to define a pl/sql table type..........
    thank u ramsy

    The correct answer is bB? I see no B.
    Do you mean three?
    But then again
    maybe line ten.
    Because (processing) isn't
    valid syntax you see.
    I know, I know
    Let's see what'll go.
    And then we'll see
    Is it A B or C?
    SQL> r
      1  DECLARE
      2  TYPE user_tab_rec IS RECORD (
      3  db_user dba_users.username%TYPE,
      4  DBA_TAB dba_tables%ROWTYPE);
      5  TYPE user_rec_tab IS TABLE OF test_rec
      6  INDEX BY BINARY_INTEGER;
      7  Tab_rec dba_tables%ROWTYPE;
      8  Obj_owner dba_objects.owner%TYPE;
      9  begin
    10  null;
    11* end;
    TYPE user_rec_tab IS TABLE OF test_rec
    ERROR at line 5:
    ORA-06550: line 5, column 31:
    PLS-00201: identifier 'TEST_REC' must be declared
    ORA-06550: line 5, column 1:
    PL/SQL: Item ignored
    SQL> create type TEST_REC as object(a number);
      2  /
    Type created.
    SQL> DECLARE
      2  TYPE user_tab_rec IS RECORD (
      3  db_user dba_users.username%TYPE,
      4  DBA_TAB dba_tables%ROWTYPE);
      5  TYPE user_rec_tab IS TABLE OF test_rec
      6  INDEX BY BINARY_INTEGER;
      7  Tab_rec dba_tables%ROWTYPE;
      8  Obj_owner dba_objects.owner%TYPE;
      9  begin
    10  null;
    11  end;
    12  /
    PL/SQL procedure successfully completed.
    SQL> Hmmm........................
    Cheers, APC

Maybe you are looking for