For loop to iterate through temp table in store procedure in pl/sql

Hi,
how to create For loop to iterate through the temporary table in the store procedure?

Neha RK wrote:
hi,
its not working , i need to check each record of table and do some task using if else loop inside that for..
if not possible to loop each row of table using for then how to use while loop.
please helpWhat's not working? We haven't got psychic powers so we can't see the code you say isn't working.
Please provide more information like create table statements, insert statements with test data, the code you've tried
and the output you are expecting from the input data.
Read {message:id=9360002} and follow the advice there.

Similar Messages

  • HELP! FOR LOOP TO SCROLL THROUGH TABLE AND CREATE DATABASE LINK

    Hi,
    Here's the scenario, not much of a PL programmer, just basic SQL so really need some help people!
    I have 2 tables. 1 contains list of DB's and the other contains rules to follow.
    I need to create a loop that goes through the table containing the DB's and on each row a DB link is created (Only 1 link allowed!)
    Once created, the schema currently logged in with also has an account on the linked DB in order to run scripts- The scripts are stored centrally hence the requirement for the link to the target DB.
    There are numerous scripts that need to be executed and can all be called from 1 script, once executed the loop exists and the database link needs to be dropped.
    Once dropped, the first loop continues, creating a DB link for the next DB listed in the table (and all the scripts are fired again)
    This continues against all the DB's listed in the table.

    Hi BlueShadow,
    Thanks again for the response, you've hit the nail on the head. SQL scripts on a unix server, a loop goes through a table 1 at a time. Each row gets a link created and then all the scripts stored on the server are executed against the db linked to. So I'm assuming this is a loop within a loop.
    1 loop to go through the table to create the link and then another loop within once connected to execute all the scripts against the connected DB. Once the scripts are run, the loop exits and moves onto the next server and so on until all the servers have the scripts are run.
    It's PL/SQL scripts we're after and not shell scripts as this would free us from the OS constraints.
    We have to drop the links due to security. Any idea on o

  • User define table and store procedure install

    Hi there,
    I like to deploy an addon, there are User define tables and store procedure need add to database, I wonder which chance is properly to add them, if add these user define objects in time of install, we can not get the enough information that connect to SQL server, and also create UDT need DIAPI. if put create UDT and UDsp in addon program, the problem is which DIAPI funciton or object can execute create store procedure SQL string.
    Thanks for any help.
    Lanjun

    R. Schwachofer,
    Thank you very much,
    the way call isqlw.exe to run SQL script is a good way when install, but I confuse with two questions about this way. first, run isqlw.exe should provid loginid and password of SQL server, these two information need additional install dialog to get; second if use isqlw.exe the store procedure only create to the current company database, when create new compay DB the store procedure does not exist in new DB.
    so I still do not know which way is the proper way to create SP for addon.
    Thanks in advance.
    Lanjun

  • Error for datawindow get data from temp table with SP

    I create a SP to produce results. In this SP, results recorded in a temp table #mytemp. The final sql in this sp is like:
    select * from #mytemp
    Then I create datawindow to display data from this sp and got following error:
    Number 277 Select Error: there was a transactin active when exiting the stored procedure 'myproc'. The temporary table '#mytemp' was dropped in this transaction either explicitly or implicitly. This transaction has been aborted to prevent database corruption.
    How to resolve this problem?

    Sorry but could not reproduce the problem with the following products:
    PB 12.5.2 build 5652
    ASE client 15.7 EBF22688
    ASE server 15.7 EBF 19496
    Tested with ASE and SYC database profiles
    // Profile ASE
    SQLCA.DBMS = "ASE Adaptive Server Enterprise"
    SQLCA.Database = "repro"
    SQLCA.LogPass = <**********>
    SQLCA.ServerName = ""
    SQLCA.LogId = "sa"
    SQLCA.AutoCommit = False
    SQLCA.DBParm = ""
    // Profile SYC
    SQLCA.DBMS = "SYC Adaptive Server Enterprise"
    SQLCA.Database = "repro"
    SQLCA.LogPass = <**********>
    SQLCA.ServerName = "xxxxxxxx"
    SQLCA.LogId = "sa"
    SQLCA.AutoCommit = False
    SQLCA.DBParm = "Release='15'"
    Below is the source of my stored procedure.
    Prior to run the script, execute a data pipeline to create ASA tables (EAS Demo DB V12.5) department and employees into your ASE server
    CREATE PROCEDURE mySP
    AS
        BEGIN
           create table #employee_working (
             emp_id  int not null,
             manager_id  int null,
             emp_fname   varchar(20)    not null,
             emp_lname   varchar(20)    not null,
             dept_id int not null,
             dept_name varchar(40) not null )
          insert into #employee_working
             select employee.emp_id, employee.manager_id, employee.emp_fname, employee.emp_lname, employee.dept_id, department.dept_name
             from employee , department
             where employee.dept_id = department.dept_id
        select #employee_working.emp_id, #employee_working.manager_id, #employee_working.emp_fname, #employee_working.emp_lname,
        #employee_working.dept_id, #employee_working.dept_name
            from #employee_working
        END
    Jacob

  • Visual Basic, DAO, Temp tables in stored procedures

    Client code currently uses DAO with SQLPassthrough option in VB to connect to SQl 6.5 db.
    I migrated all stored procedures with default options except Oracle 8i temp tables. For every procedure a package and a procedure was created. We use SQL server temporary tables extensively in a few hundred stored procedures. The ref cursor created refers to the temporary table. While migratiing, Create table statement is commented. How are SQL6.5 equivalent of temp tables handled in Oracle? Is there an alternative to temp tables?
    I also migrated to another oracle db using the INOUT type for stored procedures. This time only procedures were created. Can these procedures return a record set in DAO with SQLPAssthrough?
    How do you call a procedure using DAO in VB to get recordsets?
    What is the best way to migrate to Oracle with minimal client code changes?
    Thank you in advance.
    Umesh
    null

    Karthick_Arp wrote:
    BluShadow wrote:
    I agree with Karthick, there's no need for a temporary table in this situation.
    And to add, temporary tables should not be created at runtime, they should be part of the initial design of the database, created once and used as needed. Creating them at runtime is just wrong.The problem is the name oracle has given to GTT. The word Temporary mislead lot of SQL Server developers and they think its something same as the temporary table used in SQL Server :)Yeah, Ingres does something similar to SQL Server too, in that you can create a temporary table (Ingres assigned it a unique name and tells you what it is), and you set an expiry time on it (i.e. set it to expire in 1 days time), and then a background process is supposed to clean up the tables that have expired. Unlike Oracle, they are not session specific, but become visible to all once created.
    I think there's room for both types of temporary table, but Oracle's does the job (except when you want to use them from a stateless application front end).

  • Insert and update same record of table using store procedure in oracle 10g

    Hi,
    I am using oracle sql developer for this.
    I have created Store procedure which run after every 30mins of interval.
    the problem is Ii need to insert data for first time of day then later that same record should update for particular field(here its plan code).
    if new field is coming (if new plan code is generated) then it should insert data and again update same for interval.
    means for each plan individual record(i.e. plan wise summary) should be there for only a day. next day new record for same plan.

    Hi,
    You should use Merge like shown below:-
    Merge into original_table a
    using second_table b
    on (a.primary_key=b.primary_key and a.primary_key........)
    when match then
    update set column_list=b.column_list
    when not match then
    isert into (column list)
    values(a.column_list)If you dont know much about merge then follow below link..
    http://www.oracle-developer.net/display.php?id=203
    http://www.oracle-base.com/articles/10g/merge-enhancements-10g.php

  • Need to increase performance-bulk collect in cursor with limit and in the for loop inserting into the trigger table

    Hi all,
    I have a performance issue in the below code,where i am trying to insert the data from table_stg into target_tab and in parent_tab tables and then to child tables via cursor with bulk collect .the target_tab and parent_tab are huge tables and have a row wise trigger enabled on it .the trigger is mandatory . This timetaken for this block to execute is 5000 seconds.Now my requirement is to reduce it to 5 to 10 mins.
    can someone please guide me here.Its bit urgent .Awaiting for your response.
    declare
    vmax_Value NUMBER(5);
      vcnt number(10);
      id_val number(20);
      pc_id number(15);
      vtable_nm VARCHAR2(100);
      vstep_no  VARCHAR2(10);
      vsql_code VARCHAR2(10);
      vsql_errm varchar2(200);
      vtarget_starttime timestamp;
      limit_in number :=10000;
      idx           number(10);
              cursor stg_cursor is
             select
                   DESCRIPTION,
                   SORT_CODE,
                   ACCOUNT_NUMBER,
                     to_number(to_char(CORRESPONDENCE_DATE,'DD')) crr_day,
                     to_char(CORRESPONDENCE_DATE,'MONTH') crr_month,
                     to_number(substr(to_char(CORRESPONDENCE_DATE,'DD-MON-YYYY'),8,4)) crr_year,
                   PARTY_ID,
                   GUID,
                   PAPERLESS_REF_IND,
                   PRODUCT_TYPE,
                   PRODUCT_BRAND,
                   PRODUCT_HELD_ID,
                   NOTIFICATION_PREF,
                   UNREAD_CORRES_PERIOD,
                   EMAIL_ID,
                   MOBILE_NUMBER,
                   TITLE,
                   SURNAME,
                   POSTCODE,
                   EVENT_TYPE,
                   PRIORITY_IND,
                   SUBJECT,
                   EXT_PRD_ID_TX,
                   EXT_PRD_HLD_ID_TX,
                   EXT_SYS_ID,
                   EXT_PTY_ID_TX,
                   ACCOUNT_TYPE_CD,
                   COM_PFR_TYP_TX,
                   COM_PFR_OPT_TX,
                   COM_PFR_RSN_CD
             from  table_stg;
    type rec_type is table of stg_rec_type index by pls_integer;
    v_rt_all_cols rec_type;
    BEGIN
      vstep_no   := '0';
      vmax_value := 0;
      vtarget_starttime := systimestamp;
      id_val    := 0;
      pc_id     := 0;
      success_flag := 0;
              vstep_no  := '1';
              vtable_nm := 'before cursor';
        OPEN stg_cursor;
              vstep_no  := '2';
              vtable_nm := 'After cursor';
       LOOP
              vstep_no  := '3';
              vtable_nm := 'before fetch';
    --loop
        FETCH stg_cursor BULK COLLECT INTO v_rt_all_cols LIMIT limit_in;
                  vstep_no  := '4';
                  vtable_nm := 'after fetch';
    --EXIT WHEN v_rt_all_cols.COUNT = 0;
        EXIT WHEN stg_cursor%NOTFOUND;
    FOR i IN 1 .. v_rt_all_cols.COUNT
      LOOP
       dbms_output.put_line(upper(v_rt_all_cols(i).event_type));
        if (upper(v_rt_all_cols(i).event_type) = upper('System_enforced')) then
                  vstep_no  := '4.1';
                  vtable_nm := 'before seq sel';
              select PC_SEQ.nextval into pc_id from dual;
                  vstep_no  := '4.2';
                  vtable_nm := 'before insert corres';
              INSERT INTO target1_tab
                           (ID,
                            PARTY_ID,
                            PRODUCT_BRAND,
                            SORT_CODE,
                            ACCOUNT_NUMBER,
                            EXT_PRD_ID_TX,         
                            EXT_PRD_HLD_ID_TX,
                            EXT_SYS_ID,
                            EXT_PTY_ID_TX,
                            ACCOUNT_TYPE_CD,
                            COM_PFR_TYP_TX,
                            COM_PFR_OPT_TX,
                            COM_PFR_RSN_CD,
                            status)
             VALUES
                            (pc_id,
                             v_rt_all_cols(i).party_id,
                             decode(v_rt_all_cols(i).product_brand,'LTB',2,'HLX',1,'HAL',1,'BOS',3,'VER',4,0),
                             v_rt_all_cols(i).sort_code,
                             'XXXX'||substr(trim(v_rt_all_cols(i).ACCOUNT_NUMBER),length(trim(v_rt_all_cols(i).ACCOUNT_NUMBER))-3,4),
                             v_rt_all_cols(i).EXT_PRD_ID_TX,
                             v_rt_all_cols(i).EXT_PRD_HLD_ID_TX,
                             v_rt_all_cols(i).EXT_SYS_ID,
                             v_rt_all_cols(i).EXT_PTY_ID_TX,
                             v_rt_all_cols(i).ACCOUNT_TYPE_CD,
                             v_rt_all_cols(i).COM_PFR_TYP_TX,
                             v_rt_all_cols(i).COM_PFR_OPT_TX,
                             v_rt_all_cols(i).COM_PFR_RSN_CD,
                             NULL);
                  vstep_no  := '4.3';
                  vtable_nm := 'after insert corres';
        else
              select COM_SEQ.nextval into id_val from dual;
                  vstep_no  := '6';
                  vtable_nm := 'before insertcomm';
          if (upper(v_rt_all_cols(i).event_type) = upper('REMINDER')) then
                vstep_no  := '6.01';
                  vtable_nm := 'after if insertcomm';
              insert into parent_tab
                 (ID ,
                 CTEM_CODE,
                 CHA_CODE,            
                 CT_CODE,                           
                 CONTACT_POINT_ID,             
                 SOURCE,
                 RECEIVED_DATE,                             
                 SEND_DATE,
                 RETRY_COUNT)
              values
                 (id_val,
                  lower(v_rt_all_cols(i).event_type), 
                  decode(v_rt_all_cols(i).product_brand,'LTB',2,'HLX',1,'HAL',1,'BOS',3,'VER',4,0),
                  'Email',
                  v_rt_all_cols(i).email_id,
                  'IADAREMINDER',
                  systimestamp,
                  systimestamp,
                  0);  
         else
                vstep_no  := '6.02';
                  vtable_nm := 'after else insertcomm';
              insert into parent_tab
                 (ID ,
                 CTEM_CODE,
                 CHA_CODE,            
                 CT_CODE,                           
                 CONTACT_POINT_ID,             
                 SOURCE,
                 RECEIVED_DATE,                             
                 SEND_DATE,
                 RETRY_COUNT)
              values
                 (id_val,
                  lower(v_rt_all_cols(i).event_type), 
                  decode(v_rt_all_cols(i).product_brand,'LTB',2,'HLX',1,'HAL',1,'BOS',3,'VER',4,0),
                  'Email',
                  v_rt_all_cols(i).email_id,
                  'CORRESPONDENCE',
                  systimestamp,
                  systimestamp,
                  0); 
            END if; 
                  vstep_no  := '6.11';
                  vtable_nm := 'before chop';
             if (v_rt_all_cols(i).ACCOUNT_NUMBER is not null) then 
                      v_rt_all_cols(i).ACCOUNT_NUMBER := 'XXXX'||substr(trim(v_rt_all_cols(i).ACCOUNT_NUMBER),length(trim(v_rt_all_cols(i).ACCOUNT_NUMBER))-3,4);
              insert into child_tab
                 (COM_ID,                                            
                 KEY,                                                                                                                                            
                 VALUE)
              values
                (id_val,
                 'IB.Correspondence.AccountNumberMasked',
                 v_rt_all_cols(i).ACCOUNT_NUMBER);
             end if;
                  vstep_no  := '6.1';
                  vtable_nm := 'before stateday';
             if (v_rt_all_cols(i).crr_day is not null) then 
              insert into child_tab
                 (COM_ID,                                            
                 KEY,                                                                                                                                            
                 VALUE)
              values
                (id_val,
                 --'IB.Correspondence.Date.Day',
                 'IB.Crsp.Date.Day',
                 v_rt_all_cols(i).crr_day);
             end if;
                  vstep_no  := '6.2';
                  vtable_nm := 'before statemth';
             if (v_rt_all_cols(i).crr_month is not null) then 
              insert into child_tab
                 (COM_ID,                                            
                 KEY,                                                                                                                                            
                 VALUE)
              values
                (id_val,
                 --'IB.Correspondence.Date.Month',
                 'IB.Crsp.Date.Month',
                 v_rt_all_cols(i).crr_month);
             end if;
                  vstep_no  := '6.3';
                  vtable_nm := 'before stateyear';
             if (v_rt_all_cols(i).crr_year is not null) then 
              insert into child_tab
                 (COM_ID,                                            
                 KEY,                                                                                                                                            
                 VALUE)
              values
                (id_val,
                 --'IB.Correspondence.Date.Year',
                 'IB.Crsp.Date.Year',
                 v_rt_all_cols(i).crr_year);
             end if;
                  vstep_no  := '7';
                  vtable_nm := 'before type';
               if (v_rt_all_cols(i).product_type is not null) then
                  insert into child_tab
                     (COM_ID,                                            
                     KEY,                                                                                                                                        
                     VALUE)
                  values
                    (id_val,
                     'IB.Product.ProductName',
                   v_rt_all_cols(i).product_type);
                end if;
                  vstep_no  := '9';
                  vtable_nm := 'before title';         
              if (trim(v_rt_all_cols(i).title) is not null) then
              insert into child_tab
                 (COM_ID,                                            
                 KEY,                                                                                                                                            
                 VALUE )
              values
                (id_val,
                 'IB.Customer.Title',
                 trim(v_rt_all_cols(i).title));
              end if;
                  vstep_no  := '10';
                  vtable_nm := 'before surname';
              if (v_rt_all_cols(i).surname is not null) then
                insert into child_tab
                   (COM_ID,                                            
                   KEY,                                                                                                                                          
                   VALUE)
                values
                  (id_val,
                  'IB.Customer.LastName',
                  v_rt_all_cols(i).surname);
              end if;
                            vstep_no  := '12';
                            vtable_nm := 'before postcd';
              if (trim(v_rt_all_cols(i).POSTCODE) is not null) then
              insert into child_tab
                 (COM_ID,                                            
                 KEY,                                                                                                                                            
                 VALUE)                              
               values
                (id_val,
                 'IB.Customer.Addr.PostCodeMasked',
                  substr(replace(v_rt_all_cols(i).POSTCODE,' ',''),length(replace(v_rt_all_cols(i).POSTCODE,' ',''))-2,3));
              end if;
                            vstep_no  := '13';
                            vtable_nm := 'before subject';
              if (trim(v_rt_all_cols(i).SUBJECT) is not null) then
              insert into child_tab
                 (COM_ID,                                            
                 KEY,                                                                                                                                            
                 VALUE)                              
               values
                (id_val,
                 'IB.Correspondence.Subject',
                  v_rt_all_cols(i).subject);
              end if;
                            vstep_no  := '14';
                            vtable_nm := 'before inactivity';
              if (trim(v_rt_all_cols(i).UNREAD_CORRES_PERIOD) is null or
                  trim(v_rt_all_cols(i).UNREAD_CORRES_PERIOD) = '3' or
                  trim(v_rt_all_cols(i).UNREAD_CORRES_PERIOD) = '6' or
                  trim(v_rt_all_cols(i).UNREAD_CORRES_PERIOD) = '9') then
              insert into child_tab
                 (COM_ID,                                            
                 KEY,                                                                                                                                            
                 VALUE)                              
               values
                (id_val,
                 'IB.Correspondence.Inactivity',
                  v_rt_all_cols(i).UNREAD_CORRES_PERIOD);
              end if;
                          vstep_no  := '14.1';
                          vtable_nm := 'after notfound';
        end if;
                          vstep_no  := '15';
                          vtable_nm := 'after notfound';
        END LOOP;
        end loop;
                          vstep_no  := '16';
                          vtable_nm := 'before closecur';
        CLOSE stg_cursor;
                          vstep_no  := '17';
                          vtable_nm := 'before commit';
        DELETE FROM table_stg;
      COMMIT;
                          vstep_no  := '18';
                          vtable_nm := 'after commit';
    EXCEPTION
    WHEN OTHERS THEN
      ROLLBACK;
      success_flag := 1;
      vsql_code := SQLCODE;
      vsql_errm := SUBSTR(sqlerrm,1,200);
      error_logging_pkg.inserterrorlog('samp',vsql_code,vsql_errm, vtable_nm,vstep_no);
      RAISE_APPLICATION_ERROR (-20011, 'samp '||vstep_no||' SQLERRM:'||SQLERRM);
    end;
    Thanks

    Its bit urgent
    NO - it is NOT urgent. Not to us.
    If you have an urgent problem you need to hire a consultant.
    I have a performance issue in the below code,
    Maybe you do and maybe you don't. How are we to really know? You haven't posted ANYTHING indicating that a performance issue exists. Please read the FAQ for how to post a tuning request and the info you need to provide. First and foremost you have to post SOMETHING that actually shows that a performance issue exists. Troubleshooting requires FACTS not just a subjective opinion.
    where i am trying to insert the data from table_stg into target_tab and in parent_tab tables and then to child tables via cursor with bulk collect .the target_tab and parent_tab are huge tables and have a row wise trigger enabled on it .the trigger is mandatory . This timetaken for this block to execute is 5000 seconds.Now my requirement is to reduce it to 5 to 10 mins.
    Personally I think 5000 seconds (about 1 hr 20 minutes) is very fast for processing 800 trillion rows of data into parent and child tables. Why do you think that is slow?
    Your code has several major flaws that need to be corrected before you can even determine what, if anything, needs to be tuned.
    This code has the EXIT statement at the beginning of the loop instead of at the end
        FETCH stg_cursor BULK COLLECT INTO v_rt_all_cols LIMIT limit_in;
                  vstep_no  := '4';
                  vtable_nm := 'after fetch';
    --EXIT WHEN v_rt_all_cols.COUNT = 0;
        EXIT WHEN stg_cursor%NOTFOUND;
    The correct place for the %NOTFOUND test when using BULK COLLECT is at the END of the loop; that is, the last statement in the loop.
    You can use a COUNT test at the start of the loop but ironically you have commented it out and have now done it wrong. Either move the NOTFOUND test to the end of the loop or remove it and uncomment the COUNT test.
    WHEN OTHERS THEN
      ROLLBACK;
    That basically says you don't even care what problem occurs or whether the problem is for a single record of your 10,000 in the collection. You pretty much just throw away any stack trace and substitute your own message.
    Your code also has NO exception handling for any of the individual steps or blocks of code.
    The code you posted also begs the question of why you are using NAME=VALUE pairs for child data rows? Why aren't you using a standard relational table for this data?
    As others have noted you are using slow-by-slow (row by row processing). Let's assume that PL/SQL, the bulk collect and row-by-row is actually necessary.
    Then you should be constructing the parent and child records into collections and then inserting them in BULK using FORALL.
    1. Create a collection for the new parent rows
    2. Create a collection for the new child rows
    3. For each set of LIMIT source row data
      a. empty the parent and child collections
      b. populate those collections with new parent/child data
      c. bulk insert the parent collection into the parent table
      d. bulk insert the child collection into the child table
    And unless you really want to either load EVERYTHING or abandon everything you should use bulk exception handling so that the clean data gets processed and only the dirty data gets rejected.

  • How to pass and work with a PL/SQL or Temp table in a Procedure?

    My problem is that I have a query that involves about 10 tables or so, but everything starts from one base table. I am trying to split the base table so that the query actually finishes.
    Problem Query:
    with base_table as
    select * from table_a
    , t1 as
      select * from table_b
    -- There are some manipulation in the SQL, but not listing it here.
    , t2 as
      select * from table_c INNER JOIN t1 on t1.id = table_c.id
    ) What I want to do is limit base table and thus create a procedure such that it evalutes a temporary table and the temporary table will be limited by 1000 rows or so.
    Thanks for your help.

    Currently I am using:
    DECLARE
       l_start                       NUMBER;
       l_increment                   NUMBER;
       l_max                         NUMBER;
    BEGIN
       l_start := 1;
       l_increment := 100;
       SELECT COUNT(*) AS the_count
         INTO l_max
         FROM table_a;
       LOOP
       INSERT INTO new_table
         WITH base_table AS
         (SELECT p.*
            FROM (SELECT DENSE_RANK () OVER (ORDER BY alpha_id) rnum, a.*
                    FROM table_a a) p
           WHERE rnum BETWEEN l_start AND l_start + l_increment - 1)
       , t1 AS
         (SELECT *
            FROM table_b
    -- There are some manipulation in the SQL, but not listing it here.
       , t2 AS
         (SELECT *
            FROM table_c INNER JOIN t1 ON t1.ID = table_c.ID
    SELECT *
      FROM t2, temp_base;
    COMMIT;
          l_start := l_start + l_increment;
          EXIT WHEN l_start > l_max;
       END LOOP;Is it better to create a Temporary table or pass the data as a cursor:
    SELECT DENSE_RANK () OVER (ORDER BY alpha_id) rnum, a.*
    FROM table_a a
    Thanks.

  • Master Data Service: how to remove the dirty data from master data service from a table using store procedure?

    hello, we need to remove the dirty data from MDS, but we found we can only do this from MDS web, and we need to do this by store procedure to make this process automatically. is there any easy method to remove the data from MDS automatically? thank.
    Warren

    Hi Warren,
    Assuming the dirty data is easily identifiable, all you need to do is use the staging process with import type of 5 (de-activate - i.e., soft delete) or import type of 6 (hard delete).
    Could give more details if I knew the version of MDS you are running (SQL 2008R2 or SQL 2012).
    Kind regards,
    M

  • How do I iterate through a subform structure ?

      I have subforms which have individual fields which I have to set access either open or protected.  Instead of listing each single field, is there a way I can use a for loop to iterate through the subform and set each field access as needed?

    That’s unfortunate because we aren’t using Acrobat/Reader to read the forms.  We’re using a product called FormStream Filler.  Anyway, I stumbled onto a technique used in a previous form here.  I don’t understand everything about it, but I was able to replace enough code to get it to work with my form.  Suffice to say it has a lot to do with nodes. 
    Thanks for  answering.

  • How to iterate List in jsp without using for loop

    Hi,
    I am developing a small application is struts. I have one ActionForm file which contain one List like getEmployeeDetailsList(). When I am using this list in jsp page for displaying data. I want to display it as employee name, employee address, employee designation and employee contact no. These all fields are available in the above list. Now what is the problem is that I am using logic:iterate method to iterate data. but this is not sufficient to display all records in order. like employee name should be in one table and they can be vertical not horizontal, employee address is also should be seperate. and same thing with employee designation and contact no. I don't want to use for loop to iterate this list. Please tell me about optionCollection for this list. only employee names should be one drop down and employee designation is also in another drop down.
    Please help. It is really urgent.
    Any help will be appreciated.
    Thanks in advance.
    Manveer

    I'm not sure what you problem is, but one thing you can do is to create a new class and pass the list into its constructor (and store it as a private variable). Then, provide a set of functions in the new class that extracts data from the list and returns it in a form that the various parts of the JSP page wants. For example, one function may return a sorted list of just the employee names. In this way, all the business logic for formatting the data into a form that JSP page likes is hidden inside the new class.

  • Urgent!  Slow Result Set -- temp table slowing me??

    -- Running BC4J/JHeadstart/UIX
    Description:
    I have a uix page that calls a Servlet and passes a TABLE_NAME. The Servlet gets the TABLE_NAME and calls a class that extends oracle.jheadstart.persistence.bc4j.handler.DataSourceHandlerImpl to create a ViewObject and get the data we need. Once the ViewObject is passed back to the servlet, the servlet loops through the VIewObject and builds a report. See the problem below and the code at the bottom.
    Problem:
    I am running a query that returns approx 5000 records to my ViewObject. I then loop through the rows and construct a report. The view object will return the first 1085 records quickly, however, the following 4000 come back very slowly. I read online that BC4J creates temp tables to store large resultsets and then streams the data to the user as you need it. Is this our potential bottleneck?
    Questions:
    Is there a way to have it return all the rows? What can I do to speed this up?
    Code:
    --- Begin Servlet Snippet ---
    private ByteArrayOutputStream createReport(HttpServletRequest request)
    try{
    // PARM_REPORT = table name
    String reportName = request.getParameter(PARM_REPORT);
    System.out.println(">> calling getReport for " + reportName);
    RdmUserHandlerImpl handler = new RdmUserHandlerImpl();
    ViewObject vo = handler.getReportView2(reportName, request.getSession().getId());
    System.out.println(">> back from get report");
    // loop through report and print every 100
    while(vo.hasNext())
    curRow++;
    if (curRow % 100 == 0 )
    System.out.println(curRow + "");
    --- End Servlet Snippet ---
    --- Begin RdmUserHandlerImpl Snippet ---
    public ViewObject getReportView2(String tableName, Object sessionId) throws Exception {
    System.out.println("IN GET REPORT VIEW");
    ApplicationModule appMod = (ApplicationModule)getConnection("classpath...resource.MyUser", sessionId);
    // First see if we already created the view definition
    ViewObject vo = appMod.findViewObject(tableName);
    // If it was already created then refresh it, else lets try to create it
    if(vo != null) {
    System.out.println("found existing view");
    vo.reset();
    else {
    System.out.println("view not found, making new view");
    String query="SELECT * FROM " + tableName;
    System.out.println("QUERY = " + query);
    vo = appMod.createViewObjectFromQueryStmt(tableName, query);
    // max fetch returns -1
    System.out.println("MAX Fetch Size = " + vo.getMaxFetchSize());
    return vo;
    --- End RdmUserHandlerImpl Snippet ---
    Please reply asap! Deadline is coming fast!
    -Matt

    Matt,
    I think that you are right, the temporary tables created by BC4J are the reason for making it slow after a certain number of records. One of Steve Muench's articles includes the text:
    One of the most frequent performance-related questions we get on the Oracle Technet discussion forum is a question like, "After I query about a 1000 rows in a view object, my application gets very, very slow. What's happening?"
    It explains how you can turn off this feature, see the full article at http://www.oracle.com/technology/products/jdev/tips/muench/voperftips/index.html.
    The following article gives a lot of helpful information about the temporary tables:
    http://www.oracle.com/technology/products/jdev/htdocs/bc4j/bc4j_temp_tables.html
    The next article gives general tips for performance tuning of BC4J:
    http://www.oracle.com/technology/products/jdev/howtos/10g/adfbc_perf_and_tuning.html
    Hope this helps,
    Sandra Muller
    JHeadstart Team

  • Error while creating Global temp table

    Hi,
    I am very new to PL/SQL so please excuse my question. I have the below query . I have to get a count between the source table and various target tables. I am creating a global temp table to store the counts. I am getting the below error for my following query :
    Thanks for the help,
    Petronas
    ----Query----
    set serveroutput on
    Declare
    nm1 varchar2(200);
    nm2 varchar2(200);
    cnt1 number;
    cnt2 number;
    diff number;
    totdiff number;
    Begin
    nm1 := null;
    nm2:= null;
    cnt1:= 0;
    cnt2 := 0;
    diff := 0;
    totdiff := 0;
    create GLOBAL TEMPORARY TABLE diff ( name1 varchar(200), name2 varchar2(200), diff number);
    select count(*) into cnt1
    from users_staging;
    select count(*) into cnt2
    from PROD.users;
    nm1 := 'users_staging';
    nm2 := 'PROD.users';
    diff := cnt1 - cnt2;
    insert into diff values (nm1,nm2,diff);
    select count(*) into totdiff
    from diff
    where diff> 0 ;
    dbms_output.enable(10000);
    dbms_output.put_line('# of tables where difference is > 0 ' ||totdiff);
    end;
    Encountered the symbol "CREATE" when expecting one of the following:
    begin case declare end exception exit for goto if loop mod
    null pragma raise return select update while with
    <an identifier> <a double-quoted delimited-identifier>
    <a bind variable> << close current delete fetch lock insert
    open rollback savepoint set sql execute commit forall merge
    pipe

    Hi,
    "CREATE GLOBAL TEPORARY TABLE ..." is not a PL/SQL command; it is a SQL command only.
    Create the table, using that statement, before running the PL/SQL block.
    You can issue SQL statements from within PL/SQL using the EXECUTE IMMEDIATE command, but this is rarely a good idea.
    I assume the PL/SQL code is meant to create the table and then populate it.
    You should split those into two separate pieces of code. You'll only want to create the table once, no matter how many times you use it. I assume you'll want to populate it the same way many times. Remember, the "TEMPORARY" in "GLOBAL TEMPORARY TABLE" refers to the data, not the table. When you end a transaction (or a session, depending on whther you want "ON COMMIT DELETE ROWS" or "ON COMMIT PRESERVE ROWS"), the data disappears, but the now-empty stays, ready to be populated for the next transaction (or session).
    Edited by: Frank Kulash on Aug 4, 2010 2:25 PM

  • Having trouble with inner for loop values in my procedure

    Hi ...
    I am using oracle 10g and here is my procedure ...
    create or replace procedure sales_information is
    v_qty number(10);
    rem_qty number(10):=0;
    cursor pck_quantity is
    select * from sales_info;
    cursor no_of_labels is
    select ceil(sum(nvl(total_quantity,actual_quantity))/400) from sales_info;
    begin
    for j in no_of_labels
    loop
    for i in pck_quantity
    loop
    select nvl(i.total_quantity,i.actual_quantity) into v_qty from sales_info;
    if v_qty>=i.packed_quantity and rem_qty=0 then
    insert into sales_order values------------
    rem-qty:=v_qty-i.packed_quantity;
    v_qty:=rem_qty;
    exit;
    else if v_qty>=i.packed_quantity and rem_qty>=400 then
    insert into sales_order values-----------
    rem_qty:=v_qty-rem_qty;
    v_qty:=rem_qty;
    exit;
    else if v_qty>=i.packed_quantity and rem_qty>0 then
    rem_qty:=v_qty+rem_qty-i.packed_quantity;
    v_qty:=rem_qty;
    insert into sales_order values-----------
    else if v_qty is null and rem_qty>0 and then
    insert into sales_order values-----------
    else if v_qty<i.packed_quantity and rem_qty:=0 then
    rem_qty:=v_qty;
    else if v_qty<i.packed_quantity and rem_qty>0 then
    if (v_qty+rem_qty)>400 then
    insert into sales_order values-----------
    rem_qty:=v_qty+rem_qty-i.packed_quantity;
    v_qty:=rem_qty;
    end if;
    end if;
    end loop;
    end loop;
    The inner for loop will retrieve the same values of v_qty for every iteration of outer for loop when it runs the following select statement:
    select nvl(i.total_quantity,i.actual_quantity) into v_qty from sales_info;
    and thus loses the previously computed values of v_qty and rem_qty
    in the previous iteration of outer for loop whereas i want the inner for loop to iterate over it's previously computed values of v_qty and rem_qty but cant think of a workaround.

    h4. Thanks Dave for explanation. Hope I understood your requirement and below code resolves that
    -- Creating table SALES_INFO
    CREATE TABLE SALES_INFO
    (    S_NO             NUMBER(1),
         ACTUAL_QUANTITY  NUMBER(10),
         TOTAL_QUANTITY   NUMBER(10),
          PACKED_QUANTITY  NUMBER(10)
    -- Creating table sales_order
    CREATE TABLE SALES_ORDER
    (    S_NO             NUMBER(1),
         LABEL            VARCHAR2(30),
         ORDER_QUANTITY   NUMBER(10)
    -- Push SALES_INFO data
    INSERT INTO SALES_INFO VALUES(1,1000,800,400);
    INSERT INTO SALES_INFO VALUES(2,800,600,400);
    INSERT INTO SALES_INFO VALUES(3,800,NULL,400);
    INSERT INTO SALES_INFO VALUES(4,NULL,600,400);
    CREATE OR REPLACE PROCEDURE populate_sales_order AS
    CURSOR get_sales_info IS
    SELECT s_no,
               NVL(total_quantity,actual_quantity) total_quantity,
            packed_quantity
    FROM   sales_info;
    v_s_no          PLS_INTEGER := 0;
    v_rem_qty     PLS_INTEGER := 0;
    v_label_num   PLS_INTEGER := 1;
    BEGIN
    FOR rec IN get_sales_info LOOP
        v_rem_qty := rec.total_quantity + v_rem_qty;
        v_s_no    := rec.s_no;
         WHILE v_rem_qty >= rec.packed_quantity LOOP
           INSERT INTO sales_order( s_no, label, order_quantity)
           VALUES ( v_s_no, 'LABEL' || v_label_num, rec.packed_quantity );
           -- Reduce the packed qty from total qty and increment label counter
           v_rem_qty   := v_rem_qty - rec.packed_quantity ;
           v_label_num := v_label_num + 1;
         END LOOP;
    END LOOP;
    -- Put the last lot remaining qty into last carton
    IF v_rem_qty > 0 THEN
    INSERT INTO sales_order( s_no, label, order_quantity)
    VALUES (v_s_no, 'LABEL' || v_label_num, v_rem_qty );
    END IF;
    COMMIT;
    END;
    S_NO    LABEL                                ORDER_QUANTITY
      1          LABEL1                                    400
      1          LABEL2                                    400
      2          LABEL3                                    400
      3          LABEL4                                    400
      3          LABEL5                                    400
      4          LABEL6                                    400
      4          LABEL7                                    400
    {code}                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

  • How can I get rid of Global Temp Table

    Hello,
    I've been writing PL/SQL stored proc for creating reports on VB.NET front end. Until now, I've been using session specific global temp table to store intermediate results and at the end I pass the result set to .NET via reference cursor. The reports are created by simply binding the ref cursor result sets to .NET grids. It's been working fine, but I am kind of bothered by the temp tables. I looked on other options, but couldn't really come up with one.
    Can somebody suggest me how I can get rid of those temp tables? Thanks,

    Tubby, that's exactly I was trying to do. I think that table type has to be defined in database, not within PL/SQL. How can I create that table of user defined record type? I tried that, but it doesn't allow me. I think I am missing something. For example,
    create type group_t is record
    (A varchar2,
    B number,
    C number)
    now inside sp, i have something like:
    type my_group is table of group_t index by binary_integer
    now I have sp cursor as
    cursor cur_test IS 'ABC' as A, 1 as B, 5 as C
    now i do something like this. My original queries are longer and much more complicated so please don't suggest you can directly open ref cursor for this query.
    FETCH cur_test BULK COLLECT INTO my_group;
    Then I do all the processing, calculations, totals, sub-totals, and insert into temp table and return via ref cursor.
    My problem is I can't directly fetch into the above table you mentioned. How should I go about in this situation?
    Maybe I should STOP thinking about this approach and just do whatever I've been doing or solve it through pure SQL. However, there are tons of problems with pure SQL approach.

Maybe you are looking for

  • We have a new Wordpress site, how do I add a description and artwork to the RSS feed of the podcast?

    Hello: I am surprised I could not find this on a search of Google or Apple Support.  Our church has a new website created with Wordpress.  We have all of the functionality ready to go in order to have the RSS feed work with the itunes store. However,

  • External HD won't mount on PB

    External HD won't mount on PB but, will on iBook, G5 iMac, MBP, and Mirror Door G4. I have a USB 2 HD that will mount on everything but 15" Aluminum PowerBook. I even tried updating the IOUSBFamily.kext but no luck that just made my camera to start w

  • Does anyone know what to do about pixelated files (jpeg & raw) in Bridge CS6?

    The problem cropped up last week when some images seem to never fully resolate on the screen (viewing in Bridge), like they were corrupted though they seem fine when opened in photoshop. The pixelation was at random in a batch of about 600 photos. To

  • HT2500 How to copy all addresses in mail and export CSV?

    I've got 250+ addresses that I can access when sending email.  I want to export those addresses into a .csv form to be able to import them to another mail program.  If I go through Address Book I will only get 66 vcards and will not have the rest.  A

  • EWA-Email Notification

    Hi All, we are configured EWA in solman system also enable to view the weekly report in solman Issue is :   We are not able to recieve EWA report through auto matic email Note :i am bale to  send manually the report to email outlook address and also