Thank you. Your tip gets me start.

Here is the code I tested based on the sample codes below and it works.
Just share this here.

        UniSession mSession = new UniSession(); 
        mSession.setHostName(host); 
        mSession.setUserName(userid); 
        mSession.setPassword(passwd); 
        mSession.setAccountPath(account); 
        mSession.connect();

         UniSubroutine mSub = mSession.subroutine ( "sub1", 2);

            UniDynArray returnValue=mSession.dynArray();
            mSub.setArg(0,returnValue);
            mSub.setArg(1,"05");            
            mSub.call();

            returnValue =new UniDynArray(mSub.getArg(0));           

            String val11 = returnValue.extract(1,1).toString();
            String val12 = returnValue.extract(1,2).toString(); 
            String val13 = returnValue.extract(1,3).toString();

            String val21 = returnValue.extract(2,1).toString();
            String val22 = returnValue.extract(2,2).toString();
            String val23 = returnValue.extract(2,3).toString();

            String val31 = returnValue.extract(3,1).toString();
            String val32 = returnValue.extract(3,2).toString();
            String val33 = returnValue.extract(3,3).toString();  

You could loop through the returnValue as needed, I think.

Or you could use callable statement as below, which is a little
different from usual callable statement.

CallableStatement cstmt=con.prepareCall("call kathyGetEmployees(?)");
cstmt.setString(1,"1");
rs=cstmt.executeQuery();
        
while( rs.next()) {
        for( int i=1; i<=3; i++ ) {
        System.out.println("Column["+i+"]="+rs.getString(i)) ;
         }
      }
rs.close();
con.close();

Could anybody share his/her experience on universe database client tool,
something like Oracle sql plus or PL/SQL developer? I am looking for a
tool which I could query data and view subroutines in Universe database.

Thank you, Kathy

-----Original Message-----
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of gerry-u2ug
Sent: Tuesday, October 04, 2005 1:47 AM
To: [email protected]
Subject: RE: [U2] Java calss calls a universe subroutine

Hi Kathy , 

now for the simple (useable) answer , 


        ...

        UniSubroutine mSub = mSession.subroutine ( "*SUB1", 2);

        UniDynArray returnValue=Session.CreateDynArray();
        mSub.SetArg(0,returnValue);
        mSub.SetArg(1,"05");
        mSub.Call();

        returnVal = mSub.GetArgDynArray(0);

        string val11 = returnValue.Extract(1,1).StringValue;
        string val12 = returnValue.Extract(1,2).StringValue;    
        string val13 = returnValue.Extract(1,3).StringValue;

        string val21 = returnValue.Extract(2,1).StringValue;
        string val22 = returnValue.Extract(2,2).StringValue;
        string val23 = returnValue.Extract(2,3).StringValue;

        string val31 = returnValue.Extract(3,1).StringValue;
        string val32 = returnValue.Extract(3,2).StringValue;
        string val33 = returnValue.Extract(3,3).StringValue;

        ...


The universe subroutine catalogued as *SUB1 would look like this :

        SUBROUTINE SUB1( returnValue , inputValue )
                returnValue=""

                returnValue<1,1>=11
                returnValue<1,2>=12
                returnValue<1,3>=13

                returnValue<1,1>=21
                returnValue<1,2>=22
                returnValue<1,3>=23

                returnValue<1,1>=31
                returnValue<1,2>=32
                returnValue<1,3>=33
        END     





-----Original Message-----
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] Behalf Of Vance, Kathy
Sent: Monday, October 03, 2005 10:15 PM
To: [email protected]
Subject: [U2] Java calss calls a universe subroutine


Hi list,

I need you guys help.



I am a Java programmer and new to Universe. Could anybody show me how to
call a universe subroutine which returns a list of values?



Ex. sub1 (var in)

Returns three rows:

a1,b1,c1

a2,b2,c2

a3,b3,c3



How could I loop through these three rows and get each value?



Is something like:

UniSubroutine mSub = mSession.subroutine ( "sub1", 10);
mSub.setArg( 1, "05" );
mSub.call();

Should I use UniDataSet for the ResultSet returned?

Thanks in advance.

Kathy
-------
u2-users mailing list
[email protected]
To unsubscribe please visit http://listserver.u2ug.org/
-------
u2-users mailing list
[email protected]
To unsubscribe please visit http://listserver.u2ug.org/
-------
u2-users mailing list
[email protected]
To unsubscribe please visit http://listserver.u2ug.org/

Reply via email to