| |

VerySource

 Forgot password?
 Register
Search
View: 7|Reply: 2

The use of oracle custom objects

[Copy link]

1

Threads

2

Posts

3

Credits

Newbie

Rank: 1

Credits
3

 China

Post time: 2020-3-4 08:30:01
| Show all posts |Read mode
A type of list nsrlist is defined in oracle:
create or replace type nsrlist is varray (2000) of varchar2 (20)

The stored procedure body is as follows:
create or replace package body TESTVARRAY is
procedure testSS (nsrs out nsrlist) is
   nsrarray nsrlist: = nsrlist ('a1', 'a2', 'a3');
   begin
      nsrs: = nsrarray;
   end;
begin
   null;
end TESTVARRAY;

This is called in the java code:
Connection conn = session.connection ();
CallableStatement proc = null;
try
{
   proc = conn.prepareCall ({call TESTVARRAY.testSS (?)});
   proc.registerOutParameter (1, OracleTypes.ARRAY, "NSRLIST");
   proc.execute ();
   ResultSet rs = null;
   Array simpleArray = proc.getArray (1);
   rs = simpleArray.getResultSet ();
   while (rs.next ())
   {
      System.out.println (rs.getString (2));
   }
} catch (SQLException e)
{
   e.printStackTrace ();
}

The output of the console becomes
0x6131
0x6132
0x6133

What is going on?
Reply

Use magic Report

0

Threads

66

Posts

45

Credits

Newbie

Rank: 1

Credits
45

 China

Post time: 2020-5-16 22:00:01
| Show all posts
procedure testSS (nsrs out nsrlist) is
Just the out parameter, what about the in parameter?

How is your java code in?

proc = conn.prepareCall ({call TESTVARRAY.testSS (?)});
Reply

Use magic Report

1

Threads

2

Posts

3

Credits

Newbie

Rank: 1

Credits
3

 China

 Author| Post time: 2020-6-24 19:30:01
| Show all posts
It can take no parameters. After the call, the returned result should be:
a1
a2
a3
But now the result becomes:
0x6131
0x6132
0x6133
Reply

Use magic Report

You have to log in before you can reply Login | Register

Points Rules

Contact us|Archive|Mobile|CopyRight © 2008-2020|verysource.com ( 京ICP备17048824号-1 )

Quick Reply To Top Return to the list