Java and Sybase nested stored procedures.

Hi!
I have nested Sybase stored procedures, the main procedure calls a helper stored proc.
The main procedure returns 2 result sets before calling the helper store proc and helper store proc returns 1 resultset. After the helper store proc is called, the main store proc returns 2 more resultset. When I run it using SQL client tool the main procedure(and it's helper) execute well and returns rows.
I need to call this store proc in a java code and display all the resultset in screen. I am using Statement:execute(<exec sp>) to execute the store proc and then statement.getResultSet() to get each resultset. The loop is controlled by statement.getMoreResults() .
It displays the first 2 resultsets from main Store Proc. Then the control goes to helper store proc. It executes the helper store proc and displays the resultset from helper. But then it stops there and doesnot
come back to main store proc to execute the remaining resultset.
What I suspect is that, the statement object is getting overlaid when the call goes to helper proc.
Any idea as to how to code to handle multiple nested resultset ?
~ RNS.
My Sybase stored procedure code looks like -
=======================================================================
create procedure main_proc
@param1 int
as
select getdate()
select @@servername
declare @return_val int
exec proc2 @param1, @return_val out
select myCol1,
myCol2,
myCol3=@return_val
from mytable
select db_name()
===========================================================================
Sybase Code for proc2
create procedure proc2
@param1 int,
@param2 int out
as
begin
if something exists(select * from table where whereClause)
select @param2="TRUE"
else
select @param2="FALSE"
select getdate()
end
go
GRANT EXECUTE...
EXEC sp_procxmode 'dbo.proc2,'unchained'
go
====================================================================
Code snippet :-
do {
int iit=0;
rs=stmt.getResultSet();
if ( rs != null ) {
ResultSetMetaData rsd = rs.getMetaData();
int nocols = rsd.getColumnCount();
for (int i=1; i<=nocols; i++)
System.out.println(rsd.getColumnName(i)));
while (rs.next())
for (int i=1; i<=nocols; i++)
System.out.println(rs.getString(rsd.getColumnName(i));
} while (stmt.getMoreResults());

I'm not 100% sure about this, but my guess is that this is caused by the TDS protocol (used by Sybase). TDS makes no difference between the stored procedure you are calling and the "inner" stored procedure, so the driver just returns update counts and result sets as they are generated, regardless of who generated them.
Another guess (as I don't know what driver you are using) is that execute() returns the first result (update count or ResultSet), as opposed to executeQuery(), which returns the first ResultSet (probably discarding the update count). You can make sure of this by calling getMoreResults(); you should get your ResultSet at some point.
Alin.

Similar Messages

  • Varbinary(max) parameters in Nested Stored Procedures by value or reference _Expand / Collapse

    Consider a situation where a stored procedure taking a varbinary(max) (BLOB) input parameter
    then calls a nested stored procedure and passes along that varbinary(max) as an input parameter to the nested stored procedure.
    Is a copy of the BLOB provided to the nested stored procedure (passed by value) OR is the BLOB passed by reference.
    My interest is in understanding the potential memory hit when handling large BLOBs in this environment.
    For example, if the BLOB is 200MB, will SQL server need to allocate memory for a new copy each time it's passed to another stored procedure at the next nestlevel?
    Looks like table type parameters are passed by reference, but I haven't been able to find any info on BLOBS in this context.

    The semantics for parameters in SQL Server is copy-in/copy-out. However, this does not mean that there cannot be optimizations. That is, there is no need to copy the BLOB, as long as the procedure does not change it. Whether they actually have such an optimization,
    I don't know.
    I composed the repro below, and it is sort of interesting. If I restart my instance (SQL 2014), the memory usage grows with about 40 M for each nesting call, which certainly indicates that the BLOB is copied over and over again. But if I then run it again,
    the growth is not the same. This may be because, it uses buffers already available. (A BLOB has to be a handle like a table when it is over some size.) Then again, it means that it is squeezing something else out of the cache.
    CREATE PROCEDURE K  @h varchar(MAX) AS
       SELECT SUM(pages_kb)*8192 AS K, datalength(@h) as Dlen FROM sys.dm_os_memory_clerks
       SELECT @h = ''
    go
    CREATE PROCEDURE L  @h varchar(MAX) AS
       SELECT SUM(pages_kb)*8192 AS L1, datalength(@h) as Dlen FROM sys.dm_os_memory_clerks
       EXEC K @h
       SELECT SUM(pages_kb)*8192 AS L2, datalength(@h) as Dlen FROM sys.dm_os_memory_clerks
       --SELECT @h = ''
    go
    CREATE PROCEDURE M  @h varchar(MAX) AS
       SELECT SUM(pages_kb)*8192 AS M1, datalength(@h) as Dlen FROM sys.dm_os_memory_clerks
       EXEC L @h
       SELECT SUM(pages_kb)*8192 AS M2, datalength(@h) as Dlen FROM sys.dm_os_memory_clerks
       --SELECT @h = ''
    go
    CREATE PROCEDURE N  @h varchar(MAX) AS
       SELECT SUM(pages_kb)*8192 AS N1, datalength(@h) as Dlen FROM sys.dm_os_memory_clerks
       EXEC M @h
       SELECT SUM(pages_kb)*8192 AS N2, datalength(@h) as Dlen FROM sys.dm_os_memory_clerks
       --SELECT @h = ''
    go
    DECLARE @h varchar(MAX) = replicate(cast('ABCD' AS varchar(MAX)), 1E7)
    EXEC N @h
    go
    DROP PROCEDURE K, L, M, N
    Erland Sommarskog, SQL Server MVP, [email protected]

  • Using XI - RFC table and an Oracle stored procedure that returns a cursor.

    I need to create an interface using XI between an RFC table and an Oracle stored procedure that returns a cursor.  We are on oarcle 9.2 and  SP12.
    My stored procedure looks something like this:
    CREATE OR REPLACE
    PROCEDURE testproc_xi2 (p_recordset1 OUT SYS_REFCURSOR,
                                             in_quoteid IN varchar2 )
    AS
    BEGIN
      OPEN p_recordset1 FOR
       SELECT  q.quote_id,
                     q.modified_by,
                     q.quote_status,
                     q.total_cost
                FROM quote q
               WHERE q.quote_id = in_quoteid
                 AND q.total_cost > 0 ; 
    END testproc_xi2 ;
    My RFC has table and  one import parameter .
    I wanted to know how to create the data type for the ref cursor? and also for the table type in the RFC?
    CAN XI handle multi rows coming from a Stored procedure? Are there any other alternative methods if this is not supported?Any pointers to this would be helpful.
    I have called a Oracle SP from an RFC before, but that interface had one input parameter going to the stored procedure from the RFC and about 6 o/p parameters coming from the Stored procedure. This works fine.
    Thanks for the help.
    Mala

    Mala,
    i dont think there is anything called an rfc table...RFC stands for remote function call. That in essence would imply you need a rfc to jdbc connection.
    yes XI can handle multiple rows cooming from the the stored procedure if you have them mapped appropriately.
    Now as to how to create the data type within xi , you need to know what fields are going to be returned and whether they are nested and then just create them as you would for an xml
    for ex
    <Details>
      <FirstName>
    <LastName>
    </Details>
    that in xi would be smthing like
    Details  type of data occurence
    FirstName type of data occurence
    LastName type of data occurence.
    Hope that helps.
    If it does dont forget the points..:-)

  • Problem in calling nested stored procedure

    Hi,
    I am using execute(), getMoreResults() and getResultSet() methods to call sybase stored proc. It is working fine when calling a simple stored proc. But it is giving following error when this stored proc calls another stored proc inside it.
    <<
    Error connecting: com.sybase.jdbc2.jdbc.SybSQLException: Implicit conversion from datatype 'INT' to 'CHAR' is not allowed. Use the CONVERT function to run this query
    >>
    It will be very helpful if somebody shares the experience of nested stored procs calls using JDBC.
    -Subhendu

    Vinay,
    Thanks for replying...
    Following is the excerpts from the parent procedure
    create proc TEST_PARENT_sp
    (@fundID char(5) = NULL)
    as
    begin
    exec TEST_CHILD_sp @fundID
    end
    The code for CHILD proc is attached
    create procedure TEST_CHILD_sp
    (@fundID char(5) = NULL)
    as
    begin
    insert #PV_funds_curr
    (fundID,
    curr_id,
    curr_type,
    tcurr_id,
    in_xrate_id,
    out_xrate_id,
    display_seq)
    select
    pv.fund_id,
    rl.curr_id,
    rl.curr_type,
    rl.curr_id,
    null,
    null,
    pv.display_seq
    from
    #PV_funds pv,
    RL_currencies rl,
    #PV_currencies tmp_c
    where
    @fundID in (pv.fund_id, 'ALL') and
    pv.fund_id = rl.fund_id and
    tmp_c.curr_id in (rl.curr_id, 'ALL') and
    tmp_c.curr_type in (rl.curr_type, 'ALL')
    end
    Regards,
    Subhendu.
    PS.- The Parent Stored proc works fine while calling from other applications,e.g., Rapid SQL, isql.

  • Empty strings when passing a Java object to a Stored Procedure

    Hi,
    I'm using the interface SQLData to pass Java objects to StoredProcedures. All the object's attributes 'arrive' to the Stored Procedure ok, except the strings, which are empty.
    Here is my Oracle object:
    TYPE OBJ_ASJFF_OBJ1 IS OBJECT (
    ARG1 CHAR(3),
    ARG2 NUMBER(4),
    ARG3 CHAR(4),
    ARG4 NUMBER(7),
    ARG5 NUMBER(13,2),
    ARG6 CHAR(1));
    The nested table of that object:
    TYPE TAB_ASJFF_OBJ1 AS TABLE OF OBJ_ASJFF_OBJ1;
    The procedure declaration:
    PROCEDURE Pup_Instaura_Processo (                              x_crCert IN TAB_ASJFF_OBJ1,
    x_cResult OUT CHAR(4)
    My SQLData implementation:
    public void writeSQL(SQLOutput stream) throws SQLException {
                   stream.writeString(getArg1());     
                   stream.writeInt(getArg2().intValue());
                   stream.writeString(getArg3());          
                   stream.writeLong(getArg4().longValue());     
                   stream.writeBigDecimal(getArg5());
                   stream.writeString(getArg6());
    Can anybody help me?
    Thanks in advance
    Rui Gonçalves

    not exactly what you wanted but ingredients can be found at
    - JPublisher's docuemntation (especially "Type Mapping Support Through PL/SQL Conversion Functions")
    - http://otn.oracle.com/sample_code/tech/java/jsp/Oracle9iJSPSamples.html (Best Hotels PL/SQL Sample )
    - http://otn.oracle.com/tech/xml/xdk_sample/xdksample_093001i.html
    hope this helps
    Kuassi
    I have a Java Stored procedure which takes an instance of a different java object as its parameter.
    I need to do this from a pl/sql package - can anyone point me to a sample etc (looked on the website but don't see one) ?
    Andrew

  • How to call a java method in a Stored procedure

    Hi.,
    I was trying to call a method in a stored procedure
    This was my procedure
    CREATE OR REPLACE PROCEDURE proc_copy_file(sr_file VARCHAR2,dt_file VARCHAR2)
    AS LANGUAGE JAVA
    NAME 'FileCopy.copyfile(String,String)'; // calling a java method
    /   this was my java method
    CREATE OR REPLACE AND COMPILE JAVA SOURCE NAMED "FileCopy" as
    import java.io.File;
      import java.io.IOException;
      import java.io.FileReader;
      import java.io.FileWriter;
      import javax.imageio.stream.FileImageInputStream;
      import javax.imageio.stream.FileImageOutputStream;
      import java.security.AccessControlException;
      public class FileCopy {
          // Define variable(s).
              private static int c;
              private static File file1,file2;
              private static FileReader inTextFile;
              private static FileWriter outTextFile;
              private static FileImageInputStream inImageFile;
              private static FileImageOutputStream outImageFile;
              // Define copyText() method.
              public static void copyfile(String fromFile,String toFile) throws AccessControlException
                // Create files from canonical file names.
                file1 = new File(fromFile);
                file2 = new File(toFile);
                // Copy file(s).
                try
                  // Define and initialize FileReader(s).
                  inTextFile  = new FileReader(file1);
                  outTextFile = new FileWriter(file2);
                  // Read character-by-character.
                  while ((c = inTextFile.read()) != -1) {
                    outTextFile.write(c); }
                  // Close Stream(s).
                  inTextFile.close();
                  outTextFile.close(); }
                catch (IOException e) {
                  System.out.println ("-------"); }
             // return 1;
          public static void main(String[] args){
                          switch(args.length){
                                  case 0: System.out.println("File has not mentioned.");
                                                  System.exit(0);
                                  case 1: System.out.println("Destination file has not mentioned.");
                                                  System.exit(0);
                                  case 2: copyfile(args[0],args[1]);
                                                  System.exit(0);
                                  default : System.out.println("Multiple files are not allow.");
                                                    System.exit(0);
    };while i am executing this method i m getting error as
    ORA-29531: NO METHOD COPYFILE IN CLASS FILECOPY
    ORA-06512: AT "RMVER721.PROC_COPY_FILE", LINE 1could anyone help me

    Looks like it is a matter of not quite the same namespace for String object.
    I can get it to work by the java source containing:
              public static void copyfile(java.lang.String fromFile,java.lang.String toFile) throws AccessControlExceptionAnd the PL/SQL source:
    NAME 'FileCopy.copyfile(java.lang.String,java.lang.String)'; // calling a java methodSeems like when you just use "String", then the namespace resolving in the java source is not the same as the namespace resolving in the PL/SQL?
    Addendum:
    You do not need to put java.lang.String in the java source, String will do (java.lang is by default "imported"?)
    But in the PL/SQL source java.lang namespace prefix is needed - java.lang is not "imported" here.
    Edited by: Kim Berg Hansen on Nov 23, 2011 1:07 PM

  • Nested Stored procedure

    Hi experts,
    case :- A stored procedure calling 5 stored procedure in 3rd procedure a error handled in execption
    is the 3rd procedure resume next?
    the 4 & 5 procedure will execute or not?
    Many thanks
    Kalinga

    Hi experts,
    case :- A stored procedure calling 5 stored procedure
    in 3rd procedure a error handled in execption
    is the 3rd procedure resume next?
    the 4 & 5 procedure will execute or not?
    Many thanks
    KalingaSo you have 1 procedure that calls 5 others.
    In the 3rd procudure an exception happens, which you capture within that procedure and handle it.
    Assuming the 3rd procedure exception handler is at the top level for that procedure, it will cease execution and drop back out and then the 4th and 5th procedures will continue to be executed.
    If the exception handler in the 3rd procedure is in a nested execution block then the execution will continue from after that execution block in that 3rd procedure.
    If the 3rd procedure doesn't actually handle the exception but raises the error then the exception handler of the calling procedure will capture the exception (if there is an exception handler there) and the 4th and 5th procedures will not be called.
    The key thing to remember is that once an exception happens inside an execution block the execution point cannot return back within that same execution block automatically. It can only leave that execution block gracefully by handling the exception or it can raise the exception up a level to the calling execution block's exception handler.

  • How to use stored procedures in DIAdem and Can the stored procedures be used to return values?

    Can anyone please tell me how to use stored procedures in diadem and to return values from it. Its really important, can you please answer it at the earliest.
    Thanks In advance
    spiya

    Hi Spria,
    I'm very sorry for the mix-up, I thought Allen was going to answer you back with the particulars that we found out. Check out the attached Word document and the below tidbits:
    The built-in DIAdem ODBC functions {SQL_...()} can only call stored functions, which return a scaler result {found then in SQL_Result(1,1)}. The syntax for this with an ORACLE db is
    "select function(parameters) from package"
    ...where package defaults to "dual" if you don't use your own package.
    There might be exceptions to that though, and the syntax will be different for other databases. Note that stored ORACLE procedures can NOT be called from the ODBC functions, instead you must use either ADO function calls in the DIA
    dem VBScript or the OO4O COM wrapper that ORACLE provides (this is described in further detail in the below Word document).
    Hope this helps,
    Brad Turpin
    DIAdem Product Support Engineer
    National Instruments
    Attachments:
    Calling_ORACLE_Stored_Procedures_from_DIAdem.doc ‏28 KB

  • Java Script in a Stored Procedure

    I have a stored procedure. I use HTP Pacakge to generate the Page with HTML tags.
    I need to include a Javascript file in the stored procedure . I donno the path where the JS file resides in the Appserver meaning the context root.
    Any help in educating me the location where JS ,CSS,IMAGE files are placed
    in the appserver is most welcome.
    I am using Oracle 10g DB and Oracle 10g App server.

    The App Server has an Apache-based HTTP server. It uses the standard Apache config files - you can probably look at the $ORACLE_HOME/Apache/Apache/config/httpd.conf to find the document root.
    The $ORACLE_HOME is the App Server's Home, not the database's Home

  • Triggering and Stopping a Stored Procedure

    I'm setting up a mass mailing system for approx 250,000
    users.
    I need to find a way to trigger a stored procedure to run
    every 5 miuntes untill the task is complete. The idea being that
    once triggered it'll work its merry way through the database firing
    off a couple of thousand emails each cycle untill it's reached the
    end.
    Any ideas how to implement this?
    Thanks

    Generally, the term "stored procedure" is used to mean a
    piece of SQL code that is stored and run in the database server. It
    sounds like what you mean is a ColdFusion Scheduled Task - a piece
    of CF code that is run automatically. You can set these up using
    either the CF administrator or the <cfschedule> tag. Breaking
    up your mailings is a good idea since CF will probably time out if
    you try to execute 250,000 mailings at once. You could do something
    like this:
    1) If unsent records, do:
    2) Select X number of unsent records
    3) Send mail
    4) Update X records as having been sent
    You would just have to make sure that you time it correctly,
    otherwise you could wind up with 1 process starting before the
    other finishes and some people will get duplicate emails.

  • Returning rowcount and resultset from stored procedure

    Hello,
    In SQL Server you can return multiple resultsets from stored procedure by simple SELECT statement. But in Oracle, you have to use SYS_REFCURSOR.
    Sample code:
    CREATE OR REPLACE PROCEDURE sp_resultset_test IS
    t_recordset OUT SYS_REFCURSOR
    BEGIN
    OPEN t_recordset FOR
    SELECT * FROM EMPLOYEE;
    END sp_resultset_test;
    Is there any other way in Oracle 10 or 11 ?
    Thank You.

    What is the requirement? Oracle is far more flexible than SQL-Server... with numerous features that do not exist in SQL-Server. (Fact)
    One of the biggest mistakes you can make is to treat Oracle like SQL-Server... trying to match feature A1 in SQL-Server to feature B3 in Oracle.
    Does not work that way.. rather then stick to SQL-Server as SQL-Server does SQL-Server specific features far better than Oracle.
    So instead of trying to map what a T-SQL stored proc to do to an Oracle ref cursor (even to the extent of using that very silly sp_ prefix to name the proc), tell us the problem and requirements... That way we can tell you what Oracle features and options are best used to solve that problem - instead of competing in some unknown feature comparison event with SQL-Server.

  • Calling Java programs from Oracle Stored Procedure

    Is it possible to call Java programs from Oracle stored procs? If possible Can this be used to exchange data from other applications? Is there a better method/feature in oracle for doing data exchange with other apps?

    If what you mean by Oracle stored procedures is pl/sql then yes.
    You can create a "wrapper" this way:
    CREATE OR REPLACE FUNCTION xmlXform
    in_mapUrl IN VARCHAR2,
    in_inputUrl IN VARCHAR2
    RETURN VARCHAR2
    AS
    LANGUAGE JAVA NAME
    'com.yourcompany.xml2any.xform(java.lang.String,java.lang.String)
    RETURN java.lang.String';
    Then load the java as:
    loadjava -user youruser/youruserpasswd -resolve -verbose lib/xmlparserv2.jar classes/com/yourcompany/xform.class classes/com/yourcompany/xml2any.class
    The java, given the correct permissions, can do anything java can do including communicate with outside applications.
    Is this the "best" way... depends on what you are trying to accomplish.

  • Calling Java Constructor from Oracle Stored Procedure

    Hi all,
    I have come across a situation where on insert into one Oracle database instance, a trigger will be fired which will call a procedure which in turn calls a Java constructor with 2 string arguments(The Java class is loaded into another instance of Oracle using Loadjava).
    (Note: I don't want to call a static method from the Oracle procedure)
    I have seen some examples where in using links, on insertion into a table another table of another instance can also be updated.
    for ex: "INSERT INTO testuser.sal_audit@mainlink VALUES (?, ?, ?)" where "mainlink" is a DB link between the 2 instances.
    Similarly is it possble to call the Java constructor loaded in another instance?
    I have tried in this way. It's not working.
    create or replace procedure pr_Cust_object(FeData varchar2,szDummy varchar2) as
    LANGUAGE JAVA NAME
    'CustomObject@mainLink(java.lang.String, java.lang.String)';
    end pr_Cust_object;
    Expecting help at the earliest--ASAP.
    Thanks and Regards,
    Narendra S K

    I don't know how to do that, but I would be interested in knowing how long each insert/update/delete (which ever the trigger fires on) takes.
    And the logic for rollbacks is probably really interesting.

  • Java versus PL/SQL Stored Procedure Issues

    I am getting a result that is 30 times slower for Java when compared with PLSQL. Can you tell me if that is normal or am I missing something?
    Thanks in advance for your help,
    Gaurav Pal
    Java Developer,
    SCJP 1.1, SCJP 2, SCJD 2
    Timing results
    ---------------- Java ------------------------
    Total Time taken for 10 calls: 4667
    Result: 466 Time: 466
    ---------------- PLSQL ------------------------
    Total Time taken for 10 calls: 150
    Result: 466 Time: 15
    Java Code
    public static int getCursorCount()
    int count = 0;
    //define iterator for select
    count_iter myIter = null;
    try
    #sql myIter = { SELECT lastname FROM employee };
    while(myIter.next())
    count++;
    myIter.close();
    catch(SQLException excp)
    return count;
    PL/SQL Code
    function get_count_cursor_sf
    return
    number
    is
    cursor count_cursor is
    select lastname from employee;
    v_return_count number := 0;
    v_name employee.lastname%type;
    begin
    open count_cursor;
    fetch count_cursor into v_name;
    while (count_cursor%found) loop
    fetch count_cursor into v_name;
    v_return_count := v_return_count + 1;
    end loop;
    --Return the variable
    return v_return_count;
    end ;
    Calling Code
    public class DBCall
    public static void main(String args[])
    try
    makeJavaCalls();
    makePLSQLCalls();
    catch(Exception excp)
    excp.printStackTrace();
    public static Connection getConnection() throws Exception
    Class.forName("oracle.jdbc.driver.OracleDriver");
    return DriverManager.getConnection("jdbc:oracle:thin:@10.0.0.3:1521:oracleee","rda","rdauser");
    public static void makePLSQLCalls() throws Exception
    int count = 10;
    long time = 0;
    int result = 0;
    while(count > 0)
    Connection conn = getConnection();
    CallableStatement cs = conn.prepareCall("{? = call rda_plsql_pkg.get_count_cursor_sf()}");
    cs.registerOutParameter(1, Types.INTEGER);
    long before = System.currentTimeMillis();
    cs.execute();
    result = cs.getInt(1);
    long after = System.currentTimeMillis();
    time = time + (after - before);
    cs.close();
    conn.close();
    count--;
    System.out.println("---------------- PLSQL ------------------------");
    System.out.println("Total Time taken for 10 calls: " + time);
    System.out.println("Result: " + result + " Time: " + (time/10));
    public static void makeJavaCalls() throws Exception
    int count = 10;
    long time = 0;
    int result = 0;
    while(count > 0)
    Connection conn = getConnection();
    CallableStatement cs = conn.prepareCall("{? = call dorknight.getcursorcount()}");
    cs.registerOutParameter(1, Types.INTEGER);
    long before = System.currentTimeMillis();
    cs.execute();
    result = cs.getInt(1);
    long after = System.currentTimeMillis();
    time = time + (after - before);
    cs.close();
    conn.close();
    count--;
    System.out.println("---------------- Java ------------------------");
    System.out.println("Total Time taken for 10 calls: " + time);
    System.out.println("Result: " + result + " Time: " + (time/10));
    null

    A big contributor to the behavior seen here is that there is a one-time overhead per session (= per database connection) to start the JavaVM and also (in 8.1.6 and earlier) to initialize the SQLJ runtime (via reflection).
    Keeping the same connection for subsequent calls to Java (which is the more typical scenario, anyway) will result in a rather considerable speedup.

  • How to call a AS/400 Stored Procedure with a BigDecimal Value?

    Hi,
    Could you pls tell me how to call a stored procedure on the AS/400 which request an input value of packed decimal(10P 4) value.
    I have tried to convert it to a BigDecimal in Java and call the stored procedure as follows but it gave me a decimal point error on the AS/400.
    Could you pls show me where I'm wrong in the following code.
    Thanks
    Jan
    ========Java program to call AS/400 Stored procedure with setBigDecimal()===========
    //Assign the value to String
    string sBDVal = "30"
    //Convert the String value to BigDecimal
    BigDecimal bdAmt = new BigDecimal(sBDVal);
    //Call Stored Procedure with parameters,
    CallableStatement callSP = conn.prepareCall("{call OSCUPDLENS(?,?,?)}");
    // Set in parm values
    callSP.setString(1,"Value 1");
    callSP.setBigDecimal(2,bdAmt);
    callSP.setString(3,"");
    // Register out parameter
    callSP.registerOutParameter(3, Types.CHAR);
    // Execute call to stored procedure
    callSP.execute();
    // Retrieve out parameters
    sErrFlag = callSP.getString(3).trim();
    ========================Create Stored Procedure on AS/400===========================
    c/EXEC SQL
    c+ CREATE PROCEDURE TESTSPROC
    c+ (IN VAL1 CHAR ( 8),
    c+ IN BDAMT DEC (10, 4),
    C+ INOUT ERR CHAR ( 1))
    C+ LANGUAGE RPGLE NOT
    C+ DETERMINISTIC NO SQL EXTERNAL NAME TESTSPROC PARAMETER STYLE
    C+ GENERAL
    c/END-EXEC
    ======RPG program on AS/400 to accept the BigDecimal value to a Packed decimal======
    * Initialize the i/p parameter
    DP#VAL1 S 8A
    DP#AMT S 10P 4
    DP#ERR S 1A
    C*Input parameters
    C *ENTRY        PLIST                          
    C PARM P#VAL1
    C PARM P#AMT
    C PARM P#ERR

    Could you pls show me where I'm wrong in the following codeI don't know, you're doing a lot of things I have never tried. But "decimal data error" most likely means that the stored procedure is expecting packed data and the driver is giving it zoned data, or vice versa. You could confirm that by dumping your variables inside your RPG. If that is your problem, you could work around it by redefining your BDAMT parameter as integer or string and reformatting it in the RPG.

Maybe you are looking for