Returning structure from dll to pl/sql

hi
we have a problem regarding how to return structure of arrays from c dll. It may be possible with oci programing . Is it possible with simple c program using oracle object types or by pl/sql records .
We are having oracle 8i running on windows 2000 server
Thanks,
Zuber
null

Oracle9 i JDBC Developers Guide and Reference(page 21-16):
It is not feasible for Oracle JDBC drivers to support calling arguments or return
values of the PL/SQL RECORD, BOOLEAN, or table with non-scalar element types.
However, Oracle JDBC drivers support PL/SQL index-by table of scalar element
types. For a complete description of this, see "Accessing PL/SQL Index-by Tables"
on page 16-21.
As a workaround to PL/SQL RECORD, BOOLEAN, or non-scalar table types, create
wrapper procedures that handle the data as types supported by JDBC. For example,
to wrap a stored procedure that uses PL/SQL booleans, create a stored procedure
that takes a character or number from JDBC and passes it to the original procedure
as BOOLEAN or, for an output parameter, accepts a BOOLEAN argument from the
original procedure and passes it as a CHAR or NUMBER to JDBC. Similarly, to wrap a
stored procedure that uses PL/SQL records, create a stored procedure that handles
a record in its individual components (such as CHAR and NUMBER) or in a structured
object type. To wrap a stored procedure that uses PL/SQL tables, break the data
into components or perhaps use Oracle collection types.

