Fetch into object type

Oracle 10.2.0.5.0
Using Pl/SQL Developer
Hi I'm new to collections, object types etc, so I aologize for any poor wording and missed concepts...
I need to output a ref cursor from my package (for a summary report in SQL Server Reporting Services 2005). The summary report has two fields that come from the database table and 5 calculated fields. My idea for creating the ref cursor is as follows:
1. Define an object type at the schema level
2. Define a table (collection) type at the schema level
3. Define a ref cursor at the package level
4. Using dynamic SQL create a sql statement creating virtual columns for the 5 calculated fields
5. Fetch cursor with dynamic sql into object type one record at a time
6. Calculate the other five field values and update the object for each record processed
7. Add the object 'record' to the table (collection) after each record is processed
8. After the fetch is complete, convert the table to a ref cursor for returning to my application
Here is what I have so far. I have cut out several of the calculated fields for simplicities sake. It is not complete and I don't know how to fetch the database row into the object, nor convert the collection to a ref cursor.
Any help would be greatly appreciated.
create or replace type dlyout.srvCtr_sum_rec_type as object (
                           zoneNo number,
                           zonetx varchar2(15),
                           distNo varchar2(4),
                           distTx varchar2(30),
                           numOccr number,
                           MEError varchar2(1));
create or replace type dlyout.srvCtr_sum_tbl_of_recs is table of srvCtr_sum_rec_type;
CREATE OR REPLACE PACKAGE DLYOUT.REPORTS_PKG is
  TYPE CUR IS REF CURSOR; 
PROCEDURE testABC(startDate IN date,
                       endDate IN date,
                       startTime IN varchar2,
                       endTime IN varchar2,
                       zoneNo IN dlyout.loc.zone_no%type,
                       distNo IN dlyout.loc.dist_cd%type,
                       CUROUT OUT CUR);
END;
CREATE OR REPLACE PACKAGE BODY DLYOUT.REPORTS_PKG IS
  PROCEDURE testABC(startDate IN date,
                       endDate IN date,
                       startTime IN varchar2,
                       endTime IN varchar2,
                       zoneNo IN dlyout.loc.zone_no%type,
                       distNo IN dlyout.loc.dist_cd%type,
                       CUROUT OUT CUR) as
  startDateTimeStr varchar2(10) := to_Char(startDate, 'MM/DD/YYYY') ;     
  endDateTimeStr varchar2(10) := to_Char(endDate, 'MM/DD/YYYY');   
  startDateTime date := to_date(startDateTimeStr || ' ' || startTime, 'MM/DD/YYYY HH24:MI:SS');
  endDateTime date := to_date(endDateTimeStr|| ' ' || endTime, 'MM/DD/YYYY HH24:MI:SS');
  distClause varchar2(1000);
  sqls varchar2(2000);
  zoneClause varchar2(1000) :='';
  idx number :=0;
  curSrvCtr cur;
  srvCtrRec srvCtr_sum_rec_type;
  srvCtrTbl srvCtr_sum_tbl_of_recs :=srvCtr_sum_tbl_of_recs();
  BEGIN
    if zoneNo <> 9999 then
        zoneClause := ' and zone_no member of dlyout.reports_common_stuff_pkg.convert_to_collection(zoneNo)';
    end if;
    if distNo <> '9999' then
        distClause := ' and dist_cd member of dlyout.reports_common_stuff_pkg.convert_to_collection(distNo) ';
    end if;
    sqls := 'select distinct l.zone_no zoneNo, l.zone_tx zoneTx,
            l.dist_cd distCd , l.dist_tx distTx, 0 numOccr, '''' MEError       
            from dlyout.loc l
            where l.ts between  :startts and :endts ' ||
            zoneClause ||
            distClause ||
            ' order by l.zone_no, l.dist_tx ';
    open curSrvCtr for sqls using  startDateTime, endDateTime;
    LOOP
      FETCH curSrvCtr INTO srvCtrRec;      --ORA:00932 inconsistent datatype expected - got -
      EXIT WHEN curSrvCtr%NOTFOUND;
        --call other functions to get calculated fields
        srvCtrRec.numOccr := dlyout.reports_common_stuff_pkg.Num_Loc_Exc_Mom(startDateTimeStr, endDateTimeStr, starttime, endTime, srvctrRec.distno);
        srvCtrRec.MEError := dlyout.reports_common_stuff_pkg.ME_Error(startDateTimeStr, endDateTimeStr, starttime, endTime, srvCtrRec.distNo, null);
        dbms_output.put_line(srvCtrRec.distTx || ' ' || srvCtrRec.numoccr|| ' ' || srvCtrRec.MEError);
     end loop;
end testABC;
END;
  Then I need to add the object to the table. Something like this?
       -- add object 'record' to table
       srvCtrTbl.extend;
       srvCtrTbl.last := srvCtrRec;
Then I am not sure how to do the cast to get the table to a ref cursor. Something like this?
open curout for SELECT *
FROM TABLE (CAST (srvCtrTbl AS srvCtr_sum_tbl_of_recs))
ORDER BY zoneNo, distTx;

Ok, so after more research if seems that in 10.2 you cannot assign an object (SQL) type to a ref cursor (PLSQL). SO i changed my direction and used a global temp table - created at the schema level.
Create global temporary table dlyout.srvCtr_summary (
                           zoneNo number,
                           zonetx varchar2(15),
                           distNo varchar2(4),
                           distTx varchar2(30),
                           numOccr number,
                           MEError varchar2(1)
) on commit delete rows;Here is what the procedure looks like now.
PROCEDURE testABC(startDate IN date,
                       endDate IN date,
                       startTime IN varchar2,
                       endTime IN varchar2,
                       zoneNo IN dlyout.location.zone_no%type,
                       distNo IN dlyout.location.dist_cd%type,
                       CUROUT OUT CUR) as
  startDateTimeStr varchar2(10) := to_Char(startDate, 'MM/DD/YYYY') ;     
  endDateTimeStr varchar2(10) := to_Char(endDate, 'MM/DD/YYYY');   
  startDateTime date := to_date(startDateTimeStr || ' ' || startTime, 'MM/DD/YYYY HH24:MI:SS');
  endDateTime date := to_date(endDateTimeStr|| ' ' || endTime, 'MM/DD/YYYY HH24:MI:SS');
  distClause varchar2(1000);
  sqls varchar2(2000);
  zoneClause varchar2(1000) :='';
  curSrvCtr cur;
--Still need the PLSQL record type to put in the cursor for the dynamic SQL
type srvCtr_sum_rec_type is record (zoneNo dlyout.location.zone_no%type,
                           zonetx dlyout.location.zone_tx%type,
                           distNo dlyout.location.dist_cd%type,
                           distTx dlyout.location.dist_tx%type,
                           numOccr number,
                           MEError varchar2(1));
  srvCtrRec srvCtr_sum_rec_type;
  BEGIN
    --create clauses for dynamic sql by calling other functions
    if zoneNo <> 9999 then
        zoneClause := ' and zone_no member of dlyout.reports_common_stuff_pkg.convert_to_collection(zoneNo)';
    end if;
    if distNo <> '9999' then
        distClause := ' and dist_cd member of dlyout.reports_common_stuff_pkg.convert_to_collection(distNo) ';
    end if;
    --here is the dynamic sql
    sqls := 'select distinct l.zone_no, l.zone_tx,
            l.dist_cd , l.dist_tx, 0, 0,
            0, 0, ''''       
            from dlyout.location l
            where l.enrgz_ts between  :startts and :endts ' ||
            zoneClause ||
            distClause ||
            ' order by l.zone_no, l.dist_tx ';
   open curSrvCtr for sqls using  startDateTime, endDateTime;
    LOOP
      --fetch in part of the record
      FETCH curSrvCtr INTO srvCtrRec;
      EXIT WHEN curSrvCtr%NOTFOUND;
      --do the calculations to get the other field values
        srvCtrRec.numOccr := dlyout.reports_common_stuff_pkg.Num_Loc_Exc_Mom(startDateTimeStr, endDateTimeStr, starttime, endTime, srvctrRec.distno);
         srvCtrRec.MEError := dlyout.reports_common_stuff_pkg.MEC_Error(startDateTimeStr, endDateTimeStr, starttime, endTime, srvCtrRec.distNo, null);
        dbms_output.put_line(srvCtrRec.distTx || ' ' || srvCtrRec.numoccr|| ' ' || srvCtrRec.MEError);
        --add record to GTT
        insert into dlyout.srvCtr_summary(zoneNo, zoneTx, distNo, distTX, numOccr, MEError )
        values(srvCtrRec.zoneNo, srvCtrRec.zoneTx, srvCtrRec.distNo, srvCtrRec.distTX, srvCtrRec.numOccr, srvCtrRec.MEError);
    end loop;
   --open GTT and return ref cursor to app
   open curout for SELECT *
       FROM srvCtr_summary
       ORDER BY zoneNo, distTx;
  end testABC;

