Can we do it without using cursor ?

I have two tables. I have to insert records from master to detail table. Detail table has two columns Record_ref and Record_seq as primary key and these two columns has to be generated.
It has to be inserted like this.
for every policy_refer there can be more than one approval_ref. For policy_ref 1 having approval_ref 1,2,3 data in Record_Ref and Record_seq to be generated like this.
Record_ref Record_seq
1 1
1 2
1 3
++++++++++++++++++++++++++++++++++++++++++++++++
BANNER
Oracle Database 10g Enterprise Edition Release 10.2.0.3.0 - Prod
PL/SQL Release 10.2.0.3.0 - Production
CORE 10.2.0.3.0 Production
TNS for 32-bit Windows: Version 10.2.0.3.0 - Production
NLSRTL Version 10.2.0.3.0 - Production
++++++++++++++++++++++++++++++++++++++++++++++++
Two tables are as follows
SQL> desc monthly_dec
Name Null? Type
POLICY_REFER VARCHAR2(14)
APR_SUBSI VARCHAR2(14)
NAME_INSURED VARCHAR2(120)
NAME_INSURED1 VARCHAR2(120)
EXPIRY_POLICY DATE
APPROVAL_REF VARCHAR2(9)
EXPIRY_DATE DATE
APPROVED_AMT NUMBER(11)
BUYER_REF VARCHAR2(13)
BUYER_NAME VARCHAR2(120)
BYR_OR_BNK_REF VARCHAR2(20)
TOR VARCHAR2(14)
UW_PCY_REF VARCHAR2(14)
USER_CODE VARCHAR2(8)
UND_ID VARCHAR2(9)
CREATE_DATE DATE
DEC_MONTH VARCHAR2(10)
CLOSE_FLAG VARCHAR2(1)
CLOSE_DATE DATE
MD_APL_CHK CHAR(1)
MD_SUB_CHK CHAR(1)
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++
SQL> desc TMP_PORTAL_MONTHLY_DEC
Name Null? Type
POLICY_REFER VARCHAR2(14)
APR_SUBSI VARCHAR2(14)
NAME_INSURED VARCHAR2(120)
NAME_INSURED1 VARCHAR2(120)
EXPIRY_POLICY DATE
APPROVAL_REF VARCHAR2(9)
EXPIRY_DATE DATE
APPROVED_AMT NUMBER(11)
BUYER_REF VARCHAR2(13)
BUYER_NAME VARCHAR2(120)
BYR_OR_BNK_REF VARCHAR2(20)
TOR VARCHAR2(14)
UW_PCY_REF VARCHAR2(14)
USER_CODE VARCHAR2(8)
UND_ID VARCHAR2(9)
CREATE_DATE DATE
CLOSE_FLAG VARCHAR2(1)
CLOSE_DATE DATE
DEC_MONTH VARCHAR2(10)
MD_UND_POST_FLAG CHAR(1)
MD_UND_POST_DATE DATE
MD_MAIL_FLAG CHAR(1)
MD_MAIL_DATE DATE
MD_SENT_BY VARCHAR2(9)
CURRENCY_OF_CONTRACT VARCHAR2(12)
TOTAL_VAL_SHIPMENTS NUMBER(14,4)
EXCHANGE_RATE NUMBER(14,4)
TOT_OF_M30DAYS NUMBER(14,4)
FINAL_CURRENCY NUMBER(14,4)
DEC_PORTAL_CREAT_DATE DATE
COPY_FLAG VARCHAR2(3)
SAVE_SUBMIT_FLAG NUMBER(1)
USR_REF_CODE VARCHAR2(50)
RECORD_REF NOT NULL NUMBER(10)
RECORD_SEQ NOT NULL NUMBER(10)