Similar Messages

  • Passing a structure from Java to PL/SQL Procedure

    Environment: Oracle DB, Tomcat/Apache
    How do we pass a structure (Table Record Type) from Java to a PL/SQL Stored Procedure?
    We are doing JSP-->JavaClass/Bean to communicate to DB. We have an existing PL/SQL packages/Procedure to insert records into table (These procedures have record types as in/out parameters). So is there a way to call these from Java?
    Thanks in advance.
    Ramesh

    Oracle9 i JDBC Developers Guide and Reference(page 21-16):
    It is not feasible for Oracle JDBC drivers to support calling arguments or return
    values of the PL/SQL RECORD, BOOLEAN, or table with non-scalar element types.
    However, Oracle JDBC drivers support PL/SQL index-by table of scalar element
    types. For a complete description of this, see "Accessing PL/SQL Index-by Tables"
    on page 16-21.
    As a workaround to PL/SQL RECORD, BOOLEAN, or non-scalar table types, create
    wrapper procedures that handle the data as types supported by JDBC. For example,
    to wrap a stored procedure that uses PL/SQL booleans, create a stored procedure
    that takes a character or number from JDBC and passes it to the original procedure
    as BOOLEAN or, for an output parameter, accepts a BOOLEAN argument from the
    original procedure and passes it as a CHAR or NUMBER to JDBC. Similarly, to wrap a
    stored procedure that uses PL/SQL records, create a stored procedure that handles
    a record in its individual components (such as CHAR and NUMBER) or in a structured
    object type. To wrap a stored procedure that uses PL/SQL tables, break the data
    into components or perhaps use Oracle collection types.

  • URGENT HELP !JCO RETURN structure from SAP

    Hello,
    I am working on my intern project and I got some trouble.
    I have used JDBC to access a table in Oracle(this is an independent DB)I updated a column in the table and selected all data that
    was marked as 6 based on the update(SAP needs this data). I passed the values to a JCO application,
    which connects to SAP and send the data (I presume what I'm doing is correct) to a structure in SAP.
    SAP does some internal calculations with the data and should return the data back using the same
    structure but this time with some changes on the data.
    For example the field steuk is marked as 7 if the data processing was successful and if the data
    structure wasn't successful a 6 will be return.
    The return Values should be updated in the oracle DB indicating if the transfer was successful
    or not. And next time the same data will be sent to SAP following the same path.
    Now when I look at the return getString data in Eclipse, the result seems ambiguous.I don't see the data I presumably
    sent to the SAP structure using:
    JCO.ParameterList list = function.getTableParameterList();
    JCO.Table ztable =  list.getTable("ZSAORA_RUECK");
         for (int i = 0; i < 19; i++) {
         ztable.appendRow();
         ztable.setValue(value,field name);
    Am I doing some thing wrong here??? Any Help will be highly appreciated. Codes could be sent to [email protected]
    BELOW are the codes:
    CONNECTING TO test_table in Oracle DB:
    import java.sql.*;
    public class DatabaseConnect {
         public static void main(String[] args) {
         Connection con = null;
         Statement stmt = null;
         ResultSet re = null;
         String[] ParamArray;            
            ParamArray = new String[24];
         //Properties logon;
         try {
              Class.forName("oracle.jdbc.driver.OracleDriver");
         con = DriverManager.getConnection
    ("jdbc:oracle:thin:@226.190.0.1:1521:testdb","test","test1");
         stmt = con.createStatement ();
         stmt.executeUpdate("UPDATE test_table set steuk = 6 WHERE steuk = 5");
    ResultSet rs = stmt.executeQuery("SELECT mandt,kokrs,werks,arbpl,aufnr,vornr,ile01,"+
    "lsa01,ism01,ile02,lsa02,ism02,ile03,lsa03,ism03,"+
    "ile04,lsa04,ism04,steuk,matnr,budat,kostl,pernr,"+
    "rueckid FROM test_table where steuk =6");                              
         while (rs.next()) {
         for (int i = 1; i <= 24; i++){
         ParamArray[i-1] = rs.getString(i);
         System.out.print(rs.getString(i) + 't');
         System.out.println();                    
         } catch(Exception e) {
         e.printStackTrace();                    
         } finally {
              try
         if(stmt != null) stmt.close();
         if(con != null) con.close(); 
         } catch (Exception exception) {
              exception.printStackTrace();
         // Bapi call
         TryBapi sap = new TryBapi(ParamArray);
    BELOW IS THE JCO Code which connects to SAP and send data to the structure:
    import com.sap.mw.jco.IFunctionTemplate;
    import com.sap.mw.jco.JCO;
    public class TryBapi extends Object {     
    JCO.Client mConnection;     
    JCO.Repository mRepository;     
    OrderedProperties logonProperties;
    public TryBapi(String[] paramArray){
         try {
         logonProperties = OrderedProperties.load("/logon.properties");
         mConnection = JCO.createClient((String)logonProperties.get("jco.client.client"),
             (String)logonProperties.get("jco.client.user"),
            (String)logonProperties.get("jco.client.passwd"),
                             null,
           (String)logonProperties.get("jco.client.ashost"),
         String)logonProperties.get("jco.client.sysnr")
         mConnection.connect();
         mRepository = new JCO.Repository("SAPJCO",mConnection);
         catch (Exception ex) {
         ex.printStackTrace();
         System.exit(1);
         JCO.Function function = null;
         JCO.Table tab = null;
         try {
              function = this.createFunction("Z_UPDATE_SAORA_RUECK");
              if (function == null) {
              System.out.println("Z_UPDATE_SAORA_RUECK not found in SAP.");
              System.exit(1);
         JCO.ParameterList list = function.getTableParameterList();
              JCO.Table ztable =  list.getTable("ZSAORA_RUECK"); //inserting 24 records loop.
         for (int i = 0; i < 24; i++) {
         ztable.appendRow(); //ztable.setValue(value, field name)
         ztable.setValue("300","MANDT");
         ztable.setValue("KOKRS" + i, "KOKRS");
         ztable.setValue("WERKS" + i, "WERKS");
         ztable.setValue("ARBPL" + i, "ARBPL");
         ztable.setValue("AUFNR" + i, "AUFNR");
         ztable.setValue("VORNR" + i, "VORNR");
         ztable.setValue("ILE01" + i, "ILE01");
         ztable.setValue("LSA01" + i, "LSA01");
         ztable.setValue("ISM01" + i, "ISM01");
         ztable.setValue("ILE02" + i, "ILE02");
         ztable.setValue("LSA02" + i, "LSA02");
         ztable.setValue("ISM02" + i, "ISM02");
         ztable.setValue("ILE03" + i, "ILE03");
         ztable.setValue("LSA03" + i, "LSA03");
         ztable.setValue("ISM03" + i, "ISM03");
         ztable.setValue("ILE04" + i, "ILE04");
         ztable.setValue("LSA04" + i, "LSA04");
         ztable.setValue("ISM04" + i, "ISM04");
         ztable.setValue("STEUK" + i, "STEUK");
         ztable.setValue("MATNR" + i, "MATNR");
         ztable.setValue("BUDAT" + i, "BUDAT");
         ztable.setValue("KOSTL" + i, "KOSTL");
         ztable.setValue("PERNR" + i, "PERNR");
         ztable.setValue("RUECKID" + i, "RUECKID");
         list.setValue(ztable,"ZSAORA_RUECK");
         function.setTableParameterList(list);
         mConnection.execute(function);
         catch (Exception ex) {
         ex.printStackTrace();
         System.exit(1);
          JCO.Table codes = null;
         try {
         codes = function.getTableParameterList().getTable("ZSAORA_RUECK");
         System.out.println("Return Values starts HERE:");
         for (int i =0; i < codes.getNumRows(); i++){                 
         codes.setRow(i);
         System.out.println(codes.getString("MANDT")+ 't'+
         codes.getValue("KOKRS")+ 't'+
         codes.getString("WERKS")+ 't'+
         codes.getString("ARBPL")+ 't'+
         codes.getString("AUFNR")+ 't'+
         codes.getString("VORNR")+ 't'+
         codes.getString("ILE01")+ 't'+
         codes.getString("LSA01")+ 't'+
         codes.getString("ISM01")
    /*     codes.getString("ILE02")+ 't'+
         codes.getString("LSA02")+ 't'+
         codes.getString("ISM02")+ 't'+
         codes.getString("ILE03")+ 't'+
         codes.getString("LSA03")+ 't'+
         codes.getString("ISM03")+ 't'+
         codes.getString("ILE04")+ 't'+
         codes.getString("LSA04")+ 't'+
         codes.getString("ISM04")+ 't'+
         codes.getString("STEUK")+ 't'+
         codes.getString("MATNR")+ 't'+
         codes.getString("BUDAT")+ 't'+
         codes.getString("KOSTL")+ 't'+
         codes.getString("PERNR")+ 't'+
         codes.getString("RUECKID")       */
         catch (Exception ex) {
         ex.printStackTrace();
         System.exit(2);           
         mConnection.disconnect();
    public JCO.Function createFunction(String name) throws Exception {
         try {
         IFunctionTemplate ft =     mRepository.getFunctionTemplate(name.toUpperCase());
         if (ft == null)
         return null;
         return ft.getFunction();
         catch (Exception ex) {
         throw new Exception("Problem retrieving JCO.Function object.");
    Message was edited by: Rudolph Emange
    Message was edited by: Rudolph Emange

    Hi Astrid,
    Thank you for your remarks. The problem I'm having is that when I do send the values to SAP using the loop:
    JCO.ParameterList list = function.getTableParameterList();
    JCO.Table ztable =  list.getTable("ZSAORA_RUECK");
         for (int i = 0; i < 19; i++) {
         ztable.appendRow();
         ztable.setValue(value,field name);
    I do expect to have(or see) some values when I do access the same table structure(This is just a structure and
    not a real table as I do understand that there is a different between a structure and a table in SAP) and
    not the field names back.In the second try and catch block:
    try {
         codes = function.getTableParameterList().getTable("ZSAORA_RUECK");
         System.out.println("Return Values starts HERE:");
         for (int i =0; i < codes.getNumRows(); i++){                 
         codes.setRow(i);
         System.out.println(codes.getString("MANDT")+ 't'+
         codes.getValue("KOKRS")+ 't'+
         codes.getString("WERKS")+ 't'+
         codes.getString("ARBPL")+ 't'+
         codes.getString("AUFNR")+ 't'+
         codes.getString("VORNR")+ 't'+
         codes.getString("ILE01")+ 't'+
         codes.getString("LSA01")+ 't'+
         codes.getString("ISM01")
    I'm trying to access the values I sent in the first try and catch block. I presume I should see some real values and not the
    field names.This is how my output looks like:
    300     KOKR     WERK     ARBPL0     AUFNR0     VORN     ILE     
    300     KOKR     WERK     ARBPL1     AUFNR1     VORN     ILE     
    300     KOKR     WERK     ARBPL2     AUFNR2     VORN     ILE     
    300     KOKR     WERK     ARBPL3     AUFNR3     VORN     ILE     
    300     KOKR     WERK     ARBPL4     AUFNR4     VORN     ILE     
    300     KOKR     WERK     ARBPL5     AUFNR5     VORN     ILE
    This does not reflect the values but the field names. Why is it this way? Does it mean that my array is wrong or I'm not at all
    sending the values. Please HELP ME OUT HERE.
    Could any one show me a better way how to send the values selected from Oracle table using perhaps an
    ARRAY to the ZSAORA_RUECK structure in SAP?
    I am trying to send the values from the select statement in the first jdbc application
    to the value field in ztable.setValue(value,  field name).
    My Regards!
    Message was edited by: Rudolph Emange

  • Can't  use parameter reference from DLL C on pl/sql

    hi all, I have dll(newStr.dll) write by c language with a function name is "strNew", following code in c and pl/sql:
    char* strNew(char *& str){
         if (str != NULL){
              str = strdup("");
              str = strcat(str,"String is not null.");     
         }else{
              str = strdup("");
              str = strcat(str,"String is null.");     
         return str;
    On PL/SQL I call the dll(newStr.dll), following code on pl/sql:
    1) Create library:
         CREATE OR REPLACE LIBRARY TestDLL AS 'D:\newStr.dll';
    2) Create package:
         CREATE OR REPLACE
         PACKAGE TEST_DLL AS
         FUNCTION strNew(str IN OUT varchar2) RETURN VARCHAR2;
         END TEST_DLL
         CREATE OR REPLACE
         PACKAGE BODY TEST_DLL AS
         FUNCTION strNew(str IN OUT VARCHAR2)
         RETURN VARCHAR2 AS
         EXTERNAL LIBRARY TestDLL
         NAME "strNew"
         LANGUAGE C
         CALLING STANDARD PASCAL
         PARAMETERS(str BY REFERENCE STRING, return STRING);
    END TEST_DLL
    3) Create Procedure:
    CREATE OR REPLACE
    PROCEDURE TESTPRO AS
    newStrIn varchar2(40) :='test';
    newStrOut varchar2(256);
    BEGIN
    newStrOut := TEST.strNew(newStrIn);
    DBMS_OUTPUT.PUT_LINE('newStrOut = ' || newStrOut );
    DBMS_OUTPUT.PUT_LINE('newStrIn = ' || newStrIn );
    END TESTPRO;
    4) Run procedure the result following:
    newStrOut = String is not null.(it correct)
    newStrIn= 8!(it wrong, the newStrIn='String is not null' is correct))
    I not found root cause why in pl/sql, I can't get the variable reference from dll c.
    Please help me.
    Quan.

    For compatibility purposes you would probably be better using 10g development rather than 9i if you are going to use a 10g database. I'm not familiar with the latest versions in terms of Oracle Forms, cos I stopped developing in Forms back on version 8.
    Essentially there are different components you can download and install.
    Database - This sets up a database server and allows you to create databases to store your data in.
    Client - This installs the necessary client software to allow you to connect to a database on a database server. It includes client software such as SQL*Plus and the drivers needed to make the connections.
    Developer - This is a client side development environment for developing forms and reports. It requires the Client software in order to be able to connect to the database.
    By the sounds of it you have downloaded and installed the last two, but without the first one you don't have a database to connect to.

  • HELP!  RETURN CLOB from External DLL

    Hi
    I am working on an External DLL using OCI. Basically, PL/SQL
    calls an
    External DLL to process the data and then returns LOB back to
    the PL/SQL
    procedure. Inside the DLL, I created a Temporary lob to process
    the data.
    The error is prompted from PL/SQL:
    SQL> exec isdb.test_clob;
    Before original length=10
    ORA-24805: LOB type mismatch
    ORA-06512: at "ISDBSVR.ISDB", line 24
    ORA-06512: at "ISDBSVR.ISDB", line 29
    ORA-06512: at line 1
    So far I know that error is caused by the return from PLS_CLOB
    is not clob.
    "After_original := PLS_CLOB(before_original); {you will see more
    code in the
    below}" However inside the DLL, I have defined OCIClobLocator
    and
    OCI_TEMP_CLOB to carry the CLOB data.
    I have found the following observations:
    1. If I change everything to blob, it works fine. (such as
    OCILobLocator,
    OCI_TEMP_CLOB and all variables in PL/SQL)
    2. If I run the same DLL and PL/SQL in 9i, it works fine (clob
    too)
    I guess it would be a bug for clob, please help to check thanks
    -- CODE - PL/SQL
    CREATE OR REPLACE PACKAGE BODY "ISDBSVR"."ISDB"
    as
    Function PLS_CLOB(var_clob in clob)
    RETURN clob IS
    EXTERNAL LIBRARY bb
    WITH CONTEXT
    NAME "Encrypt_Blob"
    LANGUAGE C
    PARAMETERS
    CONTEXT,
    var_clob,
    var_clob INDICATOR SB4,
    RETURN INDICATOR SB4
    PROCEDURE TEST_CLOB IS
    before_original cLOB;
    After_original cLOB;
    CHAR_TO_CLOB varchar(200);
    bsize int;
    BEGIN
    CHAR_TO_CLOB := 'AAAAAAABBBBBBCCCCCCC';
    dbms_lob.createtemporary( before_original, TRUE );
    DBMS_LOB.write( before_original,10,1,CHAR_TO_CLOB);
    bSize := DBMS_LOB.GetLength(before_original);
    DBMS_OUTPUT.PUT_LINE('Before original length='||bSize);
    After_original := PLS_CLOB(before_original);
    bSize := DBMS_LOB.GetLength(After_original);
    DBMS_OUTPUT.PUT_LINE('After original length='||bSize);
    dbms_lob.freetemporary(before_original);
    END;
    END ISDB;
    /* CODE - DLL */
    EXPORT OCILobLocator * EncryptBlob(OCIExtProcContext
    *with_context,
    OCILobLocator *plaintext2,
    sb4 pt_indicator2,
    sb4 *ret_indicator
    { FILE *fp;
    OCIClobLocator *cipherbb;
    ub4 amount;
    ocictx oci_ctx;
    ocictx *oci_ctxp = &oci_ctx;
    status = OCIExtProcGetEnv(with_context,
    &oci_ctxp->envhp,
    &oci_ctxp->svchp,
    &oci_ctxp->errhp);
    status = OCIDescriptorAlloc(oci_ctxp->envhp,
    (dvoid **) &cipherbb,
    (ub4) OCI_DTYPE_LOB,
    (size_t) 0,
    (dvoid **) 0);
    status = (int) OCILobCreateTemporary(oci_ctxp->svchp,
    oci_ctxp->errhp, cipherbb,
    OCI_DEFAULT,
    OCI_DEFAULT,
    OCI_TEMP_CLOB, OCI_ATTR_NOCACHE,
    OCI_DURATION_SESSION);
    amount = 6;
    status = OCILobCopy(oci_ctxp->svchp,
    oci_ctxp->errhp,
    cipherbb,
    plaintext2,
    amount,
    (ub4) 1,
    (ub4) 1);
    *ret_indicator = OCI_IND_NOTNULL;
    OCIDescriptorFree((dvoid *) cipherbb, (ub4) OCI_DTYPE_LOB);
    return(cipherbb);

    In what database version did you observe the problem?
    Thomas

  • JNI_CreateJavaVM() (1.4.0) NEVER returns if I call it from DLL !

    Hello,
    I'm invoking java application from C++ exe (Win2000) and this works almost fine (except DestroyJavaVM()), but if the same piece of code that handles Java resides in DLL then JNI_CreateJavaVM() (1.4.0) NEVER returns and the process gets stuck !!!
    What could be the reason ?
    Thanx !

    Hi,
    JVM can start java application from DLL if the application (that embeds java application and DLL) has message loop (or simple endless while loop, I tested).
    Vitally

  • Some "formula" interpreter or returning value from unnamed PL/Sql blocks

    Hello,
    My company is developing Payroll and HR software and we use Oracle 10G Database. For a new module we are looking for a system were the end user (power user) can put in some kind of "formula's" to define what info/figures he wants for certain calculations done by de module (the budget module calculations will be done in PL/SQL stored proc written by us).
    Example: item "MonthlySalaryCost" = (BaseYearSal + TotalBonus)/12
    Where BaseYearSal and TotalBonus are functions that exist our will exist in or database. The idea is that a PL/SQL proc (which will be the same for all our customers), at runtime will execute that "formula" and use the result in its further calculations. The "formulas" will be stored in a table. (I foresee of course a "formula" validation to prevent dangerous sql-injection).
    My idea was to use Execute Immediate in the proc to execute the formula's and work with the results. In this approach we have to write (and foresee) all possible functions to access the data the user wants to use.
    Another (more powerful) solution I think about, is seeing these "formula's" as unnamed PL/SQL blocks (stored in a table), were the end user (or consultant) can use the full power of PL/SQL (if then else, select into ..., etc..) to obtain the result he wants to return into the item.
    My problem here is : how to return a value from a unnamed PL/SQL block that is executed via Execute Immediate in a stored proc ?
    And a general question: what do you think of this approach ? are there others possibilities to do this ?
    Thanks in advance,
    Philippe.

    Hi,
    Welcome to the forum!
    This is a simple example:
    Some functions to test:
    CREATE OR REPLACE FUNCTION f_test1 RETURN NUMBER IS
       RESULT NUMBER;
    BEGIN
       RESULT := 12;
       RETURN(RESULT);
    END f_test1;
    CREATE OR REPLACE FUNCTION f_test2 RETURN NUMBER IS
       RESULT NUMBER;
    BEGIN
       RESULT := 10;
       RETURN(RESULT);
    END f_test2;
    CREATE OR REPLACE PACKAGE pack_test_functions IS
       PROCEDURE proc_test;
    END pack_test_functions;
    CREATE OR REPLACE PACKAGE BODY pack_test_functions IS
       PROCEDURE proc_test IS
          v_sql    VARCHAR2(4000);
          v_result NUMBER;
       BEGIN
          v_sql := 'SELECT F_TEST1() + F_TEST2() FROM DUAL';
          EXECUTE IMMEDIATE v_sql
             INTO v_result;
          dbms_output.put_line(v_result);
       END proc_test;
    END pack_test_functions;
    /into v_result you have the result of the operation.
    Regards,

  • Returning table structure from Web Service...

    Hi,
    I have a web service which retrieves data from a database table. I want to use this web service from my Visual Composer to display the data on the screen.
    I want to know how to return the table structure from my web service. Currently i am returning a string array (only one row of data) from my web service and displaying it in the VC. But i want to include the names of the columns as well.
    I tried using 2D String[] and HashMap, both didn't work for me.
    Any ideas?
    Regards,
    Venkat

    Hi Venkat,
    I recommend to pass the headers in seperat variables and the data table in a array.
    I did something similar, without the header, because they are fixed in my scenario.
    This webservice returns a list of all Portal Roles:
         public roleModel[] getRoles() throws Exception{
                   // Array List as return value
                   ArrayList RoleList = new ArrayList();
                   // Try Block reading portal roles
                   try {
                        IRoleFactory rfact = UMFactory.getRoleFactory();
                        // Filter for PortalRoles
                        IRoleSearchFilter roleFilter = rfact.getRoleSearchFilter();
                        // Search for *
                        roleFilter.setUniqueName("*", ISearchAttribute.EQUALS_OPERATOR, false);
                        // Search all Roles
                        ISearchResult resultList = rfact.searchRoles(roleFilter);
                        // return the result list
                        if (resultList.getState() == ISearchResult.SEARCH_RESULT_OK) {
                             while (resultList.hasNext()) {
                                  // read roleUid
                                  String roleUid = (String) resultList.next();
                                  // create roleObject for roleUid
                                  IRole roleObject =     rfact.getRole(roleUid);
                                  //  instantiate new role for  ArrayList
                                  roleModel rolle = new roleModel();
                                  // read DisplayName and UniqeID
                                  rolle.setRole(roleObject.getDisplayName());
                                  rolle.setRoleID(roleObject.getUniqueID());
                                  rolle.setDescription(roleObject.getDescription());
                                  // add object to ArrayList
                                  RoleList.add(rolle);
                        // create new array from data type model roleModel (class)
                        // in the correspoding size
                        roleModel[] returnList = new roleModel[RoleList.size()];
                        // write ArrayList back to array
                        RoleList.toArray(returnList);
                        // return all portal roles
                        return returnList;
                   // exception handling
                   } catch (Exception e) {
                        throw new Exception(e);
    Hope that helps!
    Best Regards,
    Marcel

  • Return Table Structure from Web Service...

    Hi,
    I have a web service which retrieves data from a database table. I want to use this web service from my Visual Composer to display the data on the screen.
    I want to know how to return the table structure from my web service. Currently i am returning a string array (only one row of data) from my web service and displaying it in the VC. But i want to include the names of the columns as well.
    I tried using 2D String[] and HashMap, both didn't work for me.
    Any ideas?
    Regards,
    Venkat

    Hi,
    I have a web service which retrieves data from a database table. I want to use this web service from my Visual Composer to display the data on the screen.
    I want to know how to return the table structure from my web service. Currently i am returning a string array (only one row of data) from my web service and displaying it in the VC. But i want to include the names of the columns as well.
    I tried using 2D String[] and HashMap, both didn't work for me.
    Any ideas?
    Regards,
    Venkat

  • How can i return object from oracle in my java code using pl/sql procedure?

    How can i return object from oracle in my java code using pl/sql procedure?
    And How can i returned varios rows fron a pl/sql store procedure
    please send me a example....
    Thank you
    null

    yes, i do
    But i can't run this examples...
    my problem is that i want recive a object from a PL/SQL
    //procedure callObject(miObj out MyObject)
    in my java code
    public static EmployeeObj callObject(Connection lv_con,
    String pv_idEmp)
    EmployeeObj ret = new EmployeeObj();
    try
    CallableStatement cstmt =
    lv_con.prepareCall("{call admin.callObject(?)}");
    cstmt.registerOutParameter(1, OracleTypes.STRUCT); // line ocurr wrong
    //registerOutParameter(int parameterIndex, int sqlType,String sql_name)
    cstmt.execute();
    ret = (EmployeeObj) cstmt.getObject(1);
    }//try
    catch (SQLException ex)
    System.out.println("error SQL");
    System.out.println ("\n*** SQLException caught ***\n");
    while (ex != null)
    System.out.println ("SQLState: " + ex.getSQLState ());
    System.out.println ("Message: " + ex.getMessage ());
    System.out.println ("Vendor: " + ex.getErrorCode ());
    ex = ex.getNextException ();
    System.out.println ("");
    catch (java.lang.Exception ex)
    System.out.println("error Lenguaje");
    return ret;
    Do you have any idea?

  • How to add error message to return structure of calling BAPI from a BADI

    i have a bapi where a badi is triggered.this badi method has just importing and changing parameters.is there any way with which i can add error message to the return structure of calling bapi.please reply at the earliest.High points can be expected.

    thanks got it

  • Handling Return Codes from SQL Stored Procedures

    Hi,
    Please can you let me know how to take care of system return codes from Stored Procedure in JDBC program. Is there any way it can be handled using Callabale Statement.
    Regards.

    not sure what you mean by "system" return codes, but to capture return values from stored procedures you can use CallableStatement.registerOutParameter(), just like with output parameters. see http://www.j-netdirect.com/GenStoredProcedures.htm#ReturnStatus.

  • Returning composite datatype(record) to an SQL Query

    I have a function called get_customer_address() that takes customer id and returns the customer address as a record type.
    TYPE cust_address_type IS RECORD
    (address1 VARCHAR2(25),
    address2 VARCHAR2(25),
    city VARCHAR2(25),
    zipcode VARCHAR(10),
    STATE VARCHAR(10));
    cust_address cust_address_type;
    My function is returning cust_address.
    I want to modify below exising query and call this function from the query to get address.
    select cust_id, address1, address2, city, zipcode from customer_table;
    Instead of using address1, address2, city, zipcode if I want to the record type variable cust_id returned from the function, can I use it in my query? How do I modify the above query to call the function get_customer_address and get the same values as in the above query?

    To add to Elic's comment - PL/SQL record structures can be defined as SQL objects, as long as SQL data types are used and not non-supported PL/SQL types like boolean.
    E.g. create or replace type TCustAddress is object
    (  address1 VARCHAR2(25),
       address2 VARCHAR2(25),
       city     VARCHAR2(25),
       zipcode  VARCHAR2(10),
       state    VARCHAR2(10)
    );This provides a lot more flexibility than using PL/SQL record types. This is essentially an object class definition - and you can add constructors and methods to it.
    It works seamlessly across both SQL and PL/SQL.

  • Returning rows from stored proc

    Hello, this is the sample from the SQL Developer help to create proc:
    CREATE OR REPLACE
    PROCEDURE list_a_rating(in_rating IN NUMBER) AS
    matching_title VARCHAR2(50);
    TYPE my_cursor IS REF CURSOR;
    the_cursor my_cursor;
    BEGIN
    OPEN the_cursor
    FOR 'SELECT title
    FROM books
    WHERE rating = :in_rating'
    USING in_rating;
    DBMS_OUTPUT.PUT_LINE('All books with a rating of ' || in_rating || ':');
    LOOP
    FETCH the_cursor INTO matching_title;
    EXIT WHEN the_cursor%NOTFOUND;
    DBMS_OUTPUT.PUT_LINE(matching_title);
    END LOOP;
    CLOSE the_cursor;
    END list_a_rating;
    You have to write a cursor just to display results from a query. To me this is whacked but I'll go with it. So what if you wanted to return that resultset or refcursor so it can be consumed by a calling application or procedure? I tried something like
    CREATE OR REPLACE PROCEDURE list_a_rating(in_rating IN NUMBER, MatchingTitles OUT Ref Cursor)
    but that's not compiling. How do you return data from a proc or function?
    Thanks,
    Ken

    ktrock wrote:
    Hello, this is the sample from the SQL Developer help to create proc:A very poor example..
    You have to write a cursor just to display results from a query. To me this is whacked but I'll go with it. All SQL you send to Oracle for parsing and execution winds up as SQL cursors in the server's SQL shared pool. You, the client, then get a handle as reference to this cursor that was created for your SQL statement. Using this handle you can now fetch the output of the cursor and consume it on the client side.
    So there is no such thing as not using a cursor - you always use cursors. Many times it will be implicitly as you won't see the cursor workings as the client hides that from you.
    As for DBMS_OUTPUT and PL/SQL... PL/SQL cannot "write output". And time and again (stupid?) people will use DBMS_OUTPUT thinking that is "writing to the client's display device".
    It is not. It is writing data into a PL/SQL variable on the server. PL/SQL variable that consumes very expensive dedicated process memory on the server. The client (SQL-Developer, TOAD, SQL*Plus, etc) can read the contents of this variable and the client can render that contents on the client's display device.
    So how on earth does it make sense to take SQL data on the server (that is structured data and can vary significantly in volume), and write that as plain text into a PL/SQL variable?
    It does not make sense. At all. Bluntly put - it is just plain bloody stupid.
    So how do you return data using PL/SQL? The same way as you return data using SQL.
    PL/SQL allows the complexity of the SQL language, database model and so on to be moved from the client application into PL/SQL itself. The client thus no longer need to know table names, what to join where and when, how to write effective SQL and so on. It calls a PL/SQL procedure with optional parameters. This procedure has the logic to create the required SQL (based on the parameters too if applicable) and return the cursor handle for that SQL.
    The client thus calls PL/SQL, PL/SQL serves as the SQL abstraction layer and does the complex SQL bit, and PL/SQL then returns the SQL cursor handle to the client.
    In the PL/SQL language, there are different data types for dealing with the same SQL cursor handle - depending on what you want to do with that SQL cursor.
    If you want to pass that SQL cursor handle to a client, then you need to use the sys_refcursor data type in PL/SQL. Remember that SQL cursor does not know or care what data type the client (such as PL/SQL) uses to reference it. All SQL cursors in the server's shared pool are the same - how you treat them from a client side (as an explicit cursor, implicit cursor, ref cursor, etc) is a client program decision.
    Also keep in mind that a SQL cursor is NOT a result set. It is not a data set that is instantiated or created on the server that contains the data (or references to the data) for your SQL.
    If this was the case - just how many such cursor result sets could the server create before running out of memory?
    A cursor is an executable program. The source SQL code is compiled into a program called a cursor. This cursor contains the execution steps that the server needs to follow to find the data. The cursor then outputs this data as data is found. The execution plan of a cursor shows how this program looks like.

  • Getting DTD structure from Oracle DOMParser

    I am having trouble getting DTD structure from DOMParser after I parse the xml file with external DTD.
    When I do:
    xmlDOMParser.parse(new FileInputStream(xmlFile));
    XMLDocument xmlDoc=xmlDOMParser.getDocument();
    DTD docType=xmlDOMParser.getDoctype();
    NamedNodeMap nodeMap=docType.getElementDecls();
    the nodeMap is equal to null.
    I need to get the element structure of DTD, how can I do that?

    The below example is working fine for me
    create table t1
       as
        select object_id id, object_name text
          from all_objects;
    Create table t2
      as
      select t1.*, 0 session_id
        from t1
       where 1=0;
    CREATE OR REPLACE TYPE t2_type
    AS OBJECT (
      id         number,
      text       varchar2(30),
      session_id number
    create or replace type t2_tab_type
    as table of t2_type
    create or replace
      function parallel_pipelined( l_cursor in sys_refcursor )
      return t2_tab_type
      pipelined
      parallel_enable ( partition l_cursor by any )
      is
          l_session_id number;
          l_rec        t1%rowtype;
      begin
          select sid into l_session_id
            from v$mystat
           where rownum =1;
          loop
              fetch l_cursor into l_rec;
              exit when l_cursor%notfound;
              -- complex process here
              pipe row(t2_type(l_rec.id,l_rec.text,l_session_id));
          end loop;
          close l_cursor;
          return;
      end;
      /And its getting executed in parallel
    SQL> select DISTINCT session_id
      2    from table(parallel_pipelined
      3              (CURSOR(select /*+ parallel(t1) */ *
      4                        from t1 )
      5               ))
      6  ;
    SESSION_ID
           221
            76
            77
           241
           161
           152
           160
           302
           232
           313
            73
    SESSION_ID
           292
    12 rows selected.But why its getting disconnected in my scenario. ???

Maybe you are looking for

  • Lumia+windows 8

    as we know that current lumias wont be getting windows 8 upgrade...why doesnt nokia start launching upgradeable phones with hardware support for windows 8...it should not wait till the win8 gets launched...nokia goooo you have to win!!!!

  • Classpath in web.xml

    how do i define my classpath in the web.xml? i inserted the tag <classpath id='/directory/file.jar'/> w/in the <web-app> tags and my servlet still cannot find the file. is this the correct method?

  • How do I get rid of an error message that comes up on opening the Photoshop Elements 8 Organizer?

    When I double-click on the Adobe Photoshop Elements 8 desktop icon, an error messsage appears. The title line says: OWL ORPHANAGE: PhotoshopElementsEditor.exe - System Error Then the message ; The program can't start because CoreFoundation.dll is mis

  • Difference between Oracle Testing Center and Prometric?

    what is the Difference between Oracle Testing Center and Prometric?

  • BufferedReader readLine() not returning null

    I'm trying write an SMTP client using Socket. I'm sending EHLO command to the SMTP server is is returning multiline response. When I tried to read this multiline response using the BufferedReader in a while loop, it is never returning null. Following