Best way to return complex datasets out of a procedure

Dear Oracle experts,
I'm presently writing on a procedure which should return a kind of datastructure which contains some rows of a table (SIGFacts) which are selected in dependence of
a result set in a cursor.
I would like to return this result set in a manner which enables external programs to
fetch this data.
What I tried in the procedure below is to create a record and make it accessible from external programs outside Oracle (see below).
But I'm not sure whether this is a suitable method.
I'm wondering about several questions :
Is it suitable to give back a record or should I always give back a Cursor ?
If I should give back a cursor, how could I fetch all the data within the record into a cursor ?
And a stupid beginners question :
How can I use the record from a external program ?
(My procedure belongs to a package. The record is defined in the Package head ((see below))
procedure PROCFINDINITIALSWITCHSTATE (SwitchID INTEGER, StartTime TIMESTAMP, ausgabe2 out nocopy SIGFACTTABLE) is
cursor cursor0 (SwitchID Integer) is
select var_ref from DynamicLines where BELONGSTOSWITCHID = SwitchID;
cursor cursor1 (StartTime timestamp, VarRef Integer) RETURN SigFacts%ROWTYPE is
Select * from SIGFacts where (NewValue=1) AND DT<= StartTime AND
Var_ref = VarRef AND rownum = 1 order by DT DESC;
tempRecord SIGFACTTYPE;
tempTable SIGFACTTABLE;
BEGIN
tempTable := SIGFACTTABLE(); --Loeschen der tempTable (Initialisierung mit NULL)
for datensatz in cursor0(SwitchID) loop
for datensatz2 in cursor1 (StartTime, datensatz.Var_Ref) loop
tempTable.extend(1); -- Hinzufuegen eines (zunaechst leeren) Datensatzes
tempTable(tempTable.count).AUTOID := datensatz2.AUTOID;
tempTable(tempTable.count).VAR_REF := datensatz2.VAR_REF;
tempTable(tempTable.count).DT := datensatz2.DT;
tempTable(tempTable.count).MACHINES_REF := datensatz2.MACHINES_REF;
tempTable(tempTable.count).VARIABLESID := datensatz2.VARIABLESID;
tempTable(tempTable.count).OLDVALUE := datensatz2.OLDVALUE;
tempTable(tempTable.count).NEWVALUE := datensatz2.NEWVALUE;
tempTable(tempTable.count).PRODUCTS_REF := datensatz2.PRODUCTS_REF;
tempTable(tempTable.count).USERS_REF := datensatz2.USERS_REF;
tempTable(tempTable.count).LINE_ID := datensatz2.LINE_ID;
end loop;
end loop;
--return tempTable
END PROCFINDINITIALSWITCHSTATE;
I declared the Record in the Head section of the same package.
type SIGFACTTYPE is record(
AUTOID SIGFACTS.AUTOID%type, Var_Ref SIGFACTS.Var_ref%type, DT SIGFACTS.DT%type
, machines_ref SIGFACTS.machines_ref%type, variablesid SIGFACTS.variablesid%type
, oldvalue SIGFACTS.oldvalue%type,
newvalue SIGFACTS.newvalue%type, products_ref SIGFACTS.products_ref%type
, users_ref SIGFACTS.users_ref%type, line_id SIGFACTS.line_id%type
type SIGFACTTABLE is table of SIGFACTTYPE;

Dear Oracle experts,
I'm presently writing on a procedure which should return a kind of datastructure which contains some rows of a table (SIGFacts) which are selected in dependence of
a result set in a cursor.
I would like to return this result set in a manner which enables external programs to
fetch this data.
What I tried in the procedure below is to create a record and make it accessible from external programs outside Oracle (see below).
But I'm not sure whether this is a suitable method.
I'm wondering about several questions :
Is it suitable to give back a record or should I always give back a Cursor ?
If I should give back a cursor, how could I fetch all the data within the record into a cursor ?
And a stupid beginners question :
How can I use the record from a external program ?
(My procedure belongs to a package. The record is defined in the Package head ((see below))
procedure PROCFINDINITIALSWITCHSTATE (SwitchID INTEGER, StartTime TIMESTAMP, ausgabe2 out nocopy SIGFACTTABLE) is
cursor cursor0 (SwitchID Integer) is
select var_ref from DynamicLines where BELONGSTOSWITCHID = SwitchID;
cursor cursor1 (StartTime timestamp, VarRef Integer) RETURN SigFacts%ROWTYPE is
Select * from SIGFacts where (NewValue=1) AND DT<= StartTime AND
Var_ref = VarRef AND rownum = 1 order by DT DESC;
tempRecord SIGFACTTYPE;
tempTable SIGFACTTABLE;
BEGIN
tempTable := SIGFACTTABLE(); --Loeschen der tempTable (Initialisierung mit NULL)
for datensatz in cursor0(SwitchID) loop
for datensatz2 in cursor1 (StartTime, datensatz.Var_Ref) loop
tempTable.extend(1); -- Hinzufuegen eines (zunaechst leeren) Datensatzes
tempTable(tempTable.count).AUTOID := datensatz2.AUTOID;
tempTable(tempTable.count).VAR_REF := datensatz2.VAR_REF;
tempTable(tempTable.count).DT := datensatz2.DT;
tempTable(tempTable.count).MACHINES_REF := datensatz2.MACHINES_REF;
tempTable(tempTable.count).VARIABLESID := datensatz2.VARIABLESID;
tempTable(tempTable.count).OLDVALUE := datensatz2.OLDVALUE;
tempTable(tempTable.count).NEWVALUE := datensatz2.NEWVALUE;
tempTable(tempTable.count).PRODUCTS_REF := datensatz2.PRODUCTS_REF;
tempTable(tempTable.count).USERS_REF := datensatz2.USERS_REF;
tempTable(tempTable.count).LINE_ID := datensatz2.LINE_ID;
end loop;
end loop;
--return tempTable
END PROCFINDINITIALSWITCHSTATE;
I declared the Record in the Head section of the same package.
type SIGFACTTYPE is record(
AUTOID SIGFACTS.AUTOID%type, Var_Ref SIGFACTS.Var_ref%type, DT SIGFACTS.DT%type
, machines_ref SIGFACTS.machines_ref%type, variablesid SIGFACTS.variablesid%type
, oldvalue SIGFACTS.oldvalue%type,
newvalue SIGFACTS.newvalue%type, products_ref SIGFACTS.products_ref%type
, users_ref SIGFACTS.users_ref%type, line_id SIGFACTS.line_id%type
type SIGFACTTABLE is table of SIGFACTTYPE;

Similar Messages

  • What is the best way of returning group-by sql results in Toplink?

    I have many-to-many relationship between Employee and Project; so,
    a Employee can have many Projects, and a Project can be owned by many Employees.
    I have three tables in the database:
    Employee(id int, name varchar(32)),
    Project(id int, name varchar(32)), and
    Employee_Project(employee_id int, project_id int), which is the join-table between Employee and Project.
    Now, I want to find out for each employee, how many projects does the employee has.
    The sql query that achieves what I want would look like this:
    select e.id, count(*) as numProjects
    from employee e, employee_project ep
    where e.id = ep.employee_id
    group by e.id
    Just for information, currently I am using a named ReadAllQuery and I write my own sql in
    the Workbench rather than using the ExpressionBuilder.
    Now, my two questions are :
    1. Since there is a "group by e.id" on the query, only e.id can appear in the select clause.
    This prevent me from returning the full Employee pojo using ReadAllQuery.
    I can change the query to a nested query like this
    select e.eid, e.name, emp.cnt as numProjects
    from employee e,
    (select e_inner.id, count(*) as cnt
    from employee e_inner, employee_project ep_inner
    where e_inner.id = ep_inner.employee_id
    group by e_inner.id) emp
    where e.id = emp.id
    but, I don't like the complication of having extra join because of the nested query. Is there a
    better way of doing something like this?
    2. The second question is what is the best way of returning the count(*) or the numProjects.
    What I did right now is that I have a ReadAllQuery that returns a List<Employee>; then for
    each returned Employee pojo, I call a method getNumProjects() to get the count(*) information.
    I had an extra column "numProjects" in the Employee table and in the Employee descriptor, and
    I set this attribute to be "ReadOnly" on the Workbench; (the value for this dummy "numProjects"
    column in the database is always 0). So far this works ok. However, since the numProjects is
    transient, I need to set the query to refreshIdentityMapResult() or otherwise the Employee object
    in the cache could contain stale numProjects information. What I worry is that refreshIdentityMapResult()
    will cause the query to always hit the database and beat the purpose of having a cache. Also, if
    there are multiple concurrent queries to the database, I worry that there will be a race condition
    of updating this transient "numProjects" attribute. What are the better way of returning this kind
    of transient information such as count(*)? Can I have the query to return something like a tuple
    containing the Employee pojo and an int for the count(*), rather than just a Employee pojo with the
    transient int inside the pojo? Please advise.
    I greatly appreciate any help.
    Thanks,
    Frans

    No I don't want to modify the set of attributes after TopLink returns it to me. But I don't
    quite understand why this matters?
    I understand that I can use ReportQuery to return all the Employee's attributes plus the int count(*)
    and then I can iterate through the list of ReportQueryResult to construct the Employee pojo myself.
    I was hesitant of doing this because I think there will be a performance cost of not being able to
    use lazy fetching. For example, in the case of large result sets and the client only needs a few of them,
    if we use the above aproach, we need to iterate through all of them and wastefully create all the Employee
    pojos. On the other hand, if we let Toplink directly return a list of Employee pojo, then we can tell
    Toplink to use ScrollableCursor and to fetch only the first several rows. Please advise.
    Thanks.

  • Best way to return an array of values from c++?

    I have a a group of structs made of a mix of primitive types in c++. I need to return these to Java but Im not sure the best way to return them quickly.
    Should I create a class corresponding to the structure in Java then create the class in C++ and set its fields and return that? Or should I create arrays of different primitive types and return those? Can I even do that? Say, store a group of arrays of different types in a jobjectArray and return that? If I can, what would be the return type? Object[][]?

    Java side:
    package jni;
    import java.nio.ByteBuffer;
    import java.nio.ByteOrder;
    * @author Ian Schneider
    public class Struct {
        static {
            System.loadLibrary("struct");
        public static void doit() {
            ByteBuffer bytes = ByteBuffer.allocateDirect(structSize());
            bytes.order(ByteOrder.nativeOrder());
            getData(bytes);
            System.out.println("int : " + bytes.getInt());
            System.out.println("double : " + bytes.getDouble());
        private static native void getData(ByteBuffer bytes);
        private static native int structSize();
        public static void main(String[] args) throws Exception {
            doit();
    }C side (I'm not a C programmer, so be nice):
    #include "jni_Struct.h"
    struct foo {
      int x;
      double y;
    } foo;
    JNIEXPORT void JNICALL Java_jni_Struct_getData
      (JNIEnv * env, jobject obj, jobject buf) {
      struct foo * f = (void*) malloc(sizeof(foo));
      f->x = 123;
      f->y = 456.;
      void * data = (void *) (*env)->GetDirectBufferAddress(env,buf);
      memcpy(data,f,sizeof(foo));
      free(f);
    JNIEXPORT jint JNICALL Java_jni_Struct_structSize
      (JNIEnv * env, jobject obj) {
      return sizeof(foo);
    }This is a bit simplistic as foo is static in size (no pointers), but hopefully you get the point.

  • Best way to return structured data?procedure or function?

    Hi everyone.
    I cannot choose the best way to return, from java stored procedure, some data.
    for example , which is best way to write this method:
    public STRUCT function(input parameters) { STRUCT result     ...   return result; }
    or
    public void procedure(input parameters, STRUCT[] struct) { STRUCT result     ...   struct[0] = result; }
    in the last way, the wrapper obviously will be: CREATE PROCEDURE name(... IN datatype, data OUT STRUCT)
    Which is best way in efficiency ?
    thank you ;)

    da`,
    By "efficiency", I assume you mean, best performance/least time.
    In my experience, the only way to discover this is to compare the two, since there are many factors that affect the situation.
    Good Luck,
    Avi.

  • What is the best way to export the data out of BW into a flat file on the S

    Hi All,
    We are BW 7.01 (EHP 1, Service Pack Level 7).
    As part of our BW project scope for our current release, we will be developing certain reports in BW, and for certain reports, the existing legacy reporting system based out of MS Access and the old version of Business Objects Release 2 would be used, with the needed data supplied from the BW system.
    What is the best way to export the data out of BW into a flat file on the Server on regular intervals using a process chain?
    Thanks in advance,
    - Shashi

    Hello Shashi,
    some comments:
    1) An "open hub license" is required for all processes that extract data from BW to a non-SAP system (including APD). Please check with your SAP Account Executive for details.
    2) The limitation of 16 key fields is only valid when using open hub for extracting to a DB table. There's no such limitation when writing files.
    3) Open hub is the recommended solution since it's the easiest to implement, no programming is required, and you don't have to worry much about scaling with higher data volumes (APD and CRM BAPI are quite different in all of these aspects).
    For completeness, here's the most recent documentation which also lists other options:
    http://help.sap.com/saphelp_nw73/helpdata/en/0a/0212b4335542a5ae2ecf9a51fbfc96/frameset.htm
    Regards,
    Marc
    SAP Customer Solution Adoption (CSA)

  • Best way to return more than 1 value in a function?

    Hi all,
    What's the best way to return more than 1 value from a function? returning a cursor? varray? objects? etc? I thought of a cursor first, but i was hesitant since i am not sure if the cursor will be automatically closed when you return a cursor(open cursor no longer used is bad). Example:
    BEGIN
    OPEN c_temp_cursor;
    RETURN c_temp_cursor;
    END;
    With above example, c_temp_cursor is remained open. Or is it automatically closed once it exits from the function? Need some suggestions and expert advice.
    Thanks.
    Note: Function is to be used to return and not a procedure (This is a requirement. Can't explain the details on why).
    Edited by: dongzky on Jul 3, 2010 4:17 PM
    typo: "ir exists" to "it exits" (in bold)

    First create your pl/sql table type
    CREATE OR REPLACE TYPE pmc_tab AS TABLE OF NUMBER;
    Then a table:-
    CREATE TABLE v_stats_daily(start_date date, field1 number, field2 number, field3 number);
    Some insert into the table so we've got test data...
    insert into v_stats_daily values('08-OCT-2003',10,20,30);
    insert into v_stats_daily values('08-OCT-2003',40,50,60);
    insert into v_stats_daily values('08-OCT-2003',70,80,90);
    Then create your function:-
    CREATE OR REPLACE FUNCTION PMC_STATS
    (pStatDate Date) RETURN pmc_tab IS
    MyArray pmc_tab;
    vstat1 NUMBER;
    vstat2 NUMBER;
    vstat3 NUMBER;
    BEGIN
    MyArray := pmc_tab();
    select sum(Field1), sum(field2),sum(field3)
    into vstat1, vstat2,vstat3
    from v_stats_daily
    where Start_date = pStatDate;
    MyArray.extend;
    MyArray(1) := vstat1;
    MyArray.extend;
    MyArray(2) := vstat2;
    MyArray.extend;
    MyArray(3) := vstat3;
    RETURN MyArray;
    END;
    In SQL*Plus:-
    SQL>set serverout on
    Then a lump of PL/SQL to run your function:-
    DECLARE
    MyDate DATE;
    MyArray pmc_tab;
    i NUMBER;
    numOut NUMBER;
    BEGIN
    MyArray := pmc_stats('08-OCT-2003');
    dbms_output.put_line('Table count: '||to_char(MyArray.count));
    for i in 1..MyArray.last LOOP
    numOut := MyArray(i);
    --if numOut is null then
    dbms_output.put_line('Value: '||to_char(numOut));
    --end if;
    END LOOP;
    END;
    Your output will look like:-
    Table count: 3
    Value: 120
    Value: 150
    Value: 180
    Hope this helps,

  • Accidentally I enlarge a window. Best way to return to its original size?

    Sometimes I accidentally enlarge a window. What is the best way to return to its original sign?

    Usually there is a place in the window where three colors of dots are, and the Green dot can make the screen larger and then the same one can make it smaller again.
    Not sure if this helps...
    Good luck & happy computing!

  • What's the best way to connect the audio out of my Mac to my stereo receiver?

    I want to listen to my mp3 collection through my home theatre stero receiver.
    I have 2 audio interfaces that I connect to my mac through USB and Firewire: Digi Design Mbox mini and Maudio ProFire 610.
    I've tried going from a headphone 1/8'' connector from the headphone out of my mac to rca connected to the aux (or whatever) of my stereo.
    I've tried using a 1/4'' adapter on the 1/8'' to go from my mbox mini's headphone output to the rca aux on my stereo.
    The problem is I'm hearing distortions that sound like clipping, or static, crunchiness on certain frequencies in a lot of my mp3's that shouldn't be there.
    I listen to lots of music, and a lot of it uses distortion, like shoegaze, drone etc but I know what I'm hearing is unnatural.
    I even hear these flaws when I listen to headphones through the headphone out of my mbox.
    Page 2 on this instruction manual says I should be able to go from the monitor outs to my stereo. The monitor outs are 1/4 inch out so I figured I would need a 1/4 inch to rca cable.
    I got this one from monster thinking it should work. No dice.
    So my question is, what is the best way to connect my mac to my stereo? I need to avoid these distortions and flaws in the audio i'm hearing or I will go nuts.
    Why might I be getting these clipping distoritons?
    any advice would be fantastic

    It depends on how close the receiver is to the iMac. If it's just a few feet away you need at cable like:
    http://www.amazon.com/StarTech-com-THINTOSMIN6-Toslink-Digital-Optical/dp/B00016 W6Y6/ref=sr_1_2?ie=UTF8&qid=1316096392&sr=8-2
    However if the receiver is across the room or the house you would be best to enable Air Play, this enables you to wirelessly connect the receiver to the iMac. You will need the above cable and an Airport Express. If you are not familiar with Air Play navigate to:
    http://www.apple.com/itunes/airplay/
    I have been using it for quite some time and find it great. If you are not familiar with the Airport Express here is the link to it:
    http://www.apple.com/airportexpress/
    You can even find refurbished ones on Apples website for about $79.

  • What is the best way of lightening complexions?

    Could someone please tell me what is the best way of lightening people's complexions in Aperture 3?

    Have you tried using brushes?
    From the Adjustments tab, select Quick Brushes and then Dodge.
    Adjust the brush size and the strength, then use that to lighten the face area.

  • (New to C# here) What is the best way to return false in a function if it cannot be executed successfully?

    In Javascript or PHP you can have a function that could return, for example, a string in case of success and false in case of failure.
    I've noticed (in the few days I've been learning C#) that you need to define a type of value that the function will return, so you need to return that type of value but in case of failure you can't return false.
    What is the best way to achieve this behavior and is there an example I can see?
    Thank you in advance,
    Juan

    Juan, be aware that returning null won't work with value types, such as an int, which can't be null. You'd have to use a nullable value type. A nullable int would be declared with a "?", such as:
    int? someOtherFunction(int param)
    if(something goes great)
    return param * 42;
    return null;
    And you have to use it like this:
    int? result = someOtherFunction(666);
    if (result != null) // you can also use result.HasValue
    // it worked, do something with the result
    // if you're doing math with the result, no problem
    int x = result * 2;
    // but if you're assigning it to another an int, you need to use this syntax
    int y = result.Value;
    Before nullable value types came along, for a method that returned an int, I'd use a value of something that wouldn't normally be returned by that method to indicate failure, such as a -1.
    ~~Bonnie DeWitt [C# MVP]
    That's something very very important to keep in mind. Can save you from a lot of headaches!
    So if you have an int function and it might return NULL, if you are doing Math with the return value you can use it directly, but if you're assigning it to another variable you have to use .Value?
    Thanks

  • Returning the control out of the procedure

    Gurus,
    Please see my code
    BEGIN
         BEGIN                                    -- To check whether the user(Record) exists in the table
                SELECT a.code, a.code_desc                                     
              INTO L_code, L_code_desc
                FROM CODE_DETAIL a, USER_ROLE_PRIVS b
                WHERE a.code_desc = b.granted_role
                AND a.code_type like '%CATR%'
                AND b.username = I_U_ID;
         EXCEPTION
              WHEN NO_DATA_FOUND THEN
              O_ERR_MSG := 'N';
         END;
      IF L_CODE <> '1' AND L_CODE <> '2' AND L_CODE <> '3' THEN     -- To check whether there is any other role associated other than 1, 2 or 3
         O_ERR_MSG := 'Y';
      END IF;This is a piece of code which is a part of procedure .. Now whenever I have O_ERR_MSG initialized to Y or N .. it should come out of the procedure... What's happenning now is, variable is getting initialized and executing the rest of the code, which shouldnt happen ..
    Can you please tell me how to pass the control back to the procedure without executing the other lines ?
    Regards

    Ok... posting the entire code
    CREATE OR REPLACE PROCEDURE AFE_CHECK_SUBMIT (I_u_id in varchar2, I_ord_num in number, O_rol out VARCHAR2, O_app_check OUT Varchar2, O_v_app_check out number, O_v_otb_check out number, O_AMT OUT NUMBER, O_ERR_MSG OUT VARCHAR2, O_error_message IN OUT varchar2 ) IS
    L_role                  varchar2(30); 
    L_approval_limit        number;         L_otb_limit             number;                
    L_approval_level        varchar2(5);           
    L_tolerance_limit       varchar2(40);            L_program VARCHAR2(60)  := 'AFE_CHECK_SUBMIT';
    L_code                  VARCHAR2(10);
    L_code_desc             VARCHAR2(30);
    L_app_check             NUMBER;
    L_otb_check             NUMBER;
    L_amt                   NUMBER;
    L_otb_amt1              NUMBER;
    L_order_no           NUMBER;
    L_status           VARCHAR2(1);
    CURSOR C_PO_AMT IS SELECT i.dept, i.class, h.order_type, to_CHAR(h.otb_eow_date, 'MONYYYY') po_month, sum(o.qty_ordered * o.unit_cost) po_amt
    FROM ITEM_MASTER i, ORDLOC o, ORDHEAD h
    WHERE i.item = o.item
    AND o.order_no = h.order_no
    AND o.order_no = I_ord_num
    GROUP BY i.dept, i.class, h.order_type, to_CHAR(h.otb_eow_date, 'MONYYYY');
    CURSOR C_OTB_CALCULATE(order_type VARCHAR2, order_eow_date date, dep number, clas number ) IS
    SELECT sum(decode(order_type, 'ARB', a_budget_amt-a_approved_amt,
                                             'BRB', b_budget_amt-b_approved_amt,
                                             'N/B', n_budget_amt-n_approved_amt,
                                                 0)) otb_amt1
      FROM OTB
      WHERE to_char(EOW_DATE,'MONYYYY') = to_char(order_eow_date,'MONYYYY')
      AND DEPT = dep
      AND CLASS = clas
          GROUP BY to_CHAR(ORDER_EOW_DATE,'MONYYYY'),DEPT,CLASS;
          C2 C_OTB_CALCULATE%rowtype;
          c3 C_PO_AMT%rowtype;
    CURSOR C_ROLE_CHECK IS
      SELECT a.code, a.code_desc                                      -- checking the role of the user who has logged in
      FROM CODE_DETAIL a, USER_ROLE_PRIVS b
      WHERE a.code_desc = b.granted_role
      AND a.code_type like '%CATR%'
      AND b.username = I_U_ID;
      L_ROLE_CHECK C_ROLE_CHECK%ROWTYPE;
    BEGIN
       dbms_output.put_line('User id is :' || I_u_id);
       dbms_output.put_line('Selecting the role');
       BEGIN     
         OPEN C_ROLE_CHECK;
         LOOP
              FETCH C_ROLE_CHECK INTO L_ROLE_CHECK;
              EXIT WHEN C_ROLE_CHECK%NOTFOUND;
              L_code := L_ROLE_CHECK.code;
         END LOOP;
       EXCEPTION
              WHEN NO_DATA_FOUND THEN
                 dbms_output.put_line('No Record in table');
              O_ERR_MSG := 'N';  
    END;
      dbms_output.put_line('Role is :' || L_code);
      IF L_CODE <> '1' OR L_CODE <> '2' OR L_CODE <> '3' THEN
         O_ERR_MSG := 'Y';
         dbms_output.put_line('Unidentified user');
      END IF;
      IF L_code = '1' THEN                                       -- If user id is planner
           O_rol := '1';
         dbms_output.put_line('User is PLANNER (ROLE 1)');
            SELECT r.ORD_APPR_AMT                                   -- will be checking the approval limit of that role
            INTO L_approval_limit          
            FROM  RTK_ROLE_PRIVS r, CODE_DETAIL c
            WHERE r.ROLE = c.CODE_DESC
            AND c.CODE = L_code;
         dbms_output.put_line('Approval limit is :' || L_approval_limit);
            OPEN C_PO_AMT;                                          -- OTB check based on dept,class
            LOOP
              FETCH C_PO_AMT into c3;
                    EXIT when c_PO_AMT%notfound;
              dbms_output.put_line('Entered 1st loop');
                    OPEN C_OTB_CALCULATE(c3.order_type, TO_DATE(c3.po_month,'MONYYYY'), c3.dept, c3.class);
                    LOOP
                   dbms_output.put_line('Entered 2nd loop');
                         FETCH C_OTB_CALCULATE into c2;
                            EXIT WHEN C_OTB_CALCULATE%notfound;
                            L_amt := c3.PO_AMT;
                   dbms_output.put_line('PO AMT IS:' || L_amt);
                   IF c3.PO_AMT > L_approval_limit THEN    -- Checking whether amount greater than approval lim
                        dbms_output.put_line('Approval limit exceeded');
                                 L_app_check := 1;
                                    O_app_check := 'T';
                                    O_v_app_check := 1;
                        O_amt := L_amt;
                        dbms_output.put_line('Approval check is:' || L_app_check);
                        dbms_output.put_line('Approval check exceeded? :' || O_app_check);
                        dbms_output.put_line('Parameter for Approval check is:' || O_v_app_check);
                            ELSIF C3.PO_AMT <= L_approval_limit then
                        dbms_output.put_line('Approval limit not exceeded');
                        dbms_output.put_line('Approval check is:' || L_app_check);
                        dbms_output.put_line('Parameter for Approval check is:' || O_v_app_check);
                                    L_app_check := 0;
                                    O_v_app_check := 0;
                            END IF;
                   IF c3.PO_AMT > c2.OTB_AMT1 THEN         -- Checking whether amount greater than OTB amount
                        dbms_output.put_line('OTB AMT is :' || c2.otb_amt1);
                        dbms_output.put_line('OTB limit Exceeded');
                                 L_otb_check := 1;
                                    O_app_check := 'T';
                                    O_v_otb_check := 1;
                        O_amt := L_amt;
                        dbms_output.put_line('OTB check is:' || L_otb_check);
                        dbms_output.put_line('OTB check exceeded? :' || O_app_check);
                        dbms_output.put_line('Parameter for OTB check is:' || O_v_otb_check);
                            ELSIF C3.PO_AMT <= C2.OTB_AMT1 THEN
                        dbms_output.put_line('OTB limit not exceeded');
                                    L_otb_check := 0;
                                    O_v_otb_check := 0;
                        dbms_output.put_line('OTB check is:' || L_otb_check);
                        dbms_output.put_line('Parameter for OTB check is:' || O_v_otb_check);
                            END IF;
                    END LOOP;
                    CLOSE C_OTB_CALCULATE;
            END LOOP;
            CLOSE c_PO_AMT;
         IF L_app_check = 0 and L_otb_check = 0 then            
              SELECT ORDER_NO, STATUS                     -- Checking whether there is a duplicate order number
              INTO L_order_no, L_status                    
              FROM AFE_POAPPROVAL
              WHERE ORDER_NO = I_ord_num;
              IF L_status = 'O' then                         -- If found and its stauts is open, update the record by changing the status column to "C"
                   UPDATE AFE_POAPPROVAL
                   SET STATUS = 'C'
                   WHERE ORDER_NO = I_ord_num;
                   COMMIT;
              END IF;
              INSERT INTO AFE_POAPPROVAL                    -- Inserting the record into AFE_POAPPROVAL when OTB and approval limit is below the PO amt
                    VALUES (I_ord_num, 1,'O',I_u_id,'ROLE1','N','N', SYSDATE,'S', L_amt);
              dbms_output.put_line('Inserted Record into AFE_POAPPROVAL');
                    COMMIT;                
            END IF;
          ELSIF L_code = '2' THEN                            -- If user id is category manager
         dbms_output.put_line('User is Category manager (ROLE 2)');          
               O_rol := '2';
                  SELECT r.ORD_APPR_AMT                                        -- will be checking the approval limit of that role
                  INTO L_approval_limit          
                  FROM  RTK_ROLE_PRIVS r, CODE_DETAIL c
                  WHERE r.role = c.CODE_DESC
                  AND c.CODE = L_code;
               dbms_output.put_line('Approval limit is :' || L_approval_limit);
                  OPEN c_PO_AMT;                                          -- OTB check based on dept,class
                  LOOP
                       FETCH c_PO_AMT into c3;
                    EXIT when c_PO_AMT%notfound;
              dbms_output.put_line('Entered 1st loop');
                    OPEN C_otb_CALCULATE(c3.order_type, TO_DATE(c3.po_month,'MONYYYY'), c3.dept, c3.class);
                    LOOP
                         FETCH C_OTB_CALCULATE into c2;
                            EXIT WHEN C_OTB_CALCULATE%notfound;
                   dbms_output.put_line('Entered 2nd loop');
                            L_amt := c3.PO_AMT;
                   dbms_output.put_line('PO AMT is:' || L_amt);
                            IF c3.PO_AMT > L_approval_limit THEN    -- Checking whether amount greater than approval limit
                        dbms_output.put_line('Approval limit exceeded');
                                 L_app_check := 1;
                                    O_app_check := 'T';
                                    O_v_app_check := 1;
                        O_amt := L_amt;
                        dbms_output.put_line('Approval check is:' || L_app_check);
                        dbms_output.put_line('Approval check exceeded? :' || O_app_check);
                        dbms_output.put_line('Parameter for Approval check is:' || O_v_app_check);
                            ELSE
                        dbms_output.put_line('Approval limit not exceeded');
                                    L_app_check := 0;
                                    O_v_app_check := 0;
                        dbms_output.put_line('Approval check is:' || L_app_check);
                        dbms_output.put_line('Parameter for Approval check is:' || O_v_app_check);
                            END IF;
                            L_otb_amt1 := c2.OTB_AMT1;
                   dbms_output.put_line('Selecting tolerance limit');
                            SELECT cd.code_desc                                     -- will be chekcing the tolerance limit
                            INTO L_tolerance_limit
                            FROM CODE_DETAIL cd, CODE_HEAD ch
                            WHERE ch.CODE_TYPE = cd.code_type
                            AND ch.CODE_TYPE = 'OTBT';
                            L_tolerance_limit := to_number(L_tolerance_limit);
                   dbms_output.put_line('Tolerance limit is:' || L_tolerance_limit);
                            L_otb_limit := c2.OTB_AMT1-(c2.OTB_AMT1 * (1- (L_tolerance_limit/100))); -- Will be calculating the tolerance limit
                   dbms_output.put_line('OTB AMT is :' || L_otb_amt);
                            IF c3.PO_AMT > L_otb_limit THEN         -- Checking whether amount greater than OTB amount
                        dbms_output.put_line('OTB limit exceeded');
                                 L_otb_check := 1;
                                    O_app_check := 'T';
                                    O_v_otb_check := 1;
                        O_amt := L_amt;
                        dbms_output.put_line('OTB check is:' || L_otb_check);
                        dbms_output.put_line('OTB check exceeded? :' || O_app_check);
                        dbms_output.put_line('Parameter for OTB check is:' || O_v_otb_check);
                            ELSE
                        dbms_out.put_line('OTB Limit not exceeded');
                                    L_otb_check := 0;
                                    O_v_otb_check := 0;
                        dbms_output.put_line('OTB check is:' || L_otb_check);
                        dbms_output.put_line('Parameter for OTB check is:' || O_v_otb_check);
                            END IF;
                    END LOOP;
                    CLOSE C_OTB_CALCULATE;
                  END LOOP;
                  CLOSE c_PO_AMT;
                  IF L_app_check = 0 and L_otb_check = 0 THEN            
                    SELECT ORDER_NO, STATUS                     -- Checking whether there is a duplicate order number
              INTO L_order_no, L_status
              FROM AFE_POAPPROVAL
              WHERE ORDER_NO = I_ord_num;
              IF L_status = 'O' then                         -- If found and its stauts is open, update the record by changing the status column to C
                   UPDATE AFE_POAPPROVAL
                   SET STATUS = 'C'
                   WHERE ORDER_NO = I_ord_num;
                   COMMIT;
              END IF;
                    INSERT INTO AFE_POAPPROVAL                    -- Inserting the record into AFE_POAPPROVAL when OTB and approval limit is below the PO amt
                    VALUES (I_ord_num, 1,'O',I_u_id,'ROLE2','N','N', SYSDATE, 'S', L_amt);                 
                    COMMIT;
              dbms_output.put_line('Inserted Record into AFE_POAPPROVAL');
                  END IF;
           ELSIF L_code = '3' THEN                                         -- If user id is category head
         dbms_output.put_line('User is Category Head (ROLE3)');
                O_rol := 3;
            OPEN c_PO_AMT;                                          -- OTB check based on dept,class
            LOOP
                 FETCH c_PO_AMT into c3;
                    EXIT when c_PO_AMT%notfound;
              dbms_output.put_line('Entered 1st loop');
                    OPEN C_OTB_CALCULATE(c3.order_type, to_date(c3.po_month,'MONYYYY'), c3.dept, c3.class);
                    LOOP
                         FETCH C_OTB_CALCULATE into c2;
                            EXIT WHEN C_OTB_CALCULATE%notfound;
                   dbms_output.put_line('Entered 2nd loop');     
                            L_amt := c3.PO_AMT;
                   dbms_output.put_line('PO AMT is :' || L_amt);     
                            IF c3.PO_AMT > c2.OTB_AMT1 THEN         -- Checking whether amount greater than OTB amount
                        dbms_output.put_line('OTB AMT is :' || c2.otb_amt1);
                        dbms_output.put_line('OTB Limit exceeded');
                                 L_otb_check := 1;
                                    O_app_check := 'T';
                                    O_v_otb_check := 1;                                        
                        O_amt := L_amt;
                        dbms_output.put_line('OTB check is:' || L_otb_check);
                        dbms_output.put_line('OTB check exceeded? :' || O_otb_check);
                        dbms_output.put_line('Parameter for OTB check is:' || O_v_otb_check);
                            ELSE
                        dbms_output.put_line('OTB limit not exceeded');
                                    L_otb_check := 0;
                                    O_v_otb_check := 0;
                        dbms_output.put_line('OTB check is:' || L_otb_check);
                        dbms_output.put_line('Parameter for OTB check is:' || O_v_otb_check);
                            END IF;
                    END LOOP;
                    CLOSE C_OTB_CALCULATE;
            END LOOP;
            CLOSE c_PO_AMT;
            IF L_otb_check = 0 THEN                                
    IF L_otb_check = 0 THEN                                
              OPEN C_RECORD_CHECK;
              LOOP
                   FETCH C_RECORD_CHECK INTO L_RECORD_CHECK;
                   EXIT WHEN C_RECORD_CHECK%notfound;
                   IF C_RECORD_CHECK%FOUND THEN
                        UPDATE AFE_POAPPROVAL
                        SET STATUS = 'C'
                        WHERE ORDER_NO = I_ord_num;
                        COMMIT;
                   END IF;
              END LOOP;
              INSERT INTO AFE_POAPPROVAL                    -- Inserting the record into AFE_POAPPROVAL when otb and approval limit is below the po amount
                     VALUES (I_ord_num, 1,'O',I_u_id,'ROLE3','Y','N', SYSDATE,'S', L_amt);
                     COMMIT;
              dbms_output.put_line('Inserted Record into AFE_POAPPROVAL');
            END IF;
         END IF;
      EXCEPTION
         WHEN OTHERS THEN
            O_error_message := SQL_LIB.CREATE_MSG('PACKAGE_ERROR',
                                                   SQLERRM,
                                                   L_program,
                                                   TO_CHAR(SQLCODE));
      END AFE_CHECK_SUBMIT;
    /Now i am executing the procedure ...
    SQL>SQL> @OUT_SUBMIT;
    Enter value for user: RMS12DEV
    old 12: o_user :='&user';
    new 12: o_user :='RMS12DEV';
    Enter value for order: 6139
    old 13: o_order :=&order;
    new 13: o_order :=6139;
    User id is :RMS12DEV
    Selecting the role
    No Record in table
    Role is :
    o_rol:
    O_app_check:
    O_v_app_check:
    O_v_otb_check:
    O_amt:
    O_ERR_MSG: N
    O_error_message:
    PL/SQL procedure successfully completed.
    If you have looked at the output .. after the variable is intialized to 'N', still I am getting msgs displayed .. Hope this is clear .. Now can you suggest the solution...
    Regards
    Message was edited by:
    Seshu
    Message was edited by:
    Seshu

  • Best way to return large resultsets

    Hi everyone,
    I have a servlet that searches a (large) database by complex queries and sends the results to an applet. Since the database is quite large and the queries can be quite general, it is entirely possible that a particular query can generate a million rows.
    My question is, how do I approach this problem from a design standpoint? For instance, should I send the query without limits and get all the results (possibly a million) back? Or should I get only a few rows, say 50,000, at a time by using the SQL limit construct or some other method? Or should I use some totally different approach?
    The reason I am asking this question is that I have never had to deal with such large results and the expertise on this group will help me avoid some of the design pitfalls at the very outset. Of course, there is the question of whether the servlet should send so may results at once to the applet, but thats probably for another forum.
    Thanks in advance,
    Alan

    If you are using a one of the premiere databases (Oracle, SQL Server, Informix) I am fairly confident that it would be best to allow the database to manage both the efficiency of the query, and the efficiency of the transport.
    QUERY EFFICIENCY
    Query efficiences in all databases are optimized by the DBMS to a general algorithm. That means there are assumptions made by the DBMS as to the 'acceptable' number of rows to process, the number of tables to join, the number of rows that will be returned, etc. These general algorithms do an excellent job on 95+% of queries run against database. However, f you fall outside the bounds of these general algorithms, you will run into escalating performance problems. Luckily, SQL syntax provides enourmous flexibility in how to get your data from the database, and you can code the SQL to 'help' the database do a better job when SQL performance becomes a problem. On the extreme, it is possible that you will issue a query that overwhelms the database, and the physical resources available to the database (memory, CPU, I/O channels, etc). Sometimes this can happen even when a ResultSet returns only a single row. In the case of a single row returned, it is the intermediate processing (table joins, sorts, etc) that overwhelms the resources. You can help manage the memory resource issue by purchasing more memory (obviously), or re-code the SQL to a more apply a more efficent algorithm (make the optimizer do a better job), or you may as a last resort, have to break the SQL up into seperate SQL statements, using more granual approach (this is your "where id < 1000"). BTW: If you do have to use this approach, in most casees using the BETWEEN is often more efficient.
    TRANSPORT
    Most if not all of the JDBC drivers return the ResultSet data in 'blocks' of rows, that are delivered on an as needed basis to your program. Some databases alllow you to specify the size of these 'blocks' to aid in the optimization of your batch style processes. Assuming that this is true for your JDBC driver, you cannot manage it better than the JDBC driver implementation, so you should not try. In all cases, you should allow the database to handle as much of the data manipulation and transport logic as possible. They have 1000's of programmers working overtime to optimzie that code. They just have you out numbered, and while it's possible that you can code an efficiency, it's possible that you will be unable to take advantage of future efficiencies within the database due to your proprietary efficiencies.
    You have some interesting, and important decisions to make. I'm not sure how much control of the architecture is available, but you may want to consider alternatives to moving these large amounts of data around through the JDBC architecture. Is it possible to store this information on the server, and have it fetched using FTP or some other simple transport? Far less CPU usage, and more efficient use of your bandwith.
    So in case it wasn't clear, no, I don't think you should break up the SQL initially. If it were me, I would probably spend the time in putting out some metic based information to allow you to better judge where you are having slow downs when or if any should occur. With something like this, I have seen I.T. spend hours and hours tuning SQL just to find out that the network was the problem (or vice versa). I would also go ahead and run the expected queries outside of application and determine what kind of problems there are before coding of the application is finished.
    Hey, this got a bit wordy, sorry. Hopefully there is something in here that can help you...Joel

  • Best way to transfer large datasets between actors (Actor framework)

    Hi everyone
    I am in the planning / design phase of a larger application for which I wish to use the Actor Framework. It seems like a good "design pattern", easy for multiple developers to work on, easy to expand and easy to maintain.
    In this application I need to transfer data betweeen actors/modules at a considerable rate. The data is the continous measurements from a DAQ device (or multiple devices) sampling at 200kHz. That's 200 kHz * 8 byte = 1.5 Mb/s per device.
    There is no way this is done using the messages of the actor framework - those messages are designed to signal start, stop, select tasks etc. within the application. So how to transfer that amount of data between actors?
    I've thought about using TCP/IP on localhost - this could also easily be expanded to allow different parts of the program to run on different machines on a network. I've even tested it and it works quite well. But I would like to hear some opinions or alternatives before I decide to go with this solution. Any thoughts or alternatives?
    Thanks
    Jonas

    JonasCJ wrote:
    Could this be done without TCP/IP and just a LABVIEW queue? Passing the queue in a message from one actor to another?
    If it's in the same process then yes, and it would be more efficient, because with TCP you have to create a copy when converting the data to a string, another copy when receiving and a third one when converting back. Unless you really are planning on distribtuing it, I would suggest avoiding that. Sidebar - AQ has been talking about networked actors and I believe there should even be an experimental branch in the AF group in the community area. You might want to check that out.
    Incidentally, if you are planning on splitting it and don't actually need the real time processing, you might consider saving the data to a network drive and then simply having the other side loading the data from the file. It should be simpler.
    Try to take over the world!

  • What is the best way to zoom in and out of pictures, documentary style?

    I'm new to Adobe Premiere and I was looking to a make a mock documentary in which there would be slow zoom in's of photo's while the narrator is talking. If you could imagine what I'm talking about.
    Could anyone tell me how you would accomplish that?
    Thanks

    It looks like my image has disappeared from my earlier post. I will link to it again at the end of this post. 
    Ann, I do not understand what you are disagreeing with. You posted a link to a tutorial. I watched it. I don't mean to be troublesome, but Jeff never touched the anchor point once. He pointed it out so people would know what the symbol was, but he never changed the value. If you prefer to use it, that's fine. I merely suggested that doing it the way Jeff did it in the tutorial was the easiest way for most people to begin. You are not a beginner. The fact that you have different ways to do things is not at all unusual. I would be shocked if professionals did everything the basic way that a beginner would do it.
    Yes, of course my tutorials are ancient. I don't disagree with that. However, I think I did a pretty decent job on keyframes way back then. I don't believe that anything has changed regarding keyframes between 1.5 and CS6. There are certainly more fixed effects, but the keyframes act the same way.
    Perhaps I should not have poked fun at Jeff since you seem to have taken it personally. I have never met him, and all I know is that he is a good teacher, as I said in my earlier post. I don't apologize for finding it funny that he missed something simple. We all miss things . It happens. I do apologize for poking fun at him. And if he felt offended, I am sorry. That wasn't the purpose.
    I never suggested that a new user should watch my tutorials, by the way. I know there are people who do watch them because I still get royalties even after all these years (Thank you Lynda for making that possible), and I assume that they have much earlier versions that they can't afford to upgrade. And if they are editing DV, perhaps there is no need to upgrade. I can certainly see why people would want to upgrade, but I have met some pretty poor people in my life who use some really old, donated computers, and who reuse DV tapes over and over again. Not everybody upgrades once they find something that works for them. A few years back I bought a box of new DV tapes to donate on one of my trips and you would have thought that they were made out of gold the way they were received.
    But Jeff is not a new user. I believe that as a fellow Lynda.com author, it would not be considered out of place for him to have watched all of the older Lynda.com tutorials in order to have a better grasp on what earlier authors did right, and what they did wrong. What made things easier to understand, and what just caused more confusion. I don't know that he did or didn't. I merely poked fun at his trouble finding the little white dots.
    I admit that I am not a professional videographer or photographer. In fact, I will say that I am merely a dilettante who has been lucky enough to be in the right place at the right time to make some money producing tutorials, helping revise books, and reviewing other people's books and tutorials for possible errors, and to make sure that the instructions can be followed to achieve the stated goal. I am a mere technician and a fairly decent researcher. I am not at all sure I have an artistic bone in my body. But I am a pretty good teacher and someone to whom an artist might turn for technical advise. So don't think that throwing the word "professional" around is going to hurt my feelings in any way, or make me think that someone must be technically more adept because they shoot weddings, or commercials, or even feature films. Well, maybe feature films I would hope that they are considerably more artistic and imaginative than I am, but possibly not that much more technically competant.
    Back to the little white dots. Most of the time, the image is such that the dots don't hide from you. Now and then, the image gets pretty busy and it is difficult to see. When that happens, looking at just the bounding box and the curves makes it easier. Once it a while it doesn't help to make the image bigger. So this is the workaround. Not the main way to do it. Just when the problem that Jeff was happening in the tutorial I watched comes about.
    By the way, as a side note, Lynda Weinman is a delightful person. I can't begin to tell you how thrilled I was when I got to go to lunch with her once during the week I spent in the Lynda.com soundbooth working on my tutorials. She is just as pleasant as can be. I wish I might have gotten a chance to continue to do them over the years, but the other authors have all done an excellent job. And as I mentioned before, I am a bit dry.
    The subscription to Lynda.com is worth every penny when you consider the value that Lynda.com offers over YouTube and even Creative Cow tutorials.

  • Best way to make a burn out effect like in this film?

    I am trying to figure out how to make the same kind of film burn out effect like this short film has in the beginning.
    Check out the beginning of this short film. The yellow/red burn outs that are on the first couple of clips, what is the easiest way to make them in Motion (or FCP)?
    I've been fumbling a bit with the "Cool" emitter in Motion, but can't get the same feel.
    Please give me some tips, if you can.
    Oh and here is a link for the short film I am referring to:
    http://frenchquarterfeatures.com/movies/eighteen_seconds.640.mov
    Thanks in advance...

    The effect emulates fogging of the film, as if someone opened the camera before the film had been taken up onto the reel or into the magazine.
    I'd download that clip, convert it to a useable format and play with keying filters till I got mostly the flashes. Then I'd start adding masked layers and shapes to fill in the rest or to cover up residual hunks of the film's stars. Precompose or render. This will give you a place to start. Use it to blend in a moving red-yellow image.
    Or look at ARTBEATS site and see what they've got for film burn effects (not Ken Burns effects). I'll be tthta's where this filmmaker got his/hers.
    bogiesan

Maybe you are looking for

  • 500 error while accessing a jsp using tiles tags

    Hi all, when im trying to access a jsp which makes use of tiles tags, im getting the following error. status 500: org.apache.jasper.JasperException: The absolute uri: http://struts.apache.org/tags-tiles cannot be resolved in either web.xml or the jar

  • Integration between SRM-Confirmation and MM-FI Closing in R/3

    We are currently using SRM 5.0 through the Classic-Extended Scenario. For some of our Company Codes in R/3, Monthly closing is performed before the actual end of the month ( generally on the 27th or 28th day of the month) by blocking posting in R/3-F

  • Configure Sun Directory Server 6.3 with SSL in OIM 9.1.0.2

    Hi, I am using OIM 9.1.0.2. i want to Provision User to Directory Server 6.3 with SSL confiuration Can anyone tell me the steps for configuring the Certificate import, etc.. followed SJSDS_904120 doc but there is no info for DSEE 6.3 in it. Regards,

  • Bootcamp and Win7 lagging?

    Hi I'm the lucky owner of a 2012 MacBook Pro 15 2,4GHz Intel CPU, 16Gb 1333MHz RAM and the 1Gb ATI HD6770M graphics card. Originally it had the Toshiba 128Gb SSD disk where I was running bootcamp with OS X Lion 10.7 and Windows 7 Ultimate 64bit no pr

  • Parking Document & Workflow

    Dear All! I ahve following requirement for approving the invoice! User 1 Park the Invoice , Then he will forward to another user 2. User 2 must  have three  option ( Forward, Revert and  Reject ) after forwarding to User 3, He must have only one opti