Passing rowset

A developer at our site says that we should pass a javax.sql.rowset into a stored procedures from a java class using JDBC. Is this possible and where can I find a sample?

Rowsets read cursors DO come from the database, however, Rowsets read data-to-pass-in-to-stored-proc need to be created in Java.
We had this issue as well, where we had a stored-proc that needed to take in one parameter, but that parameter would be a list (collection, cursor, array, table, etc.) of search tokens with which to perform a search.
As far as I know you can't pass a javax.sql.rowset into a stored prcedure from java, however what you can do is use Index-By tables.
Using an oracle.jdbc.OracleCallableStatement, you can bind an Index-By table from a java array, something like this:
OracleCallableStatement ocstmt = (OracleCallableStatement) conn.prepareCall("begin pkg.stored_procedure(?); end;");
int[] data = { 1, 2, 3, 4, 5, 6, 7, 8, 9 }
ocstmt.setPlsqlIndexTable(1, data.length, data.length, OracleTypes.NUMBER, 0);
ocstmt.execute();
conn.commit();
ocstmt.close();
connt.close();
To use this approach you will need the Oracle JDBC 10g drivers.
Be warned though, I have a standalone java class with a main method which can run this code fine, passing the array into PL/SQL, which then could do whatever it wanted with it. However, I still cannot get this to work in a servlet.