Here is the sample data. I hope it helps. Here Record_ref is same but record_seq is changing. All the other data will be taken from master table. Policy_refer is not 1. It can be anything and one policy_refer can have multiple approval_ref. See that approval_ref is changing as APR-00001,APR-00002,APR-00003.
<strong>CSTP-AUS-00001</strong> A.B.CORP NULL 18-10-2008 PM 10:38:49 APR-00001 18-10-2008 PM 10:38:49 2450000 BYR-UK -00001 HSBC BYR-UK -00001 CSTP-AUS-00001 160022 UND-00001 18-10-2008 PM 10:38:49 18-10-2008 PM 10:38:49 USD 2450000.0000 1.2450 2450000.0000 18-10-2008 PM 10:38:49 1 <strong>1</strong>
<strong>CSTP-AUS-00001</strong> A.B.CORP NULL 18-10-2008 PM 10:39:24 APR-00002 18-10-2008 PM 10:39:24 2450000 BYR-UK -00001 HSBC BYR-UK -00001 CSTP-AUS-00001 160022 UND-00001 18-10-2008 PM 10:39:24 18-10-2008 PM 10:39:24 USD 2450000.0000 1.2450 2450000.0000 18-10-2008 PM 10:39:24 1 <strong>2</strong>
<strong>CSTP-AUS-00001</strong> A.B.CORP NULL 18-10-2008 PM 10:39:51 APR-00003 18-10-2008 PM 10:39:51 2450000 BYR-UK -00001 HSBC BYR-UK -00001 CSTP-AUS-00001 160022 UND-00001 18-10-2008 PM 10:39:51 18-10-2008 PM 10:39:51 USD 2450000.0000 1.2450 2450000.0000 18-10-2008 PM 10:39:51 1 <strong>3</strong>
CSTP-AUS-00002          A.B.CORP     NULL     18-10-2008 PM 10:53:10     APR-00004     18-10-2008 PM 10:53:10     2450000     BYR-UK -00001     HSBC     BYR-UK -00001          CSTP-AUS-00001     160022     UND-00001     18-10-2008 PM 10:53:10          18-10-2008 PM 10:53:10                                   USD     2450000.0000     1.2450          2450000.0000     18-10-2008 PM 10:53:10                    2     1
Edited by: aadi on Oct 19, 2008 1:25 AM
Edited by: aadi on Oct 19, 2008 1:26 AM

