我想在java中调用一个存储过程,就是一个查询而已,但不知怎么写,似乎有点麻烦,要用到游标啊。查询是这样的:
create or replace procedure query_city_by_id(p_id in number ) is
  
       
begin
   select * from system.city where cid=p_id;
end;

解决方案 »

  1.   

    这个存储过程写点有点问题编译应该不会通过的。
    http://blog.csdn.net/sparadise1003/archive/2009/01/12/3758331.aspx
      

  2.   


    这个sp,没有问题,不过没有意义。 没有out参数,在plsql block里又没有dml语句。
      

  3.   

     
    create or replace procedure query_city_by_id(p_id in number,p_cursor in out types.cursorType  ) is 
      
          
    begin 
     open p_cursor for  select * from system.city where cid=p_id; 
    end;
      

  4.   

    types.cursorType这个需要声明一下吧
      

  5.   

    在过程里直接select ...要出错的
    3楼的p_cursor in out types.cursorType  -->p_cursor out sys_refcursorsystem.city 。。怎么把表建到system用户下去了
      

  6.   

    create or replace procedure query_city_by_id(
    p_id in number ,
    p_cursor out sys_refcursor

    is begin 
      open p_cursor for
      select * from system.city where cid=p_id; 
    end;
      

  7.   

    create or replace procedure query_city_by_id(
    p_id in number ,
    p_cursor out sys_refcursor

    is begin 
      open p_cursor for
      select * from system.city where cid=p_id; 
    end;
      

  8.   

    create or replace procedure p_city_query_byid( 
    p_id in number , 
    p_cursor out sys_refcursor 

    is 
    begin 
      open p_cursor for 
      select * 
        from system.city 
       where cid=p_id; 
    end;
    或换成函数:
    create or replace function f_city_query_byid( 
    p_id in number

    return sys_refcursor 
    is 
    p_cursor  sys_refcursor; 
    begin 
      open p_cursor for 
      select * 
        from system.city 
       where cid=p_id; 
       return p_cursor;
    end;