Procedures with PL/SQL tables.

Hi,
I want to write the procedures with pl/sql tables. Can we write
if yes can you provide the example or hint. If a person helps me
i will be great thank ful.
thanks.
null

reddy (guest) wrote:
: Hi,
: I want to write the procedures with pl/sql tables. Can we write
: if yes can you provide the example or hint. If a person helps
me
: i will be great thank ful.
: thanks.
check the following faq link -- it says not supported yet ...
http://technet.oracle.com/tech/java/sqlj_jdbc/htdocs/jdbc_faq.htm
null

Similar Messages

  • Call procedure with MS SQL from linked Oracle server

    I have a procedure on a remote server that I can call from SQL*PLUS
    set serveroutput on
    declare rez varchar2(99); msg varchar2(99); begin radar.test('AL25',rez,msg); dbms_output.put_line('Rez='||rez);
    dbms_output.put_line('Msg='||msg);
    end;
    it gives me the neccessary result.
    But I need to call the same procedure with MS SQL from a linked Oracle server, I'm trying to do it through openquery for a while, but no success yet.
    Can someone tell me what is the right syntax for that query in OPENQUERY?

    Have you tried configuring Oracle Heterogenous Services/ Transparent Gateway? This would let you link Oracle to SQL Server via a database link which should solve your problem.
    Justin
    Distributed Database Consulting, Inc.
    www.ddbcinc.com

  • Using extend option with PL/SQL table of tables

    Hi,
    I have a PL/SQL table of tables sructure on which I want to use extend option available with PL/SQL tables.
    But I am not able to do so. Could anyone help?
    Below is sample code given.
    Type RA_TABLE is table of CALL_DETAIL_EXCEPTION.IC_CIRCT_GR_CD%TYPE;
    TYPE tab_of_RA_TABLE IS TABLE OF RA_TABLE;
    for idx in 1..cnt_interval Loop
    query1:='select Trunk_info from dbl.vw_cgi v where not exists (select 1 from dbl.varun f
    where f.ic_circt_gr_cd= v.TRUNK_INFO and f.call_gmt_dnect_dt_time between
    to_date('''||stime||''',''yyyymmddhh24miss'') and to_date('''||etime||''',''yyyymmddhh24miss''))';
    execute immediate query1 bulk collect into Outer_table(idx);
    ra_cnt_1:= Outer_table(idx).count;
    diff:= max_cnt-RA_CNT_1;
    dbms_output.put_line('idx: '||idx);
    dbms_output.put_line('diff: '||diff);
    if diff>=1 then
    Outer_table(idx).extend( Diff);
    end if;
    end loop;
    The extend doesnt work.
    Please help!!

    Hi,
    I have a PL/SQL table of tables sructure on which I want to use extend option available with PL/SQL tables.
    But I am not able to do so. Could anyone help?
    Below is sample code given.
    Type RA_TABLE is table of CALL_DETAIL_EXCEPTION.IC_CIRCT_GR_CD%TYPE;
    TYPE tab_of_RA_TABLE IS TABLE OF RA_TABLE;
    for idx in 1..cnt_interval Loop
    query1:='select Trunk_info from dbl.vw_cgi v where not exists (select 1 from dbl.varun f
    where f.ic_circt_gr_cd= v.TRUNK_INFO and f.call_gmt_dnect_dt_time between
    to_date('''||stime||''',''yyyymmddhh24miss'') and to_date('''||etime||''',''yyyymmddhh24miss''))';
    execute immediate query1 bulk collect into Outer_table(idx);
    ra_cnt_1:= Outer_table(idx).count;
    diff:= max_cnt-RA_CNT_1;
    dbms_output.put_line('idx: '||idx);
    dbms_output.put_line('diff: '||diff);
    if diff>=1 then
    Outer_table(idx).extend( Diff);
    end if;
    end loop;
    The extend doesnt work.
    Please help!!

  • Writing to a temp table in a stored procedure with dynamic sql

    Hi
    I am writing into a temp table with dynamic sql:
    select coloum_name into #temp_table from
    +
    @DestinationDBName+'.information_schema.tables
    and then I am trying to use #temp_table in the procedure:
    select coloum_name into #anotherTable from #temp_table
    but I am getting an error that #temp_table is not recognized.
    Can a temp table not be used in dynamic sql ?
    How can I overcome this problem ?

    Temp Table Can used easily in Dynamic Query in SQL Server and here is small Exmaple you can check it and do like it 
    CREATE PROC test
    AS
    BEGIN
    CREATE TABLE #T1 
    (ID  int , NAME Nvarchar(50))
    CREATE TABLE #T2 
    (ID  int , NAME Nvarchar(50))
    DECLARE @SQL NVARCHAR(MAX)='Insert into #T1 
    SELECT database_id , Name FROM Sys.Databases
    Insert into #T2 Select ID , Name from  #T1 '
    EXEC SP_ExecuteSQL @SQL
    SELECT * FROM #T2
    DROP TABLE #T1
    DROP TABLE #T2
    END
    Exec Test
    If you found My reply is helpful for you please vote me 
    thanks
    Mustafa EL-Masry
    Principle Database Administrator & DB Analyst
    SQL Server MCTS-MCITP
    M| +966 54 399 0968
    MostafaElmasry.Wordpress.Com

  • Can anyone help me in a problem with PL/SQL Tables & the Java getArray()

    The problem is the following:
    I would tike to get a PL/SQL Table (a table of varchar2) into a Java String Array.
    It works very well except that instead of getting the characters in the PL/SQL Table
    I receive the character codes in each string.
    In the following example i should get:
    spring
    summer
    outumn
    winter
    Instead I get:
    0x737072696E67
    0x73756D6D6572
    0x6F7574756D6E
    0x77696E746572
    Steps to try the sample
    1)Creating the following type
    create or replace TYPE CHAR_ARRAY IS TABLE OF VARCHAR(32767);
    2)Creating the following stored procedure
    create or replace PROCEDURE MQ_MSG_PROCESSOR
       MessageText in VARCHAR2,
       QueueName out VARCHAR2,
       RplyMessage out CHAR_ARRAY,
       HastoCommit out NUMBER
    AS
       RMessage CHAR_ARRAY;
    BEGIN
       QueueName:='DEV_OUT';
       RMessage:=CHAR_ARRAY();
       RMessage.Extend(4);
       RMessage(1):='spring';
       RMessage(2):='summer';
       RMessage(3):='outumn';
       RMessage(4):='winter';
       HastoCommit:=1;
       RplyMessage:=RMessage;
    END;
    3)Copiling and running the following java class
    import java.sql.*;
    import oracle.sql.*;
    import oracle.jdbc.oracore.Util;
    import oracle.jdbc.driver.*;
    import java.util.Dictionary;
    public class ArrayExample
       public static void main (String args[]) throws Exception
          MSG Msg=null;
          oracle.sql.ARRAY RMsg=null;
          DriverManager.registerDriver(new oracle.jdbc.driver.OracleDriver());
          Connection conn = DriverManager.getConnection ("jdbc:oracle:oci8:@test","test", "test");
          conn.setAutoCommit (false);
          try
             String []array={};
             ArrayDescriptor desc=ArrayDescriptor.createDescriptor("CHAR_ARRAY",conn);
             ARRAY CHAR_ARRAY=new ARRAY(desc,conn,array);
             OracleCallableStatement sproc = (OracleCallableStatement)conn.prepareCall("{call GSM.MQ_TST.MQ_MSG_PROCESSOR(?, ?, ?, ?)}");
             sproc.setString(1, "hello"); //MessageText
             sproc.registerOutParameter(2, OracleTypes.VARCHAR);   //QueueName
             sproc.registerOutParameter(3, OracleTypes.ARRAY,"CHAR_ARRAY");   //RplyMessage
             sproc.registerOutParameter(4, OracleTypes.NUMBER);      //HastoCommit
             sproc.execute();
             CHAR_ARRAY=(oracle.sql.ARRAY)sproc.getARRAY(3);
             array = (String [])CHAR_ARRAY.getArray();
             for(int i=0;i<array.length;i++)
                System.out.println(array);
          catch(SQLException e)
             System.out.println("Error while trying to execute MQ_MSG_PROCESSOR");
             System.out.println(e);
          conn.close();

    Hi,
    I tried the code with same procedure.
    That works out fine for me..
    and it prints out exactly the same words as you mentioned..:))
    may be you must have changed something later on.. which started printing character codes..
    but for me it works perfectly fine..
    All The Best..
    Regards
    Gurudatt
    The problem is the following:
    I would tike to get a PL/SQL Table (a table of
    varchar2) into a Java String Array.
    It works very well except that instead of getting the
    characters in the PL/SQL Table
    I receive the character codes in each string.
    In the following example i should get:
    spring
    summer
    outumn
    winter
    Instead I get:
    0x737072696E67
    0x73756D6D6572
    0x6F7574756D6E
    0x77696E746572
    Steps to try the sample
    1)Creating the following type
    create or replace TYPE CHAR_ARRAY IS TABLE OF
    VARCHAR(32767);
    2)Creating the following stored procedure
    create or replace PROCEDURE MQ_MSG_PROCESSOR
    ���MessageText in VARCHAR2,
    ���QueueName out VARCHAR2,
    ���RplyMessage out CHAR_ARRAY,
    ���HastoCommit out NUMBER
    AS
    ���RMessage CHAR_ARRAY;
    BEGIN
    ���QueueName:='DEV_OUT';
    ���RMessage:=CHAR_ARRAY();
    ���RMessage.Extend(4);
    ���RMessage(1):='spring';
    ���RMessage(2):='summer';
    ���RMessage(3):='outumn';
    ���RMessage(4):='winter';
    ���HastoCommit:=1;
    ���RplyMessage:=RMessage;
    END;
    3)Copiling and running the following java class
    import java.sql.*;
    import oracle.sql.*;
    import oracle.jdbc.oracore.Util;
    import oracle.jdbc.driver.*;
    import java.util.Dictionary;
    public class ArrayExample
    ���public static void main (String
    args[]) throws Exception
    ���{
    ������MSG Msg=null;
    ������oracle.sql.ARRAY
    RMsg=null;
    ������DriverManager.regis
    erDriver(new oracle.jdbc.driver.OracleDriver());
    ������Connection conn =
    DriverManager.getConnection
    ("jdbc:oracle:oci8:@test","test", "test");
    ������conn.setAutoCommit
    (false);
    ������try
    ������{
    ���������S
    ring []array={};
    ���������A
    rayDescriptor
    desc=ArrayDescriptor.createDescriptor("CHAR_ARRAY",conn
    ���������A
    RAY CHAR_ARRAY=new ARRAY(desc,conn,array);
    ���������O
    acleCallableStatement sproc =
    (OracleCallableStatement)conn.prepareCall("{call
    GSM.MQ_TST.MQ_MSG_PROCESSOR(?, ?, ?, ?)}");
    ���������s
    roc.setString(1, "hello"); //MessageText
    ���������s
    roc.registerOutParameter(2,
    OracleTypes.VARCHAR);���//QueueName
    ���������s
    roc.registerOutParameter(3,
    OracleTypes.ARRAY,"CHAR_ARRAY");���//Rpl
    Message
    ���������s
    roc.registerOutParameter(4,
    OracleTypes.NUMBER);������
    //HastoCommit
    ���������s
    roc.execute();
    ���������C
    AR_ARRAY=(oracle.sql.ARRAY)sproc.getARRAY(3);
    ���������a
    ray = (String [])CHAR_ARRAY.getArray();
    ���������f
    r(int i=0;i<array.length;i++)
    ���������{
    System.out.println(array);
    ���������}
    ������}
    ������catch(SQLException
    e)
    ������{
    ���������S
    stem.out.println("Error while trying to execute
    MQ_MSG_PROCESSOR");
    ���������S
    stem.out.println(e);
    ������}
    ������conn.close();
    ���}

  • Problem with pl/sql table data type

    hai friends,
    i have one procedure it has some in parameters and one out parameter which fetches values to front end.
    But the out parameter will be pl/sql table data type.
    if it is ref cursor
    then i declared as
    var x refcursor;
    exec procedure_name(1,:x);
    it is ok.
    but for pl/sql table data type is out parameter then what i will do in the prompt .
    give me syntax and clarify my doubt.
    advanced thanks...
    madhava

    The SQL*Plus VARIABLE statement does not support user-defined types, hence it cannot support nested tables. It can support cursors because they can be weakly typed (so we can use the one SQL*Plus VAR to hold any shape of resultset). Nested tables are strongly typed; SQL*Plus is a relatively stupid interface and cannot be expected to understand UDT.
    So, it you want to use nested tables as output you'll need to code a wrapping procedure that can understand your nested table type and handle it accordingly.
    Sorry.
    Cheers, APC

  • Need help with pl/sql tables

    i am trying but iam not understanding this....
    Evaluate this program fragment:
    DECLARE
    TYPE user_tab_rec IS RECORD (
    db_user dba_users.username%TYPE,
    DBA_TAB dba_tables%ROWTYPE);
    TYPE user_rec_tab IS TABLE OF test_rec
    INDEX BY BINARY_INTEGER;
    Tab_rec dba_tables%ROWTYPE;
    Obj_owner dba_objects.owner%TYPE;
    begin
    (processing)
    end;
    What line will generate an error?
    1.
    TYPE user_tab_rec IS RECORD (
    2.
    db_user dba_users.username%TYPE,
    3.
    DBA_TAB dba_tables%ROWTYPE);
    4.
    TYPE user_rec_tab IS TABLE OF test_rec
    5.
    INDEX BY BINARY_INTEGER;
    6.
    Tab_rec dba_tables%ROWTYPE;
    7.
    Obj_owner dba_objects.owner%TYPE;
    The correct answer is b. The line in b attempts to define a PL/SQL TABLE TYPE using a record that contains a composite datatype, which is not allowed. Answers a, c, and d are incorrect because they will not generate any errors when compiled.
    how can line b attempt to define a pl/sql table type..........
    thank u ramsy

    The correct answer is bB? I see no B.
    Do you mean three?
    But then again
    maybe line ten.
    Because (processing) isn't
    valid syntax you see.
    I know, I know
    Let's see what'll go.
    And then we'll see
    Is it A B or C?
    SQL> r
      1  DECLARE
      2  TYPE user_tab_rec IS RECORD (
      3  db_user dba_users.username%TYPE,
      4  DBA_TAB dba_tables%ROWTYPE);
      5  TYPE user_rec_tab IS TABLE OF test_rec
      6  INDEX BY BINARY_INTEGER;
      7  Tab_rec dba_tables%ROWTYPE;
      8  Obj_owner dba_objects.owner%TYPE;
      9  begin
    10  null;
    11* end;
    TYPE user_rec_tab IS TABLE OF test_rec
    ERROR at line 5:
    ORA-06550: line 5, column 31:
    PLS-00201: identifier 'TEST_REC' must be declared
    ORA-06550: line 5, column 1:
    PL/SQL: Item ignored
    SQL> create type TEST_REC as object(a number);
      2  /
    Type created.
    SQL> DECLARE
      2  TYPE user_tab_rec IS RECORD (
      3  db_user dba_users.username%TYPE,
      4  DBA_TAB dba_tables%ROWTYPE);
      5  TYPE user_rec_tab IS TABLE OF test_rec
      6  INDEX BY BINARY_INTEGER;
      7  Tab_rec dba_tables%ROWTYPE;
      8  Obj_owner dba_objects.owner%TYPE;
      9  begin
    10  null;
    11  end;
    12  /
    PL/SQL procedure successfully completed.
    SQL> Hmmm........................
    Cheers, APC

  • Can I call stored procedure with PL/SQL?

    Oracle newbie question, it is.
    Assume a very simple stored procedure like this:
    Create or replace procedure aa (
    inPar IN number, outPar OUT number)
    IS
    rrr Number;
    Begin
    Blah, blah, blah...
    rrr := inPar + 100;
    Blah, blah, blah...
    outPar := rrr;
    End;
    So the questions are
    1) How do I call the above stored proc and pass input parameter values dynamically?
    2) How can I retreieve the results of outPar?
    I did some research and I learn I can use a programming interface such as Visual Basic or Java. Is that the only way available? I know a small bit about SQL*Plus. f I've tried to enter some PL/SQL commands under SQL*PLUS but I'm stuck. I must have missed something..please.
    In MS SQL Server environment I know what I can do. If I want to do the same thing, I just:
    Create proc aa ( @inParam int, @outParam int OUTPUT )
    as
    blah, blah, blah
    Set @outParam = @inParam + 1000
    return 1
    GO
    Enter the following statements (via query analyzer) to call the SQL Server Stored procedure and get the result:
    Declare @outX int
    Declare @returnX int
    exec @returnX = aa 100, @outX OUTPUT
    print str(@outX)
    print str(@returnX)
    Go

    maybe this example might be of some help:
    SQL> set linesize 120
    SQL> set pagesize 40
    SQL> select * from emp;
         EMPNO ENAME      JOB              MGR HIREDATE         SAL       COMM     DEPTNO
          7566 JONES      MANAGER         7839 02-APR-81       2975       1000         20
          7902 FORD       ANALYST         7566 03-DEC-81       3000                    20
          7839 KING       PRESIDENT            17-NOV-81       5000                    10
          7698 BLAKE      MANAGER         7839 01-MAY-81       2850                    30
          7782 CLARK      MANAGER         7839 09-JUN-81       2450                    10
          7369 SMITH      CLERK           7902 17-DEC-80        800                    20
          7499 ALLEN      SALESMAN        7698 20-FEB-81       1600        300         30
          7521 WARD       SALESMAN        7698 22-FEB-81       1250        500         30
          7654 MARTIN     SALESMAN        7698 28-SEP-81       1250       1400         30
          7788 SCOTT      ANALYST         7566 09-DEC-82       3000                    20
          7844 TURNER     SALESMAN        7698 08-SEP-81       1500          0         30
          7876 ADAMS      CLERK           7788 12-JAN-83       1100                    20
          7900 JAMES      CLERK           7698 03-DEC-81        950                    30
          7934 MILLER     CLERK           7782 23-JAN-82       1300                    10
    14 rows selected.
    SQL> create or replace procedure proc_get_emp_name(pEmpno in number,
      2                                                pEmpName out varchar2) as
      3  begin
      4    select ename
      5      into pEmpName
      6      from emp
      7     where empno = pEmpno;
      8  end;
      9  /
    Procedure created.
    SQL> declare
      2    vEname     emp.ename%type;
      3  begin
      4    for i in (select empno from emp) loop
      5      proc_get_emp_name(i.empno,vEname);
      6      dbms_output.put_line(vEname);
      7    end loop;
      8  end;
      9  /
    SMITH
    ALLEN
    WARD
    JONES
    MARTIN
    BLAKE
    CLARK
    SCOTT
    KING
    TURNER
    ADAMS
    JAMES
    FORD
    MILLER
    PL/SQL procedure successfully completed.
    SQL>

  • Problem with a procedure with a type table varchar2

    Hey,
    I can't seem to call my function with a custom type:
    The function:
    FUNCTION f_get_urls(v_table IN t_table)
    RETURN VARCHAR2
    IS
    v_urls VARCHAR2(600);
    BEGIN
    FOR i IN 1..v_table.count LOOP
    v_urls := CONCAT(v_urls,v_table(i));
    END LOOP;
    RETURN v_urls;
    END f_get_urls;
    t_table is declared in the package header:
    TYPE t_table is table of VARCHAR2(100) index by binary_integer;
    All goes well if i call the fucntion from within the package, but when i call it from an other package I get the next error:
    Error(12,11): PLS-00306: wrong number or types of arguments in call to 'F_GET_URLS'
    This is the procedure where i'm caling the fucntion:
    PROCEDURE temp1
    IS
    TYPE t_table is table of VARCHAR2(100) index by binary_integer;
    v_tab t_table;
    v_temp VARCHAR2(100);
    BEGIN
    v_tab(1):='test';
    v_tab(2):='test2';
    v_temp:=pkg_print.f_get_urls(v_tab);
    dbms_output.PUT_LINE(v_temp);
    END temp1;
    Any idea if i made an error or is this just not possible?
    Thanks

    Hey,
    I can't seem to call my function with a custom type:
    The function:
    FUNCTION f_get_urls(v_table IN t_table)
    RETURN VARCHAR2
    v_urls VARCHAR2(600);
    GIN
    FOR i IN 1..v_table.count LOOP
    v_urls := CONCAT(v_urls,v_table(i));
    D LOOP;
    RETURN v_urls;
    END f_get_urls;
    t_table is declared in the package header:
    TYPE t_table is table of VARCHAR2(100) index by
    binary_integer;
    All goes well if i call the fucntion from within the
    package, but when i call it from an other package I
    get the next error:
    Error(12,11): PLS-00306: wrong number or types of
    arguments in call to 'F_GET_URLS'
    This is the procedure where i'm caling the fucntion:
    PROCEDURE temp1
    IS
    TYPE t_table is table of VARCHAR2(100) index by---Dont declare new collection
    binary_integer;
    > v_tab Yourpackagename.collectionname;
    v_temp VARCHAR2(100);
    EGIN
    v_tab(1):='test';
    v_tab(2):='test2';
    v_temp:=pkg_print.f_get_urls(v_tab);
    dbms_output.PUT_LINE(v_temp);
    END temp1;
    Any idea if i made an error or is this just not
    possible?
    ThanksTry it
    PROCEDURE temp1
    IS
    -- TYPE t_table is table of VARCHAR2(100) index by---Dont declare new collection
    -- binary_integer;
    v_tab Yourpackagename.collectionname;
    v_temp VARCHAR2(100);
    BEGIN
    v_tab(1):='test';
    v_tab(2):='test2';
    v_temp:=pkg_print.f_get_urls(v_tab);
    dbms_output.PUT_LINE(v_temp);
    END temp1;
    colection types are not compatible even you created 2 diffrent types with the exact defination.
    Please paste yours full code here....
    Khurram
    Whats that
    v_temp:=pkg_print.f_get_urls(v_tab);
    Message was edited by:
    Khurram Siddiqui

  • SSRS - Stored procedure with Dynamic SQL Query

    Am calling stored procedure in SSRS report.  I have used Dynamic SQL query in stored procedure as I don't know the column name and column count.  And I have used like below at end of the stored procedure "select * from ##temptable".
    As I have used dynamic column, am not able to create report with this stored procedure.  Can someone help me out to resolve this issue.
    It will be highly appreciated if I get help. 
    Thanks

    I have tried everything.  But nothing has worked out. 
    If I get solution for below issue, it would be highly appreciated.
    "An error occurred during local report processing.
    The definition of the repport 'Main Report' is invalid.
    The report defintion is not valid.  Details: The report definition has an invalid target namespace 'http://schemas.microsoft.com/sqlserver/reporting/2010/01/reportdefinition' which cannot be upgraded.
    Thanks
    Hello,
    I would suggest you post the complete error message to us for further investigation, if you preview the report before you deploy you may get a more detailed error that will help diagnose the source of the problem.
    This issue is more related to SQL Server Reporting Services, it's more appropriate to discuss it in the forum below:
    https://social.technet.microsoft.com/Forums/sqlserver/en-US/home?forum=sqlreportingservices
    Don't forget to elaborate your issue with more detail.
    For the manual column, it might be the calculated field in SSRS. Here is the article for your reference, please see:
    http://technet.microsoft.com/en-us/library/dd239322(v=sql.110).aspx
    Regards,
    Elvis Long
    TechNet Community Support

  • Error 03113 while executing java procedure with pl.sql

    Hi All,
    I am using oracle 10g on linux server. Client machine is on xp. I hava a java procedure which executes the sqlldr on server. Earlier it was working fine, but after reinstalling the oracle 10g on server. It started giving "end of Communication channel error". I am not aware that what paramete has to set. Can some body put light on this error.
    Bye
    Sachin

    According to the documentation:
    ORA-01555: snapshot too old: rollback segment number string with name "string" too small
    Cause: Rollback records needed by a reader for consistent read are overwritten by other writers.
    Action: If in Automatic Undo Management mode, increase the setting of UNDO_RETENTION. Otherwise, use larger rollback segments.
    Error: ORA-01555: snapshot too old (rollback segment too small)
    Cause: This error can be caused by one of the problems, as described below.
    Action: The options to resolve this Oracle error are:
    This error can be the result of there being insufficient rollback segments.
    A query may not be able to create the snapshot because the rollback data is not available. This can happen when there are many transactions that are modifying data, and performing commits and rollbacks. Rollback data is overwritten when the rollback segments are too small for the size and number of changes that are being performed.
    To correct this problem, make more larger rollback segments available. Your rollback data for completed transactions will be kept longer.
    This error can be the result of programs not closing cursors after repeated FETCH and UPDATE statements.
    To correct this problem, make sure that you are closing cursors when you no longer require them.
    This error can occur if a FETCH is executed after a COMMIT is issued.
    The number of rollback records created since the last CLOSE of your cursor will fill the rollback segments and you will begin overwriting earlier records.

  • How to pass values and see outout of PL/SQL Tables, SYS_REFCURSORs?

    I am new to SQL Developer (Version 3.0.02).
    Our QC division wants to test stored procedures using SQL Developer.
    I tried to test procedures with PL/SQL tables and SYS_REFCURSORS as input and output parameters.
    When we run it by pressing the green arrow we get the Run PL/SQL window.
    How can we:
    - Put values to SYS_REFCURSOR and PL/SQL table type input parameters?
    - How can we display SYS_REFCURSOR and PL/SQL table type output parameters?
    All this time we were using SQL*Navigator. In Navigator the PL Tables and SYS_REFCURSORs outputs are shown in a nice grid.
    Here, in SQL Developer, do we have to WRITE our own code to input and display these types of parameters????

    Hi Channa,
    Yes in SQL Developer 3.0 you will have to write your own code to test out ref cursors.
    I had created test harness scripts for all my procedures having ref cursors as parameters.
    And I had to dbms_output all the values on the screen.
    Probably a limitation of the SQL Developer 3.0 tool.
    In case you come across different solution to this do let me know also.
    Thanks,
    Viju
    blog: http://whizdba.wordpress.com

  • How to invoke PL/SQL Table parameter in the query string?

    Hello,
    I've met a problem invoking PL/SQL Table parameter in the query string, in OWS 3.0.
    What I'm going to do is, to invoke a stored procedure to generate a web page using PL/SQL Web Toolkit 2.0, like: "http://.../owa/test_proc".
    But there is a IN parameter for this procedure, and it's a PL/SQL Table variable. So I can't invoke the procedure sucessfully just using "http://.../owa/test_proc?v_plsql=i_plsql".
    Did someone have met this kind of problem or have the answer to it? Thanks so much for your help.

    When using procedures with pl/sql-tables as parameter they should be overloaded, e.g.:
    procedure my_procedure (my_var in varchar2)...
    and
    procedure my_procedure (my_var in owa_util.ident_arr)
    the procedure then can be called with:
    http://..../my_procedure?my_var=Scott, which invokes the version with the varchar2 parameter, or
    http://..../my_procedure?my_var=Scott&my_var=Miller......
    which invokes the version with the pl/sql-Table
    Another solution might be the use of flexible parameters, passing pairs of parameter_name, parameter_value to your procedure. Your procedure looks like:
    procedure my_procedure (name_array IN owa.vc_arr, value_array IN owa.vc_arr)..
    and is invoked (note the ! )
    http://..../!my_procedure?ename=Scott&sal=200&job=clerk.....
    looping through the pl/sql tables will retrieve values of ename, sal and job for name_array and Scott, 200 and clerk for value_array
    Hth
    null

  • Joining java array with SQL table in a stored procedure

    Hey,
    I am calling a pl/sql stored procedure from a java program passing two arrays (employees) and (departments) as parameters to the procedure. Within the procedure I have stored the arrays in a table of records like this:
    type t_emp_type is record (employee_id number, department_id number);
    type t_emp_tbl_type is table of t_emp_type index by binary_integer;
    Where all elements in employees are stored in the employee_id column and departments are stored in the department_id column. So basically I've got a table like:
    l_employee_tbl t_emp_tbl_type;
    Looped through the arrays and stored the data like:
    for i in 1..p_employees.count loop
    l_employee_tbl(i).employee_id := p_employees(i);
    l_employee_tbl(i).deparment_id := p_departments(i);
    end loop;
    Now I would like to compare my l_employee_tbl with a SQL table in the database. Basically I would like to join my l_employee_tbl table with a SQL table named departments on department_id, returning all department_id:s that was not found in table departments.
    However, it is not possible to select from a user-defined table type. I have also tried to use the table() function and to cast l_employee_tbl, but found out it can't be done with records. And I would really like to use records or some other type where define my PL/SQL data. I know that you should not mix PL/SQL and SQL but in this case I think it is more efficient to try joining these "tables". Does anyone have a solution for this or advice to try something else out? It would be most appreciated.
    Edited by: 963281 on 2012-okt-04 14:25
    Edited by: 963281 on 2012-okt-05 01:53

    963281 wrote:
    I am calling a pl/sql stored procedure from a java program passing two arrays (p_employees) and (p_departments) as parameters to the procedure. Within the procedure I have stored the arrays in a table of records like this:
    type t_emp_type is record (employee_id number, department_id number);
    type t_emp_tbl_type is table of t_emp_type index by binary_integer;Why do you create an associative array?
    Now I would like to compare my l_employee_tbl with a SQL table in the database. Basically I would like to join my l_employee_tbl table with a SQL table named departments on department_id, returning all department_id:s that was not found in table departments. Of course, not possible as the SQL engine does not support PL/SQL user defined types. PL/SQL however support user defined SQL types. Which makes SQL defined types a lot more flexible.
    However, it is not possible to select from a user-defined table type. I have also tried to use the table() function and to cast l_employee_tbl, but found out it can't be done with records. Never mind SQL and PL/SQL - as a generic programming data structure principle. How do you expect being able to cast an associative array (name-value pairs) to a standard array? The two data structures are very different. So I'm puzzled in how you expect to move a non-scalar name-value pair data structure into a non-scalar value only data structure?
    And I would really like to use records or some other type where define my PL/SQL data. Why exactly? If the Java or PL/SQL data structure is populated using SQL data and database data, and wanting to use that data structure in SQL, what is the point? Why pull SQL data into a client data structure at all then - surely it is far more performant and scalable to rather keep that data in the database, and do the joins/selects/filters/etc using SQL?
    There is also the issue of scalability of local data structures in PL/SQL. The PL/SQL engine runs inside an Oracle server process, consuming private process memory on the server. The bigger the data structures used in PL/SQL, the more server memory needs to be allocated to that server process. This does not scale. Especially not if 10 or more such server processes are running the same PL/SQL code and each server needs to grab large chunks of server memory.
    If the data from Java comes from another source (e.g. keyboard, etc), and you need a means of storing this data server-side for use by PL/SQL and SQL. There are 2 basic choices. PL/SQL arrays for smallish amounts of data - and basing these arrays preferable on SQL data types allowing the array to be used by both SQL and PL/SQL engines. If the amount of data is not smallish, then it should be stored in the SQL engine (database) as that is designed for that exact purpose. And if the data is transient, then a GTT (global temp table) structure can be used (and indexed for optimal access).

  • PL/SQL TABLE AS OUT ON PROCEDURE CALL AND JDBCTHIN(NEED HELP

    How can I pass pl/sql record in and out
    and pl/sql tables in out thru a pl/sql procedure using jdbc with
    the zip file of 816classes12.zip...
    I have tried everything I know...
    I know the procedure is working, others are using it with in
    Oracle...
    I need to use the information it generates.
    here is what I have so far...
    try
    Class.forName ("oracle.jdbc.driver.OracleDriver");
    DriverManager.registerDriver (new
    oracle.jdbc.driver.OracleDriver());
    oracle.jdbc.driver.OracleConnection conn =
    (oracle.jdbc.driver.OracleConnection)
    DriverManager.getConnection ("jdbc:oracle:thin:@--","NA","NA");
    // SQL92 SyntaxCallableStatement
    oracle.jdbc.driver.OracleCallableStatement cstmt =
    (oracle.jdbc.driver.OracleCallableStatement)conn.prepareCall
    ("{call cbmd_proposal_PKG.DefaultTerms (?,?,?,?)}" ) ;
    cstmt.setString(1,"5118");
    cstmt.setString(2,"3");
    cstmt.registerOutParameter
    (2,oracle.jdbc.driver.OracleTypes.NUMBER);
    cstmt.registerOutParameter
    (1,oracle.jdbc.driver.OracleTypes.ARRAY,"");
    cstmt.execute();
    catch(Exception e)
    System.err.println(e.toString());
    e.printStackTrace();
    null

    The "X" in the second registerOutParameter is the type name which
    you have created in oracle DB.
    eg. if you have created a nested table
    create Type integer_table is table of number(10);
    then "X" = "INTEGER_TABLE" and it has to be in caps
    and other thing to keep in mind is that it only works with nested
    table or varray and not with pl/sql table.
    Al Pivonka (guest) wrote:
    : How can I pass pl/sql record in and out
    : and pl/sql tables in out thru a pl/sql procedure using jdbc
    with
    : the zip file of 816classes12.zip...
    : I have tried everything I know...
    : I know the procedure is working, others are using it with in
    : Oracle...
    : I need to use the information it generates.
    : here is what I have so far...
    : try
    : Class.forName ("oracle.jdbc.driver.OracleDriver");
    : DriverManager.registerDriver (new
    : oracle.jdbc.driver.OracleDriver());
    : oracle.jdbc.driver.OracleConnection conn =
    : (oracle.jdbc.driver.OracleConnection
    : DriverManager.getConnection
    ("jdbc:oracle:thin:@--","NA","NA");
    : // SQL92 SyntaxCallableStatement
    : oracle.jdbc.driver.OracleCallableStatement cstmt =
    : (oracle.jdbc.driver.OracleCallableStatement)conn.prepareCall
    : ("{call cbmd_proposal_PKG.DefaultTerms (?,?,?,?)}" ) ;
    : cstmt.setString(1,"5118");
    : cstmt.setString(2,"3");
    : cstmt.registerOutParameter
    : (2,oracle.jdbc.driver.OracleTypes.NUMBER);
    : cstmt.registerOutParameter
    (1,oracle.jdbc.driver.OracleTypes.ARRAY,"X");
    : cstmt.execute();
    : catch(Exception e)
    : System.err.println(e.toString());
    : e.printStackTrace();
    : The "X" in the second registerOutParameter is still unknown to
    : me.
    : The JavaDoc for the
    OracleCallableStatement.registerOutParameter
    : is not clear.
    : Can any One help simplify this...
    : Thanks
    null

Maybe you are looking for

  • Planning file entry for MRP Area

    Hi, To create planning file entry in the background at plant level we use Transaction MDAB. I would like to know that if MRP area is active than whats the T-code for planning file entry in the background at mrp area level?? To create manualy in the T

  • Acrobat Fillable Form -Reader Enable Not Working Correctly

    I have a form that has been used and modified a number of times that is accessed from an intranet.  I am trying to make it Reader enabled, (All user have Reader X installed).  I enabled, and infact if I try to Enable Usage Rights I get the error dial

  • Connect Adobe form to WEB Services

    Hi Experts , Can you please help me i need to Connect Adobe form to WEB Services . what Function Module DO i need to use to Convert or to create ADOBE Forms. once after Createing i need to connect to web service through SAP> Regd's Raj

  • NAC guest server and pre-configured duration of accounts

    There seems to be a bug in the way the NAC guest server handles the pre-configured duration of guest accounts. I have followed the manual and I did: - Configured 3 durations (24h, 48h and 1 week) under the templates/accounts/accounts durations. - And

  • Restrict Transaction types in menu

    Hi All, In CRMD_ORDER transaction, when i select option "Create" from the menu 'Business transaction', it gives me a BIG list of all the standard and custom transaction types for selection. Is it possible to restrict this list to limited custom trans