Similar Messages

  • How to fetch into any type of record

    Hi,
    I have a problem. I have to create a procedure to which any query is given it is able to execute and then fetch into the record create based on the cursor. here is the code
    procedure execute_query(p_sql varchar2) is
    type t_rc is ref cursor;
    l_rc t_rc;
    v_t_record l_rc%rowtype;
    begin
    --dbms_lock.sleep(10);
    open l_rc for p_sql;
    loop
    fetch l_rc
    into v_t_record;
    dbms_output.put_line(v_t_record.object_name);
    exit when l_rc%notfound;
    end loop;
    v_query_row_count := l_rc%rowcount;
    -- dbms_output.put_line(v_query_row_count);
    end execute_query;
    constraints:
    i can specify return clause in ref cursor.
    I have to fetch into the records from different queries
    thanks
    Regards
    nick
    Edited by: Nick Naughty on Dec 21, 2008 5:16 AM

    Yes, as I already mentioned, you could use DBMS.SQL:
    create or replace
      procedure p1(
                   p_query varchar2
      is
          c           number;
          d           number;
          col_cnt     integer;
          f           boolean;
          rec_tab     dbms_sql.desc_tab;
          v_number    number;
          v_string    varchar2(4000);
          v_date      date;
          v_rownum    number;
      begin
          c := dbms_sql.open_cursor;
          dbms_sql.parse(c,p_query, dbms_sql.native);
          dbms_sql.describe_columns(c,col_cnt,rec_tab);
          for col_num in 1..rec_tab.count loop
            if rec_tab(col_num).col_type = 1
              then
                dbms_sql.define_column(c,col_num,v_string,rec_tab(col_num).col_max_len);
            elsif rec_tab(col_num).col_type = 2
              then
                dbms_sql.define_column(c,col_num,v_number);
            elsif rec_tab(col_num).col_type = 12
              then
                dbms_sql.define_column(c,col_num,v_date);
              else raise_application_error(-20900,'unsupported data type');
            end if;
          end loop;
          d := dbms_sql.execute(c);
          v_rownum := 0;
          loop
            exit when dbms_sql.fetch_rows(c) = 0;
            v_rownum := v_rownum + 1;
            dbms_output.put_line('row ' || v_rownum);
            for col_num in 1..rec_tab.count loop
              if rec_tab(col_num).col_type = 1
                then
                  dbms_sql.column_value(c,col_num,v_string);
                  dbms_output.put_line('  ' || rec_tab(col_num).col_name || ' = ' || v_string);
              elsif rec_tab(col_num).col_type = 2
                then
                  dbms_sql.column_value(c,col_num,v_number);
                  dbms_output.put_line('  ' || rec_tab(col_num).col_name || ' = ' || v_number);
              elsif rec_tab(col_num).col_type = 12
                then
                  dbms_sql.column_value(c,col_num,v_date);
                  dbms_output.put_line('  ' || rec_tab(col_num).col_name || ' = ' || v_date);
                else
                  raise_application_error(-20900,'unsupported data type');
              end if;
            end loop;
          end loop;
          dbms_sql.close_cursor(c);
        exception
          when others
            then
              if dbms_sql.is_open(c)
                then
                  dbms_sql.close_cursor(c);
              end if;
              raise;
    end;
    set serveroutput on format wrapped
    exec p1('select ename,sal,hiredate from emp');
    SQL> create or replace
      2    procedure p1(
      3                 p_query varchar2
      4                )
      5    is
      6        c           number;
      7        d           number;
      8        col_cnt     integer;
      9        f           boolean;
    10        rec_tab     dbms_sql.desc_tab;
    11        v_number    number;
    12        v_string    varchar2(4000);
    13        v_date      date;
    14        v_rownum    number;
    15    begin
    16        c := dbms_sql.open_cursor;
    17        dbms_sql.parse(c,p_query, dbms_sql.native);
    18        dbms_sql.describe_columns(c,col_cnt,rec_tab);
    19        for col_num in 1..rec_tab.count loop
    20          if rec_tab(col_num).col_type = 1
    21            then
    22              dbms_sql.define_column(c,col_num,v_string,rec_tab(col_num).col_max_len);
    23          elsif rec_tab(col_num).col_type = 2
    24            then
    25              dbms_sql.define_column(c,col_num,v_number);
    26          elsif rec_tab(col_num).col_type = 12
    27            then
    28              dbms_sql.define_column(c,col_num,v_date);
    29            else raise_application_error(-20900,'unsupported data type');
    30          end if;
    31        end loop;
    32        d := dbms_sql.execute(c);
    33        v_rownum := 0;
    34        loop
    35          exit when dbms_sql.fetch_rows(c) = 0;
    36          v_rownum := v_rownum + 1;
    37          dbms_output.put_line('row ' || v_rownum);
    38          for col_num in 1..rec_tab.count loop
    39            if rec_tab(col_num).col_type = 1
    40              then
    41                dbms_sql.column_value(c,col_num,v_string);
    42                dbms_output.put_line('  ' || rec_tab(col_num).col_name || ' = ' || v_string);
    43            elsif rec_tab(col_num).col_type = 2
    44              then
    45                dbms_sql.column_value(c,col_num,v_number);
    46                dbms_output.put_line('  ' || rec_tab(col_num).col_name || ' = ' || v_number);
    47            elsif rec_tab(col_num).col_type = 12
    48              then
    49                dbms_sql.column_value(c,col_num,v_date);
    50                dbms_output.put_line('  ' || rec_tab(col_num).col_name || ' = ' || v_date);
    51              else
    52                raise_application_error(-20900,'unsupported data type');
    53            end if;
    54          end loop;
    55        end loop;
    56        dbms_sql.close_cursor(c);
    57      exception
    58        when others
    59          then
    60            if dbms_sql.is_open(c)
    61              then
    62                dbms_sql.close_cursor(c);
    63            end if;
    64            raise;
    65  end;
    66  /
    Procedure created.
    SQL> set serveroutput on format wrapped
    SQL> exec p1('select ename,sal,hiredate from emp');
    row 1
      ENAME = SMITH
      SAL = 800
      HIREDATE = 17-DEC-80
    row 2
      ENAME = ALLEN
      SAL = 1600
      HIREDATE = 20-FEB-81
    row 3
      ENAME = WARD
      SAL = 1250
      HIREDATE = 22-FEB-81
    row 4
      ENAME = JONES
      SAL = 2975
      HIREDATE = 02-APR-81
    row 5
      ENAME = MARTIN
      SAL = 1250
      HIREDATE = 28-SEP-81
    row 6
      ENAME = BLAKE
      SAL = 2850
      HIREDATE = 01-MAY-81
    row 7
      ENAME = CLARK
      SAL = 2450
      HIREDATE = 09-JUN-81
    row 8
      ENAME = SCOTT
      SAL = 3000
      HIREDATE = 19-APR-87
    row 9
      ENAME = KING
      SAL = 5000
      HIREDATE = 17-NOV-81
    row 10
      ENAME = TURNER
      SAL = 1500
      HIREDATE = 08-SEP-81
    row 11
      ENAME = ADAMS
      SAL = 1100
      HIREDATE = 23-MAY-87
    row 12
      ENAME = JAMES
      SAL = 950
      HIREDATE = 03-DEC-81
    row 13
      ENAME = FORD
      SAL = 3000
      HIREDATE = 03-DEC-81
    row 14
      ENAME = MILLER
      SAL = 1300
      HIREDATE = 23-JAN-82
    PL/SQL procedure successfully completed.
    SQL> SY.

  • JPublisher: oracle...literal.AttributeMap not translated into object type

    Hi,
    I have a problem to get a valid PL/SQL wrapper for the web-service at http://adostest.armstrongconsulting.com/DSX/DocumentServices.asmx?wsdl
    I use jpub to generate the web service callout (jar file and pl/sql wrapper) and the generation of that file completes without an error, but if I try to load the pl/sql package into the database it fails, because one of the generated object types has an invalid definition.
    -- Create SQL type for oracle.j2ee.ws.common.encoding.literal.AttributeMap
    CREATE OR REPLACE TYPE OBJ_AttributeMap AS OBJECT (); The object type for the java class oracle.j2ee.ws.common.encoding.literal.AttributeMap doesn't contain any attributes.
    Software used:
    -) Latest JPublisher 10g Release 10.2 (http://download.oracle.com/otn/utilities_drivers/jdbc/10201/jpub_102.zip)
    -) 10.1.3.1 Callout Utility for 10g and 11g RDBMS (http://download.oracle.com/technology/sample_code/tech/java/jsp/dbws-callout-utility-10131.zip)
    -) Oracle DB 10.2.0.3
    Command used to generate files:
    jpub -proxywsdl="http://adostest.armstrongconsulting.com/DSX/DocumentServices.asmx?wsdl" -proxyopts=noload -package=ados -plsqlpackage=ADOS_WebServiceBTW, I noticed that the dbwsa.jar contains this class, but the "runtime" classes contained in dbwsclientws.jar which are loaded into the database do not contain this class. If I look into the previous version of the Callout Utility (10.1.3.0) at http://download.oracle.com/technology/sample_code/tech/java/jsp/dbws-callout-utility-10R2.zip it is contained in the dbwsclient.jar which is loaded into the database.
    What is wrong or what can I do to get a valid object type mapping?
    Thanks
    Patrick

    Yes. We are calling a .NET web service as well.
    I got around the problem by the following steps:
    1. Forcing JPub to use the jar files that come with JDeveloper 10.1.3.3, rather than dbwsa.jar and dbwsclientws.jar.
    2. Upload the JDeveloper 10.1.3.3 web service libraries into the database
    3. Manually edit the JPub wrapper code (static methods) generated by JPub. I have to comment out all references to AttributeMap. Not sure why JPub wants to use it...

  • Null Pointer when fetching VARRAY / OBJECT TYPE

    Hi,
    i'm trying to fetch a VARRAY, containing an Obeject Type consisiting of two NUMBERS (see scripts below). Now i used JDeveloper to generate corresponding Java Klasses. What i'm trying to do is this:
    String SQL = "select quantityprice from ts_transaction_q_history where hist_id = 125608";
    Map map = null;
    Class obj = null;
    Connection tmpCon = null;
    PreparedStatement tmpStmt = null;
    ResultSet tmpRS = null;
    VaQuantitypriceQ100 tmpQP100 = null;
    OtQuantityprice tmpQP = null;
    OtQuantityprice[] tmpQPArr = null;
    ARRAY tmpQP100ARR = null;
    try {
    tmpCon = getConnection();
    map= tmpCon.getTypeMap();
    obj = Class.forName("ch.egl.emis.persistence.wrapper.VaQuantitypriceQ100");
    map.put(VaQuantitypriceQ100._SQL_NAME, obj);
    tmpCon.setTypeMap(map);
    tmpStmt = tmpCon.prepareStatement(SQL);
    tmpRS = tmpStmt.executeQuery();
    while (tmpRS.next()) {
    tmpQP100ARR = (ARRAY) tmpRS.getObject(1);
    System.out.println(tmpQP100ARR.toString());
    ORADataFactory factory = VaQuantitypriceQ100.getORADataFactory();
    tmpQP100 = (VaQuantitypriceQ100) factory.create(tmpQP100ARR, OracleTypes.ARRAY);
    Long quan = tmpQP.getQuantity().longValue();
    Long price = tmpQP.getPrice().longValue();
    Well, everything works fine, as far as i can see. I get a Quantity (quan), but when i try to get the price, i get a null pointer.
    I am sure, that there is data on the DB and the value for price is nut null. i an using JBoss 3.2.7 and Oracle 9i. Connection is "thin" (may that be the Ptoblem)?
    Anybody there who had similar problems or has a solution for this?
    Many thanks
    Sven
    ********************** VA_QUANTITYPRICE_Q_100 *********************************
    CREATE OR REPLACE TYPE VA_QUANTITYPRICE_Q_100 AS VARRAY(100) OF OT_QUANTITYPRICE
    ********************** OT_QUANTITYPRICE *********************************
    CREATE OR REPLACE TYPE "OT_QUANTITYPRICE" as object (
    quantity number,
    price number
    )

    Hi,
    i'm trying to fetch a VARRAY, containing an Obeject Type consisiting of two NUMBERS (see scripts below). Now i used JDeveloper to generate corresponding Java Klasses. What i'm trying to do is this:
    String SQL = "select quantityprice from ts_transaction_q_history where hist_id = 125608";
    Map map = null;
    Class obj = null;
    Connection tmpCon = null;
    PreparedStatement tmpStmt = null;
    ResultSet tmpRS = null;
    VaQuantitypriceQ100 tmpQP100 = null;
    OtQuantityprice tmpQP = null;
    OtQuantityprice[] tmpQPArr = null;
    ARRAY tmpQP100ARR = null;
    try {
    tmpCon = getConnection();
    map= tmpCon.getTypeMap();
    obj = Class.forName("ch.egl.emis.persistence.wrapper.VaQuantitypriceQ100");
    map.put(VaQuantitypriceQ100._SQL_NAME, obj);
    tmpCon.setTypeMap(map);
    tmpStmt = tmpCon.prepareStatement(SQL);
    tmpRS = tmpStmt.executeQuery();
    while (tmpRS.next()) {
    tmpQP100ARR = (ARRAY) tmpRS.getObject(1);
    System.out.println(tmpQP100ARR.toString());
    ORADataFactory factory = VaQuantitypriceQ100.getORADataFactory();
    tmpQP100 = (VaQuantitypriceQ100) factory.create(tmpQP100ARR, OracleTypes.ARRAY);
    Long quan = tmpQP.getQuantity().longValue();
    Long price = tmpQP.getPrice().longValue();
    Well, everything works fine, as far as i can see. I get a Quantity (quan), but when i try to get the price, i get a null pointer.
    I am sure, that there is data on the DB and the value for price is nut null. i an using JBoss 3.2.7 and Oracle 9i. Connection is "thin" (may that be the Ptoblem)?
    Anybody there who had similar problems or has a solution for this?
    Many thanks
    Sven
    ********************** VA_QUANTITYPRICE_Q_100 *********************************
    CREATE OR REPLACE TYPE VA_QUANTITYPRICE_Q_100 AS VARRAY(100) OF OT_QUANTITYPRICE
    ********************** OT_QUANTITYPRICE *********************************
    CREATE OR REPLACE TYPE "OT_QUANTITYPRICE" as object (
    quantity number,
    price number
    )

  • Error Thrown while assinging the value into OBJECT TYPE

    Hi Oracle Experts:
    i was create one Oracle OBJECT, that object contain only one variable, and i created one function which is return the object(system date), but while i complied that procedure i was thrown the error message like ORA-06530: Reference to uninitilized composite .
    can any one tell me how can i use the object variable in the select statement into clause .
    Below i pasted my code.
    CREATE OR REPLACE TYPE str_batch IS OBJECT
    sys_date DATE
    CREATE OR REPLACE FUNCTION F_Ln_Getodperd
    p_s_actype VARCHAR2,
    p_s_acno VARCHAR2,
    p_n_bal NUMBER,
    p_d_prodt DATE
    )RETURN str_batch
    IS
    lstr_od str_batch ;
    BEGIN
    SELECT SYSDATE  INTO lstr_od.sys_date FROM dual; -- Error(Error message shown in below)
    dbms_output.put_line('');
    RETURN lstr_od;
    END;
    Error:
    ORA-06530: Reference to uninitilized composite
    Thanks in advance
    Arun M M

    Hi Mr. Saubhik
    Below i Paste my original source code. Still am facing the same problem while i execute the function. can you please tell me the solution for this.
    OBJECT :
    CREATE OR REPLACE TYPE str_batch IS OBJECT
    batchno NUMBER,
    batchslno NUMBER,
    act_type VARCHAR2(20),
    act_no VARCHAR2(20),
    curr_code VARCHAR2(10),
    amount NUMBER(23,5),
    MOD VARCHAR2(10),
    drcr VARCHAR2(2),
    cheqno VARCHAR2(20),
    cheqdt DATE,
    sts VARCHAR2(4),
    operid NUMBER,
    narr VARCHAR2(300),
    srno VARCHAR2(10),
    rem_type VARCHAR2(10)
    Function :
    CREATE OR REPLACE FUNCTION F_Ln_Getodperd
    p_s_actype IN VARCHAR2,
    p_s_acno IN VARCHAR2,
    p_n_bal IN NUMBER,
    p_d_prodt IN DATE
    )RETURN str_batch
    IS
    lstr_od str_batch ;
    -- Variable Declaration
         v_n_perd     NUMBER;     
         v_n_lnperd     NUMBER;     
         v_n_mon NUMBER;
         v_n_effmon NUMBER;
         v_n_instno NUMBER;
         v_n_odno NUMBER;
         v_n_actual NUMBER(23,5);
         v_n_diff     NUMBER(23,5);
         v_n_inst     NUMBER(23,5);
         v_d_first     DATE;
         v_d_exp DATE;
         v_d_oddt     DATE;
         v_d_lastprod DATE;
         v_s_instmode VARCHAR2(10);
         v_s_inst     VARCHAR2(10);
         v_s_branch VARCHAR2(10);
         v_s_errm VARCHAR2(20000);
    BEGIN
    SELECT F_Get_Brcode INTO v_s_branch FROM dual;
         SELECT pay_c_final,lon_d_expiry, lon_d_lastprod
         INTO     v_s_inst,v_d_exp, v_d_lastprod
         FROM      LOAN_MAST
         WHERE branch_c_code = v_s_branch AND
              act_c_type      = p_s_actype AND
              act_c_no      = p_s_acno;
         IF (p_d_prodt > v_d_exp) THEN
              SELECT CEIL(MONTHS_BETWEEN(p_d_prodt,v_d_exp)) INTO lstr_od.batchslno FROM dual;
              lstr_od.cheqdt := v_d_exp;
              SELECT v_d_lastprod - p_d_prodt INTO lstr_od.batchslno FROM dual;
              --lstr_od.batchslno = DaysAfter(DATE(ldt_lastprod), DATE(adt_prodt))
         ELSE
              IF (v_s_inst = 'N') THEN
                   IF p_d_prodt > v_d_exp THEN
                        SELECT CEIL(MONTHS_BETWEEN(p_d_prodt,v_d_exp)) INTO lstr_od.batchslno FROM dual;
                        lstr_od.cheqdt := v_d_exp;
                   ELSE
                        lstr_od.batchslno := 1;
                   END IF;     
              ELSIF (v_s_inst = 'Y') THEN
                   SELECT first_d_due,lon_c_instperd,lon_n_perd
                   INTO v_d_first,v_s_instmode,v_n_lnperd
                   FROM LOAN_MAST
                   WHERE branch_c_code = v_s_branch AND
                        act_c_type      = p_s_actype AND
                        act_c_no          = p_s_acno;     
              SELECT CEIL(MONTHS_BETWEEN(p_d_prodt,v_d_first)) INTO v_n_mon FROM dual;          
                   IF v_n_mon > 0 THEN
                        SELECT NVL(ln_n_balance,0),NVL(ln_n_instlamt,0),NVL(ln_n_instlno,0)
                        INTO v_n_actual,v_n_inst,v_n_instno
                        FROM LOAN_INST_SCH
                        WHERE act_c_type = p_s_actype AND
                             act_c_no     = p_s_acno AND
                             ln_d_effdate = (SELECT MAX(ln_d_effdate)
                                                           FROM     LOAN_INST_SCH
                                                           WHERE act_c_type = p_s_actype AND
                                                                     act_c_no = p_s_acno AND
                                                                     ln_d_effdate < p_d_prodt);
                        IF (p_n_bal > v_n_actual) THEN
                             IF v_n_inst > 0 THEN
                             lstr_od.batchslno := (p_n_bal - v_n_actual) / v_n_inst;
                             END IF;
                        ELSE
                             lstr_od.batchslno := 1;
                        END IF;
                        IF lstr_od.batchslno = 0 THEN
                        lstr_od.batchslno := 1;
                        END IF;
                        --FOR FULL OD
                        IF (v_n_mon > v_n_lnperd) THEN
                        lstr_od.batchslno := (v_n_mon - v_n_lnperd) + lstr_od.batchslno;
                        END IF;
                        IF v_s_instmode = 'Q' THEN
                        lstr_od.batchslno := lstr_od.batchslno * 3;
                        ELSIF v_s_instmode = 'H' THEN
                        lstr_od.batchslno := lstr_od.batchslno * 6;
                        ELSIF v_s_instmode = 'Y' THEN
                        lstr_od.batchslno := lstr_od.batchslno * 12;
                        END IF;
                        SELECT p_d_prodt - lstr_od.batchslno INTO lstr_od.cheqdt FROM dual;
                        IF v_s_instmode = 'M' THEN
                        v_n_odno := v_n_instno - lstr_od.batchslno; -- TO get OD DATE
                             SELECT ln_d_effdate
                             INTO lstr_od.cheqdt
                             FROM LOAN_INST_SCH
                             WHERE act_c_type = p_s_actype AND
                                  act_c_no     = p_s_acno AND
                                  ln_n_instlno = v_n_odno;
                             IF SQLCODE = -1 THEN
                             lstr_od.batchslno := -1;
                             RETURN lstr_od;
                             END IF;
                        END IF;
                        ELSE
                        lstr_od.batchslno := 1;
                        END IF;                                             
              END IF;                                             
              END IF;     
    RETURN lstr_od;
    EXCEPTION
    WHEN OTHERS THEN
    v_s_errm := SQLERRM;
    dbms_output.put_line(SQLERRM);
    lstr_od.batchslno := -1;
    RETURN lstr_od;
    END;
    /

  • Select into OBJECT TYPE

    Gotta run this some folks as it is driving me nuts. Using the nested table types so I have a simple type declared as this....
    CREATE OR REPLACE
    TYPE MAGIC_ARRAY AS TABLE OF FLOAT;
    I want to use a function which gets the values in the table by column attempts to select into the collection......
    FUNCTION getMagicNumbers()
    RETURN magic_array
    IS
    v_magic_array magic_array := magic_array();
    BEGIN
    v_magic_array.extend(10);
    select cbe.Field1,
    cbe.Field2,
    cbe.Field3,
    cbe.Field4,
    cbe.Field5,
    cbe.Field6,
    cbe.Field7,
    cbe.Field8,
    cbe.Field9,
    cbe.Field10
    INTO v_magic_array
    from cbe_magic_number cbe
    WHERE ROWNUM=1;
    --Return the value
    return (v_magic_array);
    end getMagicNumbers;
    Looks like it should work but I get ORA-00947: not enough values. If I replace the "INTO v_magic_array" with individual indexed values....
    INTO v_magic_array(1),
    v_magic_array(2),
    v_magic_array(3),
    v_magic_array(4),
    v_magic_array(5),
    v_magic_array(6),
    v_magic_array(7),
    v_magic_array(8),
    v_magic_array(9),
    v_magic_array(10),
    It compiles and works fine. Do I need to use the indexes for the assignment of values all the time?

    you need to specifically list the elements by subscript.It seems simpler to just instantiate a new collection in-line in your SQL.
    SQL> SET SERVEROUTPUT ON;
    SQL> DECLARE
      2     FUNCTION getmagicnumbers
      3        RETURN magic_array
      4     IS
      5        v_magic_array magic_array;
      6     BEGIN
      7        SELECT magic_array (
      8                  cbe.field1, cbe.field2,
      9                  cbe.field3, cbe.field4,
    10                  cbe.field5, cbe.field6,
    11                  cbe.field7, cbe.field8,
    12                  cbe.field9, cbe.field10)
    13        INTO   v_magic_array
    14        FROM   cbe_magic_number cbe
    15        WHERE  ROWNUM = 1;
    16 
    17        RETURN v_magic_array;
    18     END;
    19  BEGIN
    20     DBMS_OUTPUT.PUT_LINE (
    21        'getmagicnumbers ().COUNT => ' ||
    22           getmagicnumbers ().COUNT);
    23  END;
    24  /
    getmagicnumbers ().COUNT => 10
    PL/SQL procedure successfully completed.
    SQL>

  • How to add elements into Object[][] type of list, in runtime?

    I have Object list, ie.
        final Object[][] data = {
            {"January",   new Integer(150) },
            {"February",  new Integer(500) },
            {"March",     new Integer(54)  },
            {"April",     new Integer(-50) }
        };How can I dynamicly add new elements in it, at the runtime?
    Thank you in advance!

    Do I have to remove 'final' for that, and then add
    elements?
    No. you can't change an array's size.
    You can do this
    Object[][] arr = new Object[numRows][numCols];But once you've created it, its size can't change.*
    I don't know what you're doing, though, and what actual data you're putting in, but Object[][] holding rows of [String, Integer] is almost certainly a poor data structure. Think about creating a class the represents one "row" here and then create a 1D array of that class.
    * Okay, you can kinda sorta effectively "change" the size of second and subsequent dimensions, since a multidimensional array is an array of arrays. I wouldn't recommend it though: int[][] arr = new int[3][2]; // a 3 x 2 rectangular array of int--it's  an array of array of int, with 3 "rows", each of which is an array of int with 2 elements.
    arr[0] = new int[10]; // now it's a jagged array whose first row has 10 elments instead of 2Here we haven't changed an array's size, just replaced one of its elements, which is also an array, with a new, larger array.

  • Dynamically built query on execution How to save the data in Object Type

    Hi,
    In pl/sql I am building and executing a query dynamically. How can I stored the output of the query in object type. I have defined the following object type and need to store the
    output of the query in it. Here is the Object Type I have
    CREATE OR REPLACE TYPE DEMO.FIRST_RECORDTYPE AS OBJECT(
    pkid NUMBER,
    pkname VARCHAR2(100);
    pkcity VARCHAR2(100);
    pkcounty VARCHAR2(100)
    CREATE OR REPLACE TYPE DEMO.FIRST_RECORDTYPETAB AS TABLE OF FIRST_RECORDTYPE;Here is the query generated at runtime and is inside a LOOP
    --I initialize my Object Type*
    data := new FIRST_RECORDTYPETAB();
    FOR some_cursor IN c_get_ids (username)
    LOOP
    x_context_count := x_context_count + 1;
    -- here I build the query dynamically and the same query generated is
    sql_query := 'SELECT pkid as pid ,pkname as pname,pkcity as pcity, pkcounty as pcounty FROM cities WHERE passed = <this value changes on every iteration of the cursor>'
    -- and now I need to execute the above query but need to store the output
    EXECUTE IMMEDIATE sql_query
    INTO *<I need to save the out put in the Type I defined>*
    END LOOP;
    How can I save the output of the dynamically built query in the Object Type. As I am looping so the type can have several records.
    Any help is appreciated.
    Thanks

    hai ,
    solution for Dynamically built query on execution How to save the data in Object Type.
    Step 1:(Object creation)
    SQL> ED
    Wrote file afiedt.buf
    1 Create Or Replace Type contract_details As Object(
    2 contract_number Varchar2(15),
    3 contrcat_branch Varchar2(15)
    4* );
    SQL> /
    Type created.
    Step 2:(table creation with object)
    SQL> Create Table contract_dtls(Id Number,contract contract_details)
    2 /
    Table created.
    Step 3:(execution Of procedure to insert the dynamic ouput into object types):
    Declare
    LV_V_SQL_QUERY Varchar2(4000);
    LV_N_CURSOR Integer;
    LV_N_EXECUTE_CURSOR Integer;
    LV_V_CONTRACT_BR Varchar2(15) := 'TNW'; -- change the branch name by making this as input parameter for a procedure or function
    OV_V_CONTRACT_NUMBER Varchar2(15);
    LV_V_CONTRACT_BRANCH Varchar2(15);
    Begin
    LV_V_SQL_QUERY := 'SELECT CONTRACT_NUMBER,CONTRACT_BRANCH FROM CC_CONTRACT_MASTER WHERE CONTRACT_BRANCH = '''||LV_V_CONTRACT_BR||'''';
    LV_N_CURSOR := Dbms_Sql.open_Cursor;
    Dbms_Sql.parse(LV_N_CURSOR,LV_V_SQL_QUERY,2);
    Dbms_Sql.define_Column(LV_N_CURSOR,1,OV_V_CONTRACT_NUMBER,15);
    Dbms_Sql.define_Column(LV_N_CURSOR,2,LV_V_CONTRACT_BRANCH,15);
    LV_N_EXECUTE_CURSOR := Dbms_Sql.Execute(LV_N_CURSOR);
    Loop
    Exit When Dbms_Sql.fetch_Rows (LV_N_CURSOR)= 0;
    Dbms_Sql.column_Value(LV_N_CURSOR,1,OV_V_CONTRACT_NUMBER);
    Dbms_Sql.column_Value(LV_N_CURSOR,2,LV_V_CONTRACT_BRANCH);
    Dbms_Output.put_Line('CONTRACT_BRANCH--'||LV_V_CONTRACT_BRANCH);
    Dbms_Output.put_Line('CONTRACT_NUMBER--'||OV_V_CONTRACT_NUMBER);
    INSERT INTO contract_dtls VALUES(1,CONTRACT_DETAILS(OV_V_CONTRACT_NUMBER,LV_V_CONTRACT_BRANCH));
    End Loop;
    Dbms_Sql.close_Cursor (LV_N_CURSOR);
    COMMIT;
    Exception
    When Others Then
    Dbms_Output.put_Line('SQLERRM--'||Sqlerrm);
    Dbms_Output.put_Line('SQLERRM--'||Sqlcode);
    End;
    step 4:check the values are inseted in the object included table
    SELECT * FROM contract_dtls;
    Regards
    C.karukkuvel

  • Converting OBJECT Type into RECORD Type

    folks,
    Is there a way to Convert a OBJECT Type into a RECORD Type in Oracle PL/SQL, Because i have a stored procedure with RECORD Type as a IN parameter and as we know that we JDBC doesn't support calling or returning RECORD Types , So i was thinking of sending a OBJECT type and convert that to a RECORD type,
    I appreciate any help with the code or point to the documentation,
    thanks
    KM

    folks,
    Is there a way to Convert a OBJECT Type into a RECORD Type in Oracle PL/SQL, Because i have a stored procedure with RECORD Type as a IN parameter and as we know that we JDBC doesn't support calling or returning RECORD Types , So i was thinking of sending a OBJECT type and convert that to a RECORD type,
    I appreciate any help with the code or point to the documentation,
    thanks
    KM

  • Instantiate com.waveset.object.Type into Type[]

    I am trying to instantiate com.waveset.object.Type into Type[]. I am trying execute method exportObjects(Type[] types, java.lang.String filename, BulkMonitor monitor). I can write it in java doing something like _wsSess.exportObjects(new Type[]{Type.findType(type)}, out, null); but having trouble doing in xpress or javascript. Please help. Thanks.

    Hi,
    To get all the types, you can use:
    <invoke name='getTypes' class='com.waveset.object.Type'/>
    to get specific ones:
    <block>
    <set name='typeList'>
    <list>
    <invoke name='getType' class='com.waveset.object.Type'>
    <s>Resource</s>
    </invoke>
    <invoke name='getType' class='com.waveset.object.Type'>
    <s>User</s>
    </invoke>
    </list>
    </set>
    <invoke name='toArray'>
    <ref>typeList</ref>
    </invoke>
    </block>
    hope this helps
    Regards
    Arjun

  • Problem in fetching varray of Object type

    Below are the code,
    where am calling an procedure which returns me Varray of object type test_obj(id number, name varchar2);
    Am facing an problem in get the object(test_obj) from ARRAY object
    the exception is java.lang.ClassCastException: java.lang.Object
    at line number No 12..
    Can anyone suggest me How handle this...
    1. STRUCT test_objStruct ;
    2. ARRAY test_arr;
    3. OracleCallableStatement cs = (OracleCallableStatement)
    4. con.prepareCall("{call test_data(?)}");
    5. cs.registerOutParameter(1,oracle.jdbc.driver.OracleTypes.ARRAY,"TEST_ARR");
    6. cs.execute();
    7. test_arr = (ARRAY)cs.getObject(1);
    8.System.out.println("array varible "+test_arr.getBaseTypeName());
    9. System.out.println("length "+test_arr.length());
    10. Map map = (Map)con.getTypeMap();
    11. map.put("TEST_OBJ", Class.forName("oracle.sql.STRUCT"));
    12. test_objStruct = (STRUCT)test_arr.getArray(1,1);
    13.Object country_attrs[] = test_objStruct.getAttributes();
    14.System.out.println ("ID: " country_attrs[0]);
    15.System.out.println ("Name: " +country_attrs[1]);
    the output is..
    array varible TEST_OBJ
    length 106
    Error java.lang.ClassCastException: java.lang.Object

    Hi,
    The error occurs on line 12, the first time through the loop, when you try to execute:
    vClient(iCounter).ename_obj:=i.ename;
    At that point, vClient (1) is not an Employee object; it's NULL.
    Try this:
    DECLARE
        TYPE tvrEmploy IS VARRAY(10) OF Employee;
        vClient    tvrEmploy;
        iCounter   integer := 1;
        CURSOR client_cursor IS
            SELECT  ename, sal
            ,       empno                                                 -- ADDED
       FROM    scott.emp
       WHERE   rownum < 11;
    BEGIN
        vClient := tvrEmploy (null,null,null,null,null,null,null,null,null,null) ;  
        FOR i IN client_cursor LOOP
            vClient (iCounter) := Employee (i.ename, i.empno, i.sal);     -- CHANGED
            iCounter := iCounter + 1;
       END LOOP;
    FOR I IN REVERSE 1..10 LOOP
           dbms_output.put_line(to_char(I) ||' '|| vClient(I).ename_obj ||' '|| vClient(I).empno_obj ||' '||
          vClient(I).sal_obj);
       END LOOP;
    END ;

  • Mapping refcursors with object types in a procedure

    Hi all,
    I need some help regarding the mapping of refcursors with object types .
    Example: Procedure "A" has object types as input/output parameters which lies in the Web Method Application as a API.
    We are creating a procedure "B" which has ref cursors as input/ouput parameters
    which will map to the Procedure "A"'s object type parameters.
    It will be highly needful for the solution.
    Regards
    Saugata

    Your pseudocode has a lot of steps in it, but you didn't say which step you need help with. Since I already covered going from a nested table type to a refcursor, I'll assume you want an example that goes the other way now, like from a refcursor to a nested table type. Here's one ...
    SQL>
    SQL>
    SQL> set serveroutput on
    SQL>
    SQL> create type nested_table_type as table of varchar2(14) ;
      2  /
    Type created.
    SQL> show errors
    No errors.
    SQL>
    SQL>
    SQL> create function func
      2    ( p_cursor in sys_refcursor )
      3    return nested_table_type
      4  as
      5    v_nested_table nested_table_type ;
      6  begin
      7
      8    fetch p_cursor bulk collect into v_nested_table ;
      9    return( v_nested_table );
    10
    11  end;
    12  /
    Function created.
    SQL> show errors
    No errors.
    SQL>
    SQL> select func( cursor( select dname from dept ) ) as nested_table from dual ;
    NESTED_TABLE
    NESTED_TABLE_TYPE('ACCOUNTING', 'RESEARCH', 'SALES', 'OPERATIONS')If your cursor selects objects instead of simple data types, the code is pretty much the same.
    SQL> create type object_type as object ( c1 varchar2(14), c2 varchar2(13) );
      2  /
    Type created.
    SQL> show errors
    No errors.
    SQL>
    SQL> create type nested_table_type as table of object_type ;
      2  /
    Type created.
    SQL> show errors
    No errors.
    SQL>
    SQL>
    SQL>
    SQL> create function func
      2    ( p_cursor in sys_refcursor )
      3    return nested_table_type
      4  as
      5    v_nested_table nested_table_type ;
      6  begin
      7
      8    fetch p_cursor bulk collect into v_nested_table ;
      9    return( v_nested_table );
    10
    11  end;
    12  /
    Function created.
    SQL> show errors
    No errors.
    SQL>
    SQL> select
      2    func( cursor( select object_type( dname, loc ) from dept ) ) as object_table
      3  from dual ;
    OBJECT_TABLE(C1, C2)
    NESTED_TABLE_TYPE
      ( OBJECT_TYPE('ACCOUNTING', 'NEW YORK'),
        OBJECT_TYPE('RESEARCH', 'DALLAS'),
        OBJECT_TYPE('SALES', 'CHICAGO'),
        OBJECT_TYPE('OPERATIONS', 'BOSTON')
      )(NB I manually reformated the query results for clarity).

  • Object type

    i have problem with using or calling the methods declared in object type body
    how to call a method which is part of database object
    from form 6i
    i can use it in PLsql but HOW i can do it inside form
    its important to me
    r there any 1 can help

    cursor 4_emp_obj
    select emp_obj( from_table_l_name, from_table_l_no, from_table_l_salary)
    from table
    where will_ok = 'I hope so';
    FETCH 4_emp_obj BULK COLLECT INTO emp_obj_array LIMIT 1000 ;
    ... so quick ...

  • Need some help on procedure calling procedure using object type reg

    dear all,
    i need to test one procedure by passing only one value but how do i pass single value. i am showing the details of few section on which i am working on. here is few details about the package.
    Description: package pkj_emp contains two procedure pkj_emp and procedure proc_rem.
    purpose:based on passing dname values to procedure pkj_emp, cursor cur_emp will fetch empid from emp table and then we are passing 4 empid records to procedure proc_rem using empid object type.Inside the procedure proc_rem it will delete all 4 records of table A,B,C and D at one short.
    Requirement:i need to test for only one value that means is it possible i can pass only one value using the cursor cur_emp.
    create or replace package pkj_emp
    TYPE obj_emp IS TABLE OF NUMBER INDEX BY BINARY_INTEGER;
    procedure proc_emp(empid obj_emp);
    create or replace package body pkj_emp
    as
    procedure(
    dname varchar2;
    as
    cursor cur_emp is select emp_id from emp a,dept d
    where a.deptid=d.deptid
    and d.deptname=dname;
    begin
    count:=0;
                   for cur_emp_rec in cur_emp LOOP
                   empid(count) := cur_emp_rec.emp_id;
              IF (count = 4) THEN
                   proc_rem(empid); // calling another procedure
                   commit;
                   END IF;
                   count := count + 1;
                   END LOOP;
    end;
    proc_rem(
    empid obj_emp;
    is
    begin
    delete from A where emp_id in (empid(0),empid(1),empid(2),empid(3));
    delete from B where emp_id in (empid(0),empid(1),empid(2),empid(3));
    delete from c where emp_id in (empid(0),empid(1),empid(2),empid(3));
    delete from d where emp_id in (empid(0),empid(1),empid(2),empid(3));
    end;
    regards
    Laxman

    You have hardcoded your IN LIST in the REM procedure. I recommend changing the code to take a variable number of inputs. You could do something like the following:
    SQL> CREATE TABLE A (ID NUMBER);
    Table created.
    SQL> CREATE TABLE B (ID NUMBER);
    Table created.
    SQL> CREATE TABLE C (ID NUMBER);
    Table created.
    SQL> CREATE TABLE D (ID NUMBER);
    Table created.
    SQL> INSERT INTO A VALUES(7566);
    1 row created.
    SQL> INSERT INTO B VALUES(7902);
    1 row created.
    SQL> INSERT INTO C VALUES(7876);
    1 row created.
    SQL> INSERT INTO D VALUES(7369);
    1 row created.
    SQL> CREATE OR REPLACE TYPE EMP_TYPE AS TABLE OF NUMBER(4);
      2  /
    Type created.
    SQL> CREATE OR REPLACE PACKAGE PKJ_EMP
      2  AS
      3          PROCEDURE PKJ_EMP
      4          (
      5                  DNAME   IN      SCOTT.EMP.DEPTNO%TYPE
      6          );
      7 
      8          PROCEDURE REM
      9          (
    10                  pEMPList  IN      EMP_TYPE
    11          );
    12  END PKJ_EMP;
    13  /
    Package created.
    SQL> CREATE OR REPLACE PACKAGE BODY PKJ_EMP
      2  AS
      3          PROCEDURE PKJ_EMP
      4          (
      5                  DNAME   IN      SCOTT.EMP.DEPTNO%TYPE
      6          )
      7          AS
      8                  pEMPList        EMP_TYPE := EMP_TYPE();
      9                  i               NUMBER := 1;
    10          BEGIN
    11                  FOR r IN
    12                  (
    13                          SELECT  EMPNO
    14                          FROM    SCOTT.EMP
    15                          WHERE   DEPTNO = DNAME
    16                  )
    17                  LOOP
    18                          pEMPList.EXTEND;
    19                          pEMPList(i) := r.EMPNO;
    20 
    21                          i := i + 1;
    22                  END LOOP;
    23 
    24                  REM(pEMPList);
    25          END PKJ_EMP;
    26 
    27          PROCEDURE REM
    28          (
    29                  pEMPList  IN      EMP_TYPE
    30          )
    31          AS
    32          BEGIN
    33                  DELETE FROM A WHERE ID IN (SELECT   COLUMN_VALUE FROM TABLE(pEMPList));
    34                  DELETE FROM B WHERE ID IN (SELECT   COLUMN_VALUE FROM TABLE(pEMPList));
    35                  DELETE FROM C WHERE ID IN (SELECT   COLUMN_VALUE FROM TABLE(pEMPList));
    36                  DELETE FROM D WHERE ID IN (SELECT   COLUMN_VALUE FROM TABLE(pEMPList));
    37          END REM;
    38  END PKJ_EMP;
    39  /
    Package body created.
    SQL> EXEC PKJ_EMP.PKJ_EMP(20);
    PL/SQL procedure successfully completed.
    SQL> SELECT * FROM A;
    no rows selected
    SQL> SELECT * FROM B;
    no rows selected
    SQL> SELECT * FROM C;
    no rows selected
    SQL> SELECT * FROM D;
    no rows selected
    SQL> spool off;HTH!

  • Question on Object Type

    Hi,
    I don't know if its the right forum to ask this question but I am a beginner. I am trying to extract a large number of values from oracle using more than 10 queries fired in sequence, with a little logic in-between( which can easily be shifted a stored procedure). I want to reduce the number of network trips by shifting all these queries in a stored procedure which could take all the input parameters as some sort of Object which can be mapped directly to a C# object. The return type of this proc would also be a similar object/ array of objects.
    I can use those objects as is in my application for further execution.
    Is this approach feasible and optimized than the current mechanism?
    If yes then can I use the oracle object type for this purpose?
    Thanks,
    Peeyush

    > I am trying to extract a large number of values from oracle using more than
    10 queries fired in sequence, with a little logic in-between( which can easily
    be shifted a stored procedure.. <snipped>
    I think that is an accurate description of both the problem and solution.
    It does not make sense to perform huge fetches of data, and ship that off to the client for processing. A RDBMS is a data processing platform. It is designed to do exactly this.. process the data on the server, reducing the data to information and then pass that information to the client.
    And yes, the solution to this is to use PL/SQL. But to a greater extent of merely wanting to weld a bunch of SQLs together. The purpose of PL/SQL is to crunch the data - to do the processing that you would have done at the client.
    In fact, much of this processing can likely be done using just SQL itself, without much help of PL/SQL.
    What does not make sense is to use SQL as your "I/O language" - have it relegated to merely making read and write calls and nothing else. SQL is a very powerful and capable language - and the fastest at crunching data. Nothing, not even PL/SQL which is also very close to the physical data, can do it as fast as SQL.
    Thus the performance and scalability rule that says: Maximize SQL. Minimize PL/SQL (and C/C#/Java/etc).
    What also does not make sense is to take the data returned by SQL and throw it into buffers (objects/collections) in PL/SQL. PL/SQL memory (called PGA) is expensive dedicated memory. Oracle's SQL engine already has a very sophisticated and capable shared database buffer - that unlike a buffer in the PGA, is available and able to service all sessions and clients. (collections/bulk processing in PL/SQL is aimed at reducing context switching - not at reducing I/O calls)
    My approach to this type of problem is to do as much as possible in SQL. Provide a PL/SQL wrapper to make the (sometimes complex) SQL transparent from the client - which also allows me to optimise, tune and maintain that without touching a single byte of client code.
    Do as little as possible in the client (RDBMS and business logic wise) - have the client do what it is suppose to do - Visualise the information received via PL/SQL calls (usually using ref cursors) in an attractive user interface and interact with the end-user.

Maybe you are looking for

  • Internet Explorer preview not working correctly.

    Hi, Well my problems seem to be mounting up, my website is loading completely fine in Chrome and Firefox, but in Internet Explorer it doesn't want to load properly. It seems that only the text is loading, leaving me to believe that the css files, sty

  • How to set a sound when a email will print from the printer.

    I would like to set a sound or a big bip when a email come throught the printer via hpeprint

  • Creator 2 + OODB

    hi! Some one know if is possible work with a Object Oriented Database using Creator 2 ? Some one know if there are an OODB that provide a JDBC Connector, which let me use Data Provider of Creator 2 ? Some one know how I can fil a Table Component usin

  • Billing based on % of the project done

    Hi all! Let's see if you guys can help me out with some ideas here: I need the billing as follows: Every sales order comes from a project and generates a purchase order which account assignment category is "Project" (the same project that trigered th

  • Installing Windows XP on iMac MacOS 10.6

    I (foolishly probably) tried to install Windows XP on my new (February 2011) iMac running MacOS 10.6. I got part way through the installation process and could not get any farther. Messages were that the partitions were not recognized or not big enou