Similar Messages

  • SELECT n. row without using cursors

    For example, I retrieved 100 rows after executing a SELECT statement but I want to list only 20th row. How can I do this without using cursors?

    The general approach to getting a set of rows would be to do something like
    SELECT *
      FROM (SELECT a.*, rownum rn
              FROM (<<query with ORDER BY clause>>) a
             WHERE rownum <= <<max>>)
    WHERE rn >= <<MIN>>Depending on the particular requirements, you could also do something like
    SELECT *
      FROM (SELECT a.*, RANK() OVER (<<ORDER BY clause>>) rnk
              FROM <<table>> a
             WHERE <<rest of statement>>)
    WHERE rnk = 20Justin
    Distributed Database Consulting, Inc.
    http://www.ddbcinc.com/askDDBC

  • How to manipulate data in multiple rows without using cursor??

    Hi all,
    I have a form in which there is a push button & 4 text fields.
    Push button : Process
    Text fields: Year, Month, Financial_To_Year, Financial_From_Date.
    In database , there are tables like, CUSTOMER_MASTER, FD_ACCOUNT_MASTER, FD_ACCOUNT_DTL, CUSTOMER_YEARLY_INTEREST, etc.
    In table FD_ACCOUNT_MASTER, there are columns, like CUST_CODE, FD_ACCT_NO, FD_AMOUNT, ACCT_OPEN_DT, ACCT_CLOSE_DATE, ACCT_TYPE, INTEREST_RATE, etc.
    There are thousands of records in the table.
    For Push button : Process , TRIGGER: When button pressed,
    I have to do all the process of FD for all the FD_ACCOUNTS at once. Process means i have to calculate Interest for all the accounts, calculate interest monthly, quarterly, yearly and make the FD_Accounts disable after the date of ACCT_CLOSE_DATE is reached, make the accounts renewed , etc all the process.
    But to do this process for multiple rows at once, we use cursor, but i don't want to use cursor as i feel its too tedious to do.
    Is there any other way , where i do process of multiple records at once without using cursor??
    Help me, Thank You.
    Oracle Forms Builder 6i.
    Oracle9i Enterprise Edition Release 9.2.0.1.0 - Production

    An Update statement certainly can update sets of data instead single row updates:
    UPDATE Statement
    if you can't do it in a single statement you can use bulk processing as well:
    PLSQL 101
    cheers

  • Signal to phone varies between 4G and 1X. Can that be improved without using antennae.

    Signal strength varies from 4G to 1X, is there an adjustment in the phone to correct or is it necessary to buy xtra antennae.

    Thank you for replying.
    Signal varies in 61822 and 33917 zip codes. The incline plane emblem next
    to battery icon never shows strength greater than just the tip of the
    indicator except when I go to Verizon corporate store where they have a
    booster. It happens in and out doors. I have not removed the sim card. This
    is a Motorola RAZR M with a number on back - CEO 168
         [image: Verizon Wireless
    Community]<http://community.verizonwireless.com>
    <http://www.verizonwireless.com/b2c/index.html>
    <http://www.verizonwireless.com/b2c/explore>
    <http://www.verizonwireless.com/b2c/store/controller?item=phoneFirst&action=viewShopIndex>
    <https://wbillpay.verizonwireless.com/vzw/nos/topline.jsp>
    <http://support.verizonwireless.com/clc/>    Re:
    Signal to phone varies between 4G and 1X. Can that be improved without
    using antennae.  created by Verizon Wireless Customer
    Support<https://community.verizonwireless.com/people/vzw_customer_support>in
    Android - View the full
    discussion<https://community.verizonwireless.com/message/1026021#1026021>

  • Can mail be accessed without using apple password

    Can Mail be accessed without using an Apple password

    Appreciate the reply - it was a local IP problem - thanks

  • Hello! I'm out of the country and all my iWeb information is on my computer at home. Now I need to make changes on the webpage... how can i do that without using the computer i made the page on? Thank you!!

    Hello! I'm out of the country and all my iWeb information is on my computer at home. Now I need to make changes on the webpage... how can i do that without using the computer i made the page on? Thank you!!

    iWeb uses the domain.sites2 files to store its assets.
    You'll find it here :
    ~/Library/Application Support/iWeb/
    where ~ is your Home directory.
    If you take a computer with you, you have to store that file in the same location.
    It's not different from taking documents with you if you want to edit them.
    A solution is to remotely control your computer at home.
    TeamViewer, LogMeIn, Apple Remote Desktop or any VNC application you can use, like "Chicken of the VNC".

  • What happens if you never realised you needed your serial number, then your ipod was stolen and you need it...where can if find it without using my ipod

    what happens if you never realised you needed your serial number, then your ipod was stolen and you need it...where can if find it without using my ipod
    please help me!!
    thanks

    See:
    iPod: How to find the serial number
    And this previous discussion:
    iPod touch Serial number help?: Apple Support Communities

  • I'm using an iPad mini can I make calls without using face time?

    I'm using an iPad mini can I make calls without using face time?

    You can use apps such as Skype For iPad from the app store, but if you are asking whether you can make 'normal' phone calls with it then no, you can't.

  • About 2/3 of the time I leave Firefox, it is evidently retained in memory so I can't restart it without using the task manager. I don't use Norton or Skype programs. How do I keep this from happening?

    About 2/3 of the time I leave Firefox, it is evidently retained in memory so I can't restart it without using the task manager. I don't use Norton or Skype programs. How do I keep this from happening?
    == After I have used Firefox and "closed" it.

    See this:
    https://support.mozilla.com/en-US/kb/Firefox+hangs#Hang_at_exit

  • Can I reposition windows without using mouse?

    I'm using a third-party application which, when opening a new window, insists on putting the title bar at the top of the window underneath the menu bar at the top of the screen. This occudes the title bar and makes it impossible to click on it to move the window elsewhere on the screen. I also can't minimize or maximize the window because those buttons are also on the title bar.
    Is there a method in OS X that will let me select a window and reposition it on the screen without using the mouse to click-and-drag? (Perhaps using the arrow keys somehow?) Or alternatively, is there a way to automatically reposition all the open windows so that the title bar would become visible (like the tile function I remember from some past Mac version of Word)?
    FYI: I've tried Exposé, but that only brings up a "ghost image" of the window. When I click on it, it immediately heads back to its "occluded" position. I've also tried resizing and rotating the screen in System Preferences. That doesn't work either.
    Thanks for any help you can provide. This is driving me crazy!

    What about enabling Spaces and assigning the window to a different Space - does that have an effect on how the application is positioned?
    What about pressing cmdshift/ to open the help menu. Then type in "Zoom" (assuming that command exists within the application's menus) and press enter. This should have the same effect as pressing the green plus sign in the application top left corner.
    Note that the menus of your application may have several zoom functions. For instance Firefox 3 has Zoom In and Zoom Out under the View menu (for zooming the webpage) and Zoom (the green plus function) for maximising the application window. This means I have to use arrow keys to find the right one in the help menu. However, unless your application is too far "up" or beyond the top of the screen, you should see the menus when you use the arrow keys - a floating blue arrow appears next to the command.
    I found a commercial application that allows moving windows with the keyboard, MercuryMover:
    http://www.macupdate.com/info.php/id/26411/mercurymover
    (see also here http://www.macosxhints.com/article.php?story=20080428064742892)
    I haven't tried it myself but perhaps it will help.
    /p
    Message was edited by: pullman

  • How to return a resultset in a stored procedure without using Cursor

    Dear all,
    I need to return a resultset in a stored procedure.
    I know I can return a Cursor.
    But because there are many complicate logics I need to carry out,
    so I can finish all the logic in a SINGLE SQL select statement, so I think it can't
    use Cursor as return value.
    Does anybody know other approaches? Please help.
    Thanks!

    Some basic techniques that one can use in SQL. These are merely to illustrate (simplistically) different approaches.
    > field3 = select count(*) from table2,table1 where table2.id = table1.id
    This can be done via an analytical function (refer to the SQL Reference) or very simply, as an in-line select as follows:
    SQL> select
    2 o.object_name,
    3 (select count(*) from user_objects u where u.object_type = o.object_type) as "ONE OF",
    4 o.object_type
    5 from user_objects o
    6 where o.object_name = 'LISTFILES';
    OBJECT_NAME ONE OF OBJECT_TYPE
    LISTFILES 8 PROCEDURE
    So LISTFILE is "one of 8" procedures. I would however rather so this via an analytic function as these are a lot more flexible. Note the WITH clause that allows "modularisation" of SQL - kind of like creating "sub-SQL results" in a single SQL statement:
    SQL> with DATASET1 as(
    2 select
    3 object_name,
    4 count(distinct object_name) over (partition by object_type) as TOTAL_TYPES,
    5 object_type
    6 from user_objects
    7 ),
    8 DATASET2 as(
    9 select
    10 name,
    11 text as SOURCE_LINE,
    12 line as LINE_NO,
    13 count(line) over (partition by name) as TOTAL_LINES
    14 from user_source
    15 )
    16 select
    17 object_name,
    18 '1 of '||total_types||' '||object_type as "TYPE",
    19 source_line as "1st LINE",
    20 total_lines as "TOTAL LINES"
    21 from DATASET1 ds1,
    22 DATASET2 ds2
    23 where ds1.object_name = ds2.name
    24 and ds1.object_name = 'LISTFILES'
    25* and ds2.line_no = 1
    SQL> /
    OBJECT_NAME TYPE 1st LINE TOTAL LINES
    LISTFILES 1 of 8 PROCEDURE procedure ListFiles( cDirectory in varchar2 ) 3
    SQL>
    SQL is quite powerful and analytical functions allows all kinds of aggregation processing per row, accessing the leading or lagging rows' data, etc.
    You need to play around with this to get to grips with it and how to apply it.

  • How can change my code without using if else in procedure

    Hai ,
    I have wrote code like this
    if RPTFORMNTH='M' then
    SELECT coalesce(SUM(IN_RWEEKS),0),
    INTO C2_COL1
    FROM HS_CASEDTA_DTLS_TB
    WHERE UPPER(VR_HAUNM) like NVL(case when HAUNM='0' then null else UPPER(HAUNM) END , UPPER(VR_HAUNM))||'%'
    AND IN_ULBOBJID=ULBOBJID AND CH_FLAG!='D'
    AND VR_RPTFORMNTH=VR_RPTFORMNTH
    AND IN_YEAR=IN_YEAR;
    ELSE
    SELECT
    coalesce(SUM(IN_RWEEKS),0),
    INTO C2_COL1
    FROM HS_CASEDTA_DTLS_TB
    WHERE UPPER(VR_HAUNM) like NVL(case when HAUNM='0' then null else UPPER(HAUNM) END , UPPER(VR_HAUNM))||'%'
    AND IN_ULBOBJID=ULBOBJID AND CH_FLAG!='D'
    AND
    TO_DATE(('01/'||VR_RPTFORMNTH||'/'||IN_YEAR),'DD/MM/YYYY')
    BETWEEN to_date('04/' || to_char(RPTYEAR-1),'MM/YY')
    AND add_months(to_date(RPTFORMNTH || to_char(RPTYEAR),'MonYYYY'),1)-1;
    END IF;
    My query is without using if else and replicate data in if and else how can i modify code.Observe that only where condition i want changes that's why i used if else without that how can i modify where clause with that two conditions.Please give me guidance.
    Regards ,
    rajendar.

    hi,
    I think you want your condition to change inside the where clause so you could have only one select statement. If that is so try this:
    SELECT coalesce(SUM(IN_RWEEKS),0),
    INTO   C2_COL1
    FROM   HS_CASEDTA_DTLS_TB
    WHERE  1 = CASE WHEN RPTFORMNTH='M' THEN
                    CASE WHEN UPPER(VR_HAUNM) like NVL(case when HAUNM='0' then null else UPPER(HAUNM) END , UPPER(VR_HAUNM))||'%'
                              AND IN_ULBOBJID=ULBOBJID AND CH_FLAG!='D'
                              AND VR_RPTFORMNTH=VR_RPTFORMNTH
                              AND IN_YEAR=IN_YEAR
                   THEN 1
                         ELSE 0
                    END
               ELSE --  RPTFORMNTH !='M'
                    CASE WHEN UPPER(VR_HAUNM) like NVL(case when HAUNM='0' then null else UPPER(HAUNM) END , UPPER(VR_HAUNM))||'%'
                              AND IN_ULBOBJID=ULBOBJID AND CH_FLAG!='D'
                              AND TO_DATE(('01/'||VR_RPTFORMNTH||'/'||IN_YEAR),'DD/MM/YYYY')
                              BETWEEN to_date('04/' || to_char(RPTYEAR-1),'MM/YY')
                              AND add_months(to_date(RPTFORMNTH || to_char(RPTYEAR),'MonYYYY'),1)-1
                         THEN 1
                         ELSE 0
                    END
               ENDMessage was edited by:
    Bobbydj
    hi Are, after belatedly reading Rob's post, I think his post is better. I was only looking at your highlighted code, but he took the most common conditions inside the where clause.

  • Can you control volume without using side controls?

    Can you control the volume without using side controls?

    Or, if your iPad is asleep/locked, double click the home button and you'll get an on-screen volume control and play/pause iPod controls (no need to unlock).

  • Im creating a Digital magazine using InDesign. How can I publish it without using DPS?

    Hi there,
    I feel really stupid asking this question.
    But Im creating a digital magazine for a school project and I only need to publish it or view it on an Ipad just for the marker who is looking at it, Can see how it works and Can mark it. Is there anyway I can go about doing that without purchasing the DPS. As its alot of money and I dont wish to buy it just to put this one magazine on an Ipad. Its just for my final yearlie school project. So again I dont see the point of purchasing it just for this one project, In which I will never use it again...
    Thank you.

    As long as you have the Adobe DPS tools installed (Folio Builder and Folio Overlays), and you have a free Adobe ID, you can create folios and can view them on your iPad. You can share them with another person who has an Adobe ID. You cannot publish the folio on the Apple App Store without a Creative Cloud subscription, or by purchasing the rights to publish a Single Edition app.
    For further questions, please ask on the Adobe DPS forum:
    Digital Publishing Suite

  • Due to a divorce all my music is on my iTunes and iPod. I had to buy a new computer and want to transfer my Library to the new computer. How can I do this without using an external drive and use new computer just like I do the old one? Thanks.

    Due to divorce, all my music is on my iTunes and iPod. I have had to buy  a new laptop and want to transfer the library to the new computer before deauthorizing the old one. I dont want to have to use an external drive every time I want to listen to my music. How can I do this and have the same basic iTunes setup as before? HELP!

    You might consider itunes match for moving CDs you've copied into your itunes library if you dont have a way to use home sharing.
    iTunes match is an optional service offered by apple that costs about $25 a year.  It scans your music library and if it finds music that is already in apple's itunes catalog it'll automatically "unlock"/"store" these in the cloud for you.  Items that it does not find in the catalog it'll upload and store these in the cloud for you and you can download them on your devices.  See http://www.apple.com/itunes/itunes-match/

Maybe you are looking for