Similar Messages

  • Pass RowSet from one class to another

    Hi, i am trying to pass a rowset from one class to another but i keep getting the error messages:
    method does not return a value
    statement not reachable
    Does anybody know why?
    package project1;
    import java.sql.SQLException;
    public class readdata {
        public static void main(String[] args) {
            Class2 cl = new Class2();
            try {
            while (cl.openConnection().next()) {
                System.out.println(cl.openConnection().getInt("id") + "-");
            catch (SQLException se)
                    System.out.println(se);
           // while (rs.next())
             //       System.out.println(rs.getInt("id") + "-");
             //       System.out.println(rs.getString("field1") + '\n');
    package project1;
    import java.sql.Connection;
    import java.sql.DriverManager;
    import java.sql.ResultSet;
    import java.sql.SQLException;
    import java.sql.Statement;
    import javax.sql.RowSet;
    public class Class2 {
       private Connection conn;
        public Class2() {
            openConnection();
        public RowSet openConnection()
                try
                        Class.forName("sun.jdbc.odbc.JdbcOdbcDriver").newInstance();
                        conn = DriverManager.getConnection("jdbc:odbc:;DRIVER=Microsoft Access Driver (*.mdb);DBQ=D:\\test.mdb;PWD=","admin","");
                        Statement command = conn.createStatement();
                        RowSet rs = (RowSet)command.executeQuery("select * FROM testing");
                        return rs;
                        System.out.println("Connected To Access");
                        rs.close();
                        conn.close();
                catch (SQLException se)
                        System.out.println(se);
                catch (Exception ex)
                        System.out.println(ex);
    }Thanks in advance
    Message was edited by:
    snipered2003
    Message was edited by:
    snipered2003

    Hi snipered2003
    I'm fairly new to java, so check out anything I say.
    to me it appears that the code within your try block in the main method of readdata class can never throw a SQLException since the calls are to cl.openConnection() which catches any SQLException and does not throw it.
    So one statement not reachable is the statement in the catch blockSystem.out.println(se);Second, the only return statement in your openConnection() method is inside the try block, whic means that if an exception is encountered there will be no RowSet returned by the method.
    Secondly, the code in the try block in your Class2.openConnection() after the return statement will also never be reached.
    You may need something like    public RowSet openConnection()
            RowSet rs = null;
            try
                Class.forName("sun.jdbc.odbc.JdbcOdbcDriver").newInstance();
                conn = DriverManager.getConnection("jdbc:odbc:;DRIVER=Microsoft Access Driver (*.mdb);DBQ=D:\\test.mdb;PWD=","admin","");
                Statement command = conn.createStatement();
                rs = (RowSet)command.executeQuery("select * FROM testing");
                System.out.println("Connected To Access");
            catch (SQLException se)
                System.out.println(se);
            catch (Exception ex)
                System.out.println(ex);
            return rs;
        }But you will have to check for a null return value in the call to the method.
    It also looks like the code in your main method, when these things are ironed out, will run an infinite loop, but I could be wrong on that.
    I think (note: think) this part should be        RowSet rs = cl.openConnection()
            if (rs != null) {
                while (rs.next()) {
                    System.out.println(rs.getInt("id") + "-");
                rs.close();
            }Anybody please correct me if I am wrong.
    And I don't know where the conn.close would fit in this scheme of things.
    Cheers, Darryl

  • How to pass rowset properties out of mapping

    I want to pass out the count of records inserted, and the value of a field out of a mapping to send an email with this information. I cannot see how to accomplish this.
    I tried setting up an aggregate, and passing result to an Output parameter, but I get a validation error saying this is not supported.
    Anyone know how to do this?

    Hi.
    You may build a function like:
    Function Check_executed(Map_nm varchar2, execution_date date) return boolean
    v_records_selected number;
    is
    select
    b.number_records_selected total_num_records
    into v_records_selected
    from
    all_rt_audit_executions a,
    all_rt_audit_map_runs b
    where a.execution_audit_id = b.execution_audit_id
    and a.map_name = MAP_NM
    and trunc(a.created_on) = trunc(execution_date);
    if v_records_selected > 0 then
      return(true);
    else
      return(false);
    end if;
    end Check_executed;I did not test this function logic, not sure if it'll work just as it is in here, because I don't have proper rights to access this table here. :-(
    Try that and alter if necessary. Then, you may use this function in a fork, in OWF process flow.
    Hope this helps.
    Regards,
    Marcos

  • Workshop Database Controls

    We are using workshop as our development tool for a new project. Are there any guidelines concerning when to use a Database Control vs an EJB for database updates? How do Database Controls differ from entity EJB's in terms of transaction management?

    Henrik--
    In general, the Workshop Database Control executes the SQL that you
    see in each method's annotations. So, you can do a batch update in the
    context of a single transaction if you wrap a database control in a
    custom control which calls database control methods many times.
    Relative to your JPF, this would look like a batch update.
    If you pass RowSet objects to Database Control methods, the RowSet
    will generate update / insert / delete SQL statements to push changes
    made in the RowSet into the database.
    Hope that helps...
    Eddie
    Henrik Fredholm wrote:
    I want to insert many rows into a database. Does the Workshop Database Control
    or RowSet Control support batch update? How is it done?

  • Passing cursor as rowset to java procedure

    Hello,
    let me try to define my application.
    here's my tables
    news_items has 0 or many news_updates
    news_items has 0 or many news_attachments
    news_updates has 0 or many news_attachments
    so news_updates is a child of news_items. when i
    update or insert in either table i need to write a web page. this means selecting from news_items (1 row) and news_updates (0 or many rows). this is what i'm dealing with now.
    my concept is to have a java procedure that accepts a rowset or two as args. like,
    public static void updateWebsite(
    Rowset rsetItem,
    Rowset rsetUps
    String pageContent = "";
    String filePath = "";
    while( rsetItem->next() ) {
    ... getfields ...
    pageContent = formatItem(id,title,author,dateCreated, text ...);
    filePath = getFilePath(id,title,dateCreated);
    while (resetUps->next() ) {
    ... getfields ...
    pageContent =
    pageContent
    + formatUpdate( author, dateCreated, text ... );
    writeFile(filePath, pageContent);
    the first rset being the news_items rowset (1 row) and the second one being news_updates (0 or many rows).
    i'm doing this rather than selecting the fields using sql since i get mutating table problems.
    i also need to write a procedure/function/package? that is triggered on insert or update of news_items and news_updates and calls the java stored procedure. this is where i need some help. i figure i need to use cursors to pass the rowsets to java?
    in the news_items trigger
    1) create cursor1 rowset from news_items
    2) select from news_updates where news_id = x into cursor2.
    3) updateWebsite(cursor1, cursor2)
    in the news_updates trigger
    1) select from news_items where news_id = x into cursor1
    2) selcect from news_updates into a cursor2
    3) updateWebsite(cursor1, cursor2)
    Do you think this is a good path to work on?
    Any suggestions or possibly pseudo code to help me since i'm especially new to oracle is much appreciated!

    i'm using Oracle9i Release 9.2.0.4.0

  • Passing Parameter to XSL document (in XDK forPL/SQL)

    Here i' trying to pass parameters to my XSL document.But the value is not getting populated in the final document, can anyone help me on this.,.?
    // This is how i 'm passing parameter value to the XSL
    xslprocessor.setParam (styles,'p_batch_name','batch1');
    // Applyting stylesheet(xsl) with XMLdoc and storing it in a DOM node
    docn := xmldom.makeNode(xslprocessor.processXSL(engine,styles,doc));
    My XSL is like this
    <INSERT xsl:version="1.0" xmlns:xsl ="http://www.w3.org/1999/XSL/Transform">
    <xsl:param name="p_batch_name"/>
    <ROWSET table="abc">
    <xsl:for-each select="rowset/row">
    <ROW>
    <batch_name>"{$p_batch_name}"</batch_name>
    </ROW>
    <xsl:for-each>
    </ROWSET>
    <INSERT>
    But in the final document, the value (batch1) is not getting
    populated. it is coming as null .
    Can anyone help me ...
    null

    This does not work because of the following two things:
    [list=1]
    [*]The value of a parameter is interpreted as an XPath expression. Passing a value of batch1 will be interpreted as the XPath expression batch1 that will try to match any <batch1> child elements of the root of the source document. You need to include the value in quotes to have it be interpreted as a literal string:xslprocessor.setParam (styles,'p_batch_name','"batch1"');[*] The setParam method can only set the value of "top-level" stylesheet parameters. In your stylesheet, you've illegally used <xsl:param> inside a template. You need to switch from the "simple form" of a stylesheet to the "normal form" of the stylesheet to use a top-level parameter. So instead of:<INSERT>
    </INSERT>
    [code]
    you need instead:
    [code]
    <xsl:stylesheet>
    <xsl:template match="/">
    <INSERT>
    </INSERT>
    </xsl:insert>
    </xsl:stylesheet>[list]
    null

  • Urgent!! How to publish a session Info Object once and pass it to sevaral forms

    Hi , I am using JDev 3.1. I have this problem when i create several forms in Jdev, where the wizard adds a sessionInfo object for each form. It also publishes them on the Infobus every time the form is called.I tried to use 1 marster sessionInfo Object from a marster form publish it there and then pass it to the other forms, but then the rowsets don't work propally. I f any one has any ideas please post as soon as possible.

    We do have a FAQ, and the topic is part of the FAQ. Unfortunately, it seems that the FAQ is not yet available on OTN. In the meantime, I'll post some of the content here which may be useful:
    <BLOCKQUOTE><font size="1" face="Verdana, Arial">quote:</font><HR>
    Q
    How do I share database information across multiple Frames?
    A
    This describes using a SDI with multiple frames that share common database information (for example, a master-detail application
    based on Dept-Emp where Dept information is dispayed in one frame, and Emp in another). For help in constructing an MDI
    application, please refer to the JDeveloper documentation.
    1.Create an empty project
    2.Add a class to this project (this class will contain the SessionInfo, RowSetInfo, AttributeInfo)
    3.Switch to Design mode for this class, and create the SessionInfo and RowSetInfos for your application by selecting the
    appropriate object from the Component Palette, then clicking in the Structure Pane.
    4.Set the properties of these objects as normal.
    5.Create an Application with an empty Frame
    6.In design mode, drop the desired controls into the Frame.
    7.You can set all the properties for these controls as usual except for the properties that bind the control to a datasource. To bind
    the controls to a datasource, switch to Source mode and add the appropriate code, for example:
    textFieldControl1.setDataItemName("infobus:/oracle/sessionInfo1/rowSetInfo1/Deptno");
    8.Repeat steps 6 and 7 for the second Frame.
    9.Modify the Application to instantiate the class that contains the database information, and optionally to display the second
    Frame (you may want to use a button on Frame1 that shows Frame2 instead).
    Note that if you wish to access the methods of the database information objects programmatically, you may need to make the objects
    public static.
    <HR></BLOCKQUOTE>
    Also in regards to Ali's comment that executing all these queries when the app starts, you may be interested in the following:
    <BLOCKQUOTE><font size="1" face="Verdana, Arial">quote:</font><HR>
    Q
    How do I delay the execution of one or more queries?
    A
    By default, all queries being used by RowSetInfos in your application are executed when SessionInfo.PublishSession() is invoked.
    There are two methods to potentially improve the performance of your DAC application if your queries return a large number of
    rows.
    1) As a workaround, you can dynamically alter the Where clause of your queries so that fewer rows (or no rows) are retrieved
    initially. For example, include the condition 1=2 in the Where clause. Then, based on some interaction from the user, you can set a
    "real" where clause condition. For information on dynamically altering the Where clause, see the appropriate FAQ.
    2) A slighter cleaner method is to delay the association and subsequent publishing of the RowSetInfo until AFTER
    SessionInfo.publishSession() is invoked. The following illustrates the order in which the key steps would be performed:
    1.define the all RowSetInfo objects and their attributes
    2.parent any RowSetInfo whose queries should be executed immediately to the SessionInfo object
    3.publish the SessionInfo
    4.parent any RowSetInfo objects whose queries should be delayed to the SessionInfo object
    5.when appropriate, publish the RowSetInfo using RowSetInfo.publishRowSet(true)
    <HR></BLOCKQUOTE>
    And, finally, the above makes reference to a FAQ for how to dynamically set the where clause:
    <BLOCKQUOTE><font size="1" face="Verdana, Arial">quote:</font><HR>
    Q
    How do I dynamically alter the Where clause of a RowSet?
    A
    There are two ways to accomplish this task. You can either call the setWhereClauseCondition on the RowSet, or you can use bind
    variables. Both of the samples below assume a TextField named textSearch in which the user has entered a search value.
    void buttonSearch_actionPerformed(ActionEvent e) {
    // Two ways of "refreshing" the RowSet with condition specified by user
    // Note that both samples use AttributeInfo.getColumnName() to get the appropriate
    // format of the column name which differs depending on whether the VO uses "Expert mode"
    // Example using dynamically created condition
    rowSetInfo1.setQueryCondition(NamerowSetInfo1.getColumnName() + " LIKE '" + textSearch.getText() + "%'");
    // Example using bind variable in condition (Note that the VO and its associated views must use ? style parameters)
    rowSetInfo1.setQueryCondition(NamerowSetInfo1.getColumnName() + " LIKE ?");
    rowSetInfo1.setQueryConditionParams(new Object[] {textSearch.getText() + "%"});
    // Execute the query in either case...
    rowSetInfo1.executeQuery();
    <HR></BLOCKQUOTE>
    I hope this helps!!!
    -- Brian
    null

  • Update passed in XML doc with pl/sql xmldom

    Hi,
    I have an xml document that is passed in through a stored procedure as CLOB. I'm trying to use the XMLParser and XMLDOM to add an additional node
    The XML looks something like the following
    <rowset>
    <row>
    <firstname>john</firstname>
    </row>
    <row>
    <firstname>jane</firstname>
    </row>
    </rowset>
    I need to loop through each of <mynames> nodes and then add another node <lastame> so it looks like the following
    <rowset>
    <row>
    <firstname>john</firstname>
    <lastame>smith</lastame>
    </row>
    <row>
    <firstname>jane</firstname>
    <lastame>smith</lastame>
    </row>
    </rowset>
    I have the following code
    parseClob XMLPARSER.Parser;
    newNames XMLDOM.DOMDocument;
    tempNode XMLDOM.DOMNode;
    mye xmldom.domelement;
         item_text xmldom.DOMText;
    numofrows number;
         nodeList xmldom.DOMNodeList;
         newnode xmldom.domnode;
    parseClob := xmlparser.newParser;
    XMLPARSER.parseClob(parseClob,names);
    newNames := XMLPARSER.getDocument(parseClob);
    XMLPARSER.freeParser(parseClob);
    nodeList := xslprocessor.selectNodes(xmldom.makeNode(newNames), '//rowset/row');
    numOfRows := xmldom.getlength(nodeList)-1;
    for i in 0..numOfRows LOOP
    newnode := xmldom.item(nodeList, i);
              --create the new node
    mye := xmldom.createElement(newName, 'lastname');
    --add it to the new node   
    tempNode := xmldom.appendChild(newnode, xmldom.makeNode(mye));
    --update the text in the lastname   
    item_text := xmldom.createTextNode(newNames, 'smith');
    tempNode := xmldom.appendChild(tempNode, xmldom.makeNode(item_text));
    end loop;
    what happens is that when i write out the newnode xml out to a buffer i see the <lastname> tag
    but when i write out the newNames xml out to a buffer after the loop is finished the <lastname> tag is
    missing. like it didn't update the newNames xml
    I've seen lots of example on how to create an XML document with the DOM from scratch but nothing about updating
    an passed in xml document. any help would be appreciated

    Updatexml is reference in Oracle 9i, I'm sorry i should have mentioned that I am using oracle 8i. Is there something you can use in oracle 8i?

  • Create Resultset/Rowset programatically

    How can I create a resultset/rowset programatically from scratch, without connecting to database. Actually I'm designing an N-tier intranet app. The page controller (JSP) has to pass the data of the HTTP request to the buiness tier in a generic form. As our business tier is using resultset for its methods (for efficiency and simplicity we avoided using a pure object oriented business tier whose objects have the state as their fields. Instead we have resultsets of the whole query that has the data of a single business transaction).
    Is it possible to create rowset without database connection? How?

    You can do it using CachedRowSet:
    import java.sql.*;
    import javax.sql.*;
    import sun.jdbc.rowset.*;
    public class RowSetExample
    public static void main(String args[])
    try {
    // create a new rowset and populate it...
    sun.jdbc.rowset.CachedRowSet crs = new sun.jdbc.rowset.CachedRowSet();
    sun.jdbc.rowset.RowSetMetaDataImpl rsmdi = new sun.jdbc.rowset.RowSetMetaDataImpl();
    int colCount = 2;
    rsmdi.setColumnCount(colCount);
    rsmdi.setColumnDisplaySize(1, 5);
    rsmdi.setColumnName(1, "ID");
    rsmdi.setColumnType(1, java.sql.Types.INTEGER);
    rsmdi.setColumnTypeName(1, "INTEGER");
    rsmdi.setTableName(1, "MY_TABLE");
    rsmdi.setAutoIncrement(1, false);
    rsmdi.setSearchable(1, true);
    rsmdi.setColumnDisplaySize(2, 20);
    rsmdi.setColumnName(2, "NAME");
    rsmdi.setColumnType(2, java.sql.Types.VARCHAR);
    rsmdi.setColumnTypeName(1, "VARCHAR");
    rsmdi.setTableName(2, "MY_TABLE");
    rsmdi.setAutoIncrement(2, false);
    rsmdi.setSearchable(2, true);
    crs.setMetaData(rsmdi);
    java.util.Map map = new java.util.HashMap();
    map.put(new Integer(1), "AAA");
    map.put(new Integer(2), "BBB");
    map.put(new Integer(3), "CCC");
    java.util.Iterator iter = map.entrySet().iterator();
    while (iter.hasNext()){
    java.util.Map.Entry entry = (java.util.Map.Entry) iter.next();
    int idx = 0;
    crs.moveToInsertRow();
    crs.updateObject(1, entry.getKey());
    crs.updateObject(2, entry.getValue());
    crs.insertRow();
    crs.moveToCurrentRow();
    crs.beforeFirst();
    while (crs.next()){
    System.out.print(crs.getObject(1));
    System.out.println(": " + crs.getObject(2));
    }catch (SQLException ex) {
    System.err.println("SQLException: " + ex.getMessage());
    }

  • Pass XML to MII transaction via HTTPService in FLEX

    Hi folks,
    I have a problem with a HTTPService call of a MII transaction in Flex3. It always worked fine, when I only had to pass simple parameters like strings etc. But now I have a transaction that expects 3 String parameters (they are received) and two XML parameters. I already tried several possibilities:
    1.) I put the XML data into an object in Flex and passed this object for the XML parameters - the XML is empty on MII side
    2.) I change the content-type of the HTTPService to application/xml and passed the XML parameters as XML - the XML is still empty on MII side.
    So my question is: Is it possible to send such a combined HTTPService call with Strings AND XML? Did anybody already do that? The XMLs have the typical MII-structure with Rowsets/Rowset/Row, but without the column-description at the beginning - could that be a point, that MII cannot deal without this column description? But I already tried to send an XML in an other structure and it was also empty on MII side.
    Would be great if anybody has any suggestion!
    Thanks,
    Anika
    EDIT: I now realized, that if I pass only one XML parameter, it works. As soon as I pass both XML parameters, it does not work and shows up a HTTP request error. Don't know why... Maybe it's limited to a certain string length in the transaction call, that is exceeded when I pass both parameters?
    Edited by: Anika Delzeit on Nov 25, 2009 5:54 PM

    If you think you're encountering URL length issues make sure you are using POST and not GET, although it looks like there may be additional issues:  http://www.javaworld.com/community/node/2307

  • Passing date format in sys.dbms_xmlgen

    hello all,
    i am using following query to generate insert SQL statements
    SELECT
    'insert into ' || table_name || ' (' || (select rtrim(extract(xmlagg(xmlelement(e, t.column_value.getrootelement() || ',')),'//text()'),',') from table(xmlsequence(t.column_value.extract('ROW/*'))) t) || ') values (' ||
    (select dbms_xmlgen.convert(rtrim(extract(xmlagg(xmlelement(e, '''' || t.column_value.extract('//text()') || ''',')),'//text()'),','),1) from table(xmlsequence(t.column_value.extract('ROW/*')))t) || ');' ins_stmt
    from user_tables,
    table(xmlsequence(dbms_xmlgen.getxmltype('select * from ' || a_TblName ||' WHERE MODIFIEDON >'||a_date).extract('ROWSET/ROW'))) t
    where table_name in (select table_name from user_tables where table_name =a_TblName);but when i execute the procedure as
    sql> exec   Gen_Insert_Statement('11-jun-2009');
    ORA-19202: Error occurred in XML processing
    ORA-00904: "JUN": invalid identifier
    ORA-06512: at "SYS.DBMS_XMLGEN", line 288
    ORA-06512: at line 1
    ORA-06512: at "MRILDATA17TEST.GEN_INSERT_STATEMENT", line 22
    ORA-06512: at line 2     and if i do this
    SQL> exec Gen_Insert_Statement('11-06-2009');
    begin Gen_Insert_Statement('11-06-2009'); end;
    ORA-01843: not a valid month
    ORA-06512: at line 2is there any format to pass date while using XML packages??? i am also not getting in which this issue is occuring??
    any suggestion will be appreciable
    thanks and regards
    VD
    Edited by: dixit on Aug 13, 2009 6:15 AM
    Edited by: dixit on Aug 13, 2009 6:21 AM

    The date issue is coming from
    dbms_xmlgen.getxmltype('select * from ' || a_TblName ||' WHERE MODIFIEDON >'||a_date)It is due to the implicit conversion from the internal Date object type to a String type for display. The format is based off the NLS_DATE_FORMAT so varies from system to system. When dealing with dates, it is always best to use either to_char or to_date to ensure there are no errors in converting from one format to the other. That would include adding to_date with a format mask making it part of your Select SQL statement around a_date, such as to_date(a_date, 'DD-MON-YYYY')
    Also, if you have any dates in the tables that are being queried, you will run into a similar implicit conversion issue. Oracle does not format dates in the proper XML format of YYYY-MM-DD when building XML in this manner as it uses the NLS_DATE_FORMAT. So you cannot guarantee the INSERT statement will work on another DB with a different NLS_DATE_FORMAT.
    As others have asked, why you are trying to build insert statements this way as there is a lot to take into consideration regarding data formats. It seems this has been discussed on the {forum:id=75} forum but that has been some time ago.

  • Passing data to a separate jpf

    What is the best practice for passing data from one jpf to another? I have a collection of jpf's generated from rowset controls. And, I would like some of them to restrict their query only to the parent row as selected in a previous screen. What is the bestway to minimize maintenance and rework to store this key, and use it in the receiving jpf rowset control? Should I simply save it in global, and modify the sql in the receiving jpf's associated rowset control?

    Thanks. Unfortunately when I try to follow the url you provided it dumps me in the help files:
    http://e-docs.bea.com/workshop/docs81/doc/en/core/index.html
    And, when I try to enter the url explicitly, I get an error saying I do not have sufficient authority to access it. I get this at the samplesrc directory.

  • Passing null as input parameter for relational physical DS

    I'm creating a adapter(physical and logical) to talk to a Sybase Stored procedure. A few input integer arguments to the stored procedure are always null
    From Stored procedures - default NULL , I use xs:int(()) to pass in nulls. But for the 2nd argument($id),which has args with valid input following it, the stored procedure does not return any results. Executing the same stored proc with same inputs via Java JDBC or Sybase central gives the right results.
    But if i give a value for the 2nd argument ($id), the stored proc returns valid multi-row results indicating that the plumbing(my rowset schema..) works.
    In the below code, I have included the 2nd argument(id_inp) as an input to Logical just to be able to test using "setNull" check box. I also tried just passing "xs:int(())" without getting it as input into the logical.
    Physical:
    declare function f1:test_get($cid as xs:string, *$id as xs:int?*, $dt as xs:string, $tm as xs:string, $in1 as xs:int?, $in2 as xs:int?, $in3 as xs:int?, $in4 as xs:int?) as schema-element(t1:test_get) external;
    Logical:
    declare function tns:test_get($cid_inp as xs:string, $dt_inp as xs:string, $tm_inp as xs:string, *$id as xs:int?*) as element(ns1:OutputSchema)*{
    for $test_ret_get in f1:test_get($cid_inp, *$id*, $dt_inp, $tm_inp, xs:int(()), xs:int(()), xs:int(()), xs:int(()))
    return
    The sybase stored proc is declared as below: [ id, in1.in2,in3,in4 do not need to be passed in]
    create proc test_get
    @cid          varchar(32)=null,
    @id          int=null,
    @dt               varchar(8)=null,
    @tm               varchar(8)=null,
    @in1               int=null,
    @in2          int=null,
    @in3          int=null,
    @in4           int=0
    as
    Can i pass in null to an input argument followed by valid inputs to arguments following it?
    Is there any other way to send null?
    Thank you.

    mikereiche wrote:
    First - it is impossible to optimize stored procedures, as sorting, joining and filtering cannot be "pushed" inside the stored procedure. For this reason, I encourage you to avoid using stored procedures in your solution.Unfortunately, this is an external Sybase DB stored proc that we need to call to get data.
    >
    The issue is that SQL syntax for querying for a null value ( ... where COL_A is null ) is not consistent with querying for a non-null value (... where COL_A = ? ), and for ODSI to support querying for null values, it would need to delay generating the sql until the value of the arguments was known, and also there would be the possibility of having 2^number_of_args different sql statements. So it does not execute queries where any of the arguments are null. (look at the audit for your query, there won't be any executions of the sql).
    The stored procedure seems to correctly handle the null input parameters since I get the correct results with Java JDBC.
    See the thread, Re: Search Functionality , the post by Jeff Hoffman at "Mar 8, 2010 12:24 PM"
    Jeff shows how to solve this problem when it occurs in a sql query (SELECT) - and this is useful for doing query-by-form - which, by the looks of it, is what you are after. To implement it for a stored query, you would need an extra "IsNull" arg for each arg that could be null,
    myProcedure( @lastName varchar(8), @lastNameIsNull int, @firstName varchar(8) @firstNameIsNull int)
    select from CUSTOMER where (LASTNAME = @lastName or @lastNameIsNull=1) and (FIRSTNAME = @firstName or @firstNameisNull=1)
    And you would call that from ODSI as below (using Jeff's ensureNotNull function).
    myProcedure( tns:ensureNotNull($lastName), fn:empty($lastName) , tns:ensureNotNull($firsttName), fn:empty($firstName) )
    You may note that when lastName is null, a bogus value of "" (empty-string) will be passed for the value of @lastName. This does not matter since LASTNAME = @lastName will have no effect in the query since @lastNameIsNull=1 is true.I'm probably missing something but it is different in my case that i want to pass in null and the stored proc already has the necessary check for null. It looks up a different table when this arg is null and gets the values needed for execution.
    I turned on the Audit for query parameters and it goes out as null for the 2nd argument. Its probably what i'm not getting from your explanation but I don't understand why it would behave differently compared to Java JDBC when it looks like the input parameters are the same. This also uses the JDBC DataSource created in Weblogic console.
    Audit log:
    rows: 0
    parameters:
    10000
    null
    12/06/11
    15:48:00
    null
    null
    null
    0

  • Passing multiple rows of data as an XML input to a transaction

    Hi,
    I have a grid with several rows and columns of data on the front-end UI. I would like to select few rows and pass the data as an XML structure to a transaction. Is this possible? If so, how could I do this?
    Regards,
    Chanti.

    Hello Chanti,
    Yes, Its definitely possible, I have done it on couple of occasions and it has worked
    Option 1:
    1) Pass each row value in a string where each row is separated by a comma as shown,
    Value1,Value2,Value3.....
    2) Then within BLS use it as string input variable and parse it using String_List_To_XML XML action block.
    Option 2:
    1) If you are aware of the required XML structure then prepare one as string by appending reach rows something like as shown below,
         var SpeedXML = "";
         SpeedXML =      '<?xml version="1.0" encoding="utf-8"?>'
         SpeedXML =     SpeedXML + '<Rowsets Version="12.1">'
           SpeedXML =     SpeedXML + '<Rowset>'
         SpeedXML = SpeedXML + '<Columns>'
         SpeedXML =     SpeedXML + '<Column Description="" MaxRange="1" MinRange="0" Name="Average_Run_Speed" SQLDataType="1" SourceColumn="Average_Run_Speed" />'
         SpeedXML =     SpeedXML + '<Column Description="" MaxRange="1" MinRange="0" Name="Line_Stops" SQLDataType="1" SourceColumn="Line_Stops" />'
         SpeedXML =     SpeedXML + '</Columns>'
    Here in this section you can loop through your rows and append them to structure,
    Start Loop
         SpeedXML = SpeedXML + '<Row>'
         SpeedXML = SpeedXML + '<Average_Run_Speed>'+ Value1 +'</Average_Run_Speed>'
         SpeedXML = SpeedXML + '<Line_Stops>'+ Value2 +'</Line_Stops>'
         SpeedXML = SpeedXML + '</Row>'
    End Loop
         SpeedXML = SpeedXML + '</Rowset>'
         SpeedXML =     SpeedXML + '</Rowsets>'
    2) Now in the Transaction, use it as String input variable and parse it using String_To_XML XML action block
    Hope this helps!!
    Regards,
    Adarsh

  • Passing in parameters to Data Instance

    Hi
    I read in OSM 7.2 Release Notes on vf:instance :
    You can now add explicit parameter values from within an XQuery or XPath that
    augment or override the parameters defined in the OSM data dictionary using
    vf:instance()
    My question is, how do I make use of the parameters passed in in my Data Instance?
    The example given in Developer's Guide says:
    log:info($log,local-name(
    vf:instance($order/oms:GetOrder.Response/oms:_root/oms:data[1],'DataInstance',<oms:url>file://us/catalog.xml</oms:url>)/*[1]
    How do I make use of parameter oms:url in the Data Instance?
    I tried using ${oms:url} but it gives me compile error.
    I created a new namespace for the data instance to obtain the passed in parameters. Is this the correct way?
    the xquery to invoke the data instance:
    let $dataInstanceParams := <m1:params xmlns:m1="http://xxx.com/bcc/osm/com/orderopco/xml">
    <m1:OMGroupRefID>{fn:normalize-space(im:MainOrderLineItem[0]/im:OMGroupRefID/text())}</m1:OMGroupRefID>
    <m1:ActionCode>{fn:normalize-space(im:MainOrderLineItem[0]/im:ActionCode/text())}</m1:ActionCode>
    </m1:params>
    let $dboutput2 := vf:instance('CheckProductGroupExists',$dataInstanceParams/*)
    adapter is JDBC adapter, built-in.
    My Data Instance Behavior's oms:sql is:
    <query xmlns:im="http://xxx.com/bcc/osm/com/orderopco">
    <sql>
    select opg_ref_id from C_OM_OPG_MAP
    where om_product_group='{$OMGroupRefID}'
    and action_code='{$ActionCode}'
    </sql>
    </query>
    Thanks.
    Will
    Edited by: will.s on Dec 10, 2012 6:01 PM added xquery to invoke the data instance

    Hi Will;
    The DatabaseAdapter expects input parameters to be named "in:1", "in:2", "in:3" and so-on. The numbers 1, 2, 3, etc. correspond to the position of the ? entry in your SQL parameter. in:1 would be used as the value for the first ? in your sql, in:2 would be used as the value for the second ? and so-on.
    So based on this, your xquery would need to be something like this:
    let $dataInstanceParams := <m1:params xmlns:m1="http://xxx.com/bcc/osm/com/orderopco/xml">
    <in:1>{fn:normalize-space(im:MainOrderLineItem[0]/im:OMGroupRefID/text())}</in:1>
    <in:2>{fn:normalize-space(im:MainOrderLineItem[0]/im:ActionCode/text())}</in:2>
    </m1:params>
    let $dboutput2 := vf:instance('CheckProductGroupExists',$dataInstanceParams/*)
    We don't care what the namespace is that you use, but the namespace prefix must be "in:".
    For your reference, I'm copying below the full text of the Javadocs for the DatabaseAdapter. You can find the docs for this and other adapters in the OSM SDK Javadocs.
    This class implements a View Framework external instance adapter that executes a SQL statement and builds an XML document based on the result set.
    There are two mandatory parameters for this class, oms:sql and oms:dataSource.
    oms:dataSource: Refers to the jndi name of a JDBC datasource defined in WebLogic. For example 'mslv/oms/oms1/internal/jdbc/DataSource'
    oms:sql: Contains the sql that will be sent to the database. For example 'select * from scott.emp where empno=?'
    Additional optional input parameters may be supplied that will be bound to parameters defined in the oms:sql value. For example, in the above sql statement a parameter is used to define the value for 'empno' in the where clause. A value for this parameter may be specified by defining a paremter called "in:1". If there were additional input parameters defined in the sql statement, these could be passed as "in:2", "in:3" and so on.
    In all cases these input parameters will be assumed to be string values and bound to the sql statement as string values.
    The following is an example of using the DatabaseAdapter to invoke a query:
    <instance name="well_paid_salesman" xsi:type="externalInstanceType">
    <adapter>com.mslv.oms.view.rule.adapter.DatabaseAdapter</adapter> <parameter
    name="oms:dataSource">'mslv/oms/oms1/internal/jdbc/DataSource'</parameter> <parameter
    name="oms:sql">"select * from scott.emp where job='SALESMAN' and sal > ?"</parameter> <parameter
    name="in:1">1250</parameter> </instance>
    The above declaration returns the following XML instance:
    <results> <rowSet> <row> <empno>7499</empno> <ename>ALLEN</ename> <job>SALESMAN</job> <mgr>7698</mgr>
    <hiredate>1981-02-20 00:00:00.0</hiredate> <sal>1600</sal> <comm>300</comm> <deptno>30</deptno> </row> <row>
    <empno>7844</empno> <ename>TURNER</ename> <job>SALESMAN</job> <mgr>7698</mgr> <hiredate>1981-09-08
    00:00:00.0</hiredate> <sal>1500</sal> <comm>0</comm> <deptno>30</deptno> </row> </rowSet> </results>
    The DatabaseAdapter can also be used to execute SQL stored procedures.
    The DatabaseAdapter provides a stored procedure SQL escape syntax that allows stored procedures to be called in a standard way for all RDBMSs. This escape syntax is defined as part of the Java JDBC API.
    This escape syntax has one form that includes a result parameter and one that does not. If used, the result parameter must be registered as an OUT parameter. The other parameters can be used for input, output or both. Parameters are referred to sequentially, by number, with the first parameter being 1.
    {?= call [,, ...]}
    {call [,, ...]}
    Values for input parameters to the stored procedure are specified using the in:1, in:2 (etc.) parameters in the same way as they are for regular SQL queries.
    Output parameters are specified using out:1, out:2 (etc.). Keep in mind that the parameter number (1, 2, 3, etc.) are numbered sequentially from 1 ordered from left to right in the specified SQL statement including both input and output parameters.
    The value of the parameter is the parameter SQL type (see http://java.sun.com/j2se/1.4.2/docs/api/java/sql/Types.html for a list of types).
    The following example illustrates how to call a database stored procedure that has one output parameter (the result of the stored procedure call), and one input parameter.
    <instance name="lock_count" xsi:type="externalInstanceType">
    <adapter>com.mslv.oms.view.rule.adapter.DatabaseAdapter</adapter> <parameter
    name="oms:dataSource">'mslv/oms/oms1/internal/jdbc/DataSource'</parameter> <parameter
    name="oms:sql">"{? = call om_cartridge_pkg.get_any_cartridge_id('my_cartridge',?)}"</parameter> <parameter
    name="out:1">'INTEGER'</parameter> <parameter name="in:2">'1.1'</parameter> </instance>
    The above declaration returns the following XML instance:
    <results> <outputParameter number="1">1234</outputParameter> </results>

Maybe you are looking for

  • DBIF_RSQL_INVALID_REQUEST

    when loggind on using SAP GUI, an abap runtime error is appearing at the beginning  DBIF_RSQL_INVALID_REQUEST whose details are Runtime Error          DBIF_RSQL_INVALID_REQUEST Date and Time          13.06.2008 09:57:13 ShrtText Invalid call of datab

  • When i try to install windows 8 with bootcamp on my Macbook pro (early 2011) it says it only supports windows 7, how can i fix this?

    When i try to install windows 8 with bootcamp on my Macbook pro (early 2011) it says it only supports windows 7, how can i fix this?

  • Pegasus2 disk mount fails to mount in time during restart

    I have a new Mac Pro + Pegasus2 external drive.   If I restart the system, the boot happens and files under the mount point are accessed before the Pegasus2 drive is ready to be mounted, which appears to block the mount point.    I called the mount p

  • Invalid column name: syabase issue

    Hi    I am trying to load data from sybase into temporary table. When i executing the job, it is giving the following error. 3220     5728     DBS-070404     2/11/2008 8:07:26 AM     SQL submitted to ODBC data source <ppi-r_pp3_V1R00> resulted in err

  • ITunes radio not working

    No idea why, but iTunes radio has stopped working. I reinstalled the latest version, but when I open 'Radio' and click on a category I get "An error occurred while contacting the radio tuning service. Check your Internet connection, or try again late