Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
Clear All
new posts

    Troubles on calling oracle stored function

    In my oracle db I have function:

    Code:
    function get_object_tree return sys_refcursor
    is
     v_res sys_refcursor;
    begin
    ....lot of comlicated pl/sql
    return v_res;
    end;
    it is returning ref cursor with 4 fields.

    so I created datasource:

    Code:
    <DataSource ID="objectTree" dataFormat="iscServer" serverType="sql" dataSourceVersion="1">
        <fields>
            <field name="NPARENT_KEY" type="FLOAT " title="parentKey"/>
            <field name="NKEY" type="FLOAT " title="IdKey" primaryKey="true"/>
            <field name="CNAME" type="TEXT " title="objectName"/>
            <field name="NLEVEL" type="INTEGER " title="treeLevel"/>
        </fields>
        <allowAdvancedCriteria>false</allowAdvancedCriteria>
    
        <operationBindings>
    	<operationBinding operationId="getTree"
          	    operationType="fetch">
    	        <customSQL>select krks2_vik_app.get_object_tree from dual</customSQL>
        </operationBinding>
        </operationBindings>
    </DataSource>



    and trying to show it in a listgrid:

    Code:
    VLayout layout = new VLayout();
            layout.setHeight100();
            layout.setWidth100();
    
            ListGrid grid = new ListGrid();
            grid.setHeight100();
            grid.setWidth100();
            grid.setDataSource(DataSource.get("objectTree"));
            grid.setFetchOperation("getTree");
            grid.fetchData();
    
            layout.addMember(grid);
    
            layout.draw();
    and on run i get this:
    Code:
    === 2013-01-30 23:47:40,712 [l0-0] DEBUG DataTools - Bean inspection: invocation of oracle.jdbc.driver.OracleResultSetImpl.getFetchSize() while trying to obtain property 'fetchSize' threw an exception: java.lang.IllegalAccessException: Class com.isomorphic.util.DataTools can not access a member of class oracle.jdbc.driver.OracleResultSetImpl with modifiers "public"
    	at sun.reflect.Reflection.ensureMemberAccess(Reflection.java:95)
    Function actually works fine in our flex project and also in my SmartGWT LGPL test project, where I used plain JDBC/OraclePrepared statement to get result set and then converted it to Record[] to feed grids.

    What is wrong with it? Where I should look for troublemaker?
    * And one more question - is it the right way to call function? "call krks2_vik_app.get_object_tree()" was resulting in "ORA-06576:
    not a valid function or procedure name"

    I am using "SmartClient Version: v8.3_2012-11-20/EVAL Deployment (expires 2013.01.19_05.13.53) Licensed to: Isomorphic Software (#ISC_EVAL_NIGHTLY)"
    Attached Files

    #2
    The error message suggests this stored procedure returns something like a set of rows where some rows have ResultSets inside the rows (as a column value). Is that the case?

    Comment


      #3
      Originally posted by Isomorphic View Post
      The error message suggests this stored procedure returns something like a set of rows where some rows have ResultSets inside the rows (as a column value). Is that the case?
      I think it returns single-cell which contains cursor, that contains resultset.

      classic jdbc code is like this:
      Code:
      oraCallStmt = (OracleCallableStatement) con.prepareCall(
                      "{? = call ref_cursor_package.get_dept_ref_cursor(?)}"
                  );
                  oraCallStmt.registerOutParameter(1, OracleTypes.CURSOR);
                  oraCallStmt.setInt(2, 104);
                  oraCallStmt.execute();
      
                  deptResultSet = (OracleResultSet) oraCallStmt.getCursor(1);
      
                  while (deptResultSet.next()) {
      }
      here its content:

      Code:
      NPARENT_KEY	NKEY	                CNAME	NLEVEL
      1988213369995	1988223469995	返-1	            2
      1988213279995	1988223269995	返-1	            2
      1988213249995	1988223169995	返-1	            2
      1988213259995	1988223419995	返-1	            2
      1988213209995	1988223179995	返-1            	2
      1988213299995	1988223409995	返-1	            2
      1988213239995	1988223229995	返-1	            2
      1988213309995	1988223389995	返-1	            2
      1988213359995	1988223289995	返-1	            2
      1988213329995	1988223309995	返-1	            2
      1988213339995	1988223319995	返-1	            2
      1988213349995	1988223329995	返-2	            2
      all of thеm can even be casted to strings, it will not affect further logic.

      Comment


        #4
        You realize that OracleResultSet.getCursor() is not part of JDBC? It's something specific to Oracle's driver, so it seems like you are expecting magic to happen here..

        If your procedure returns a normal ResultSet where no non-JDBC calls are required to get to the data, that will work.

        Comment


          #5
          If it's too much upheaval to modify or augment your procedures so that they can be called via standard JDBC, you can also simply write a DMI that has your exact existing logic in it.

          Comment


            #6
            Thanks

            Now is a question about DMI:

            DSResponse.setData(java.lang.Object data)

            Is it possible not to use Beans as mid point of DMI<->Database?

            In DMI serverObject I call my OracleJdbc interface to call my stored function and returning something like
            List<Map<String, Object>>
            where each row presented as a set attributeName-attributeValue pairs (java.util.jar.Attributes as an example)?

            Comment


              #7
              Yes. See the QuickStart Guide section Returning Data.

              Comment

              Working...
              X