Write an UPdate statement using the logic used in PL/SQL block (oracle 10g)

Hi All,
I have written the following PL/SQL block. I want to write an UPDATE statement using the logic used in the following PL/SQL block. can any one please help me out in this regards.
DECLARE
   v_hoov_fag   gor_gold_post.hoov_flg%TYPE;
   v_b49n          gor_gold_post.b49n%TYPE;
   CURSOR c
   IS
      SELECT bs_id, loyalty_date, loyalty_period, contract_date
        FROM gor_gold_post
       WHERE tariff_code IN (169, 135, 136);
BEGIN
   FOR rec IN c
   LOOP
      IF    (TRUNC (ADD_MONTHS (rec.loyalty_date, rec.loyalty_period)
                    - SYSDATE) < 304
         OR (    TRUNC (  ADD_MONTHS (rec.loyalty_date, rec.loyalty_period)
                        - SYSDATE
                       ) IS NULL
             AND (SYSDATE - TO_DATE (rec.contract_date, 'YYYYMMDD')) > 91.2
      THEN
         v_hoov_flg := 1;
      ELSE
         v_hoover_flag := 99;
      END IF;
      IF    (TRUNC (ADD_MONTHS (rec.loyalty_date, rec.loyalty_period)
                    - SYSDATE) < 121.6
         OR (    TRUNC (  ADD_MONTHS (rec.loyalty_date, rec.loyalty_period)
                        - SYSDATE
                       ) IS NULL
             AND (SYSDATE - TO_DATE (rec.contract_date, 'YYYYMMDD')) > 91.2
      THEN
         v_b49n := 1;
      ELSE
         v_b49n := 99;
      END IF;
      UPDATE gor_gold_post
         SET hoov_flg = v_hoov_flg,
             b49n = v_b49n
       WHERE bs_id = rec.bs_id AND tariff_code IN (169, 135, 136);
      COMMIT;
   END LOOP;
END;Thank you,

Using case statement.
UPDATE gor_gold_post
   SET hoov_flag = CASE WHEN TRUNC (ADD_MONTHS (rec.loyalty_date, rec.loyalty_period) - SYSDATE) < 304
                               OR
                               (TRUNC (ADD_MONTHS (rec.loyalty_date, rec.loyalty_period) - SYSDATE) IS NULL
                            AND (SYSDATE - TO_DATE (rec.contract_date, 'YYYYMMDD')) > 91.2)
                       THEN 1
                       ELSE 99
                     END,
       b49n      = CASE WHEN TRUNC (ADD_MONTHS (rec.loyalty_date, rec.loyalty_period) - SYSDATE) < 121.6
                         OR
                         (TRUNC (ADD_MONTHS (rec.loyalty_date, rec.loyalty_period) - SYSDATE) IS NULL
                            AND (SYSDATE - TO_DATE (rec.contract_date, 'YYYYMMDD')) > 91.2)
                       THEN 1
                       ELSE 99
                     END
WHERE tariff_code IN (169, 135, 136);Note: Code not tested.

Similar Messages

  • Logic Pro 9 (9.0.0).   Message You can't use this version of the application Logic Pro 9 with this version of Mac OS X You have Logic Pro 9 9.0.0.   I have been told that I can use the Logic Pro 9.1.4 Update (.dmg) which you can download from Apple Logic

    Since upgrading to lion, I can't use Logic pro, hope someone can help.  thank you
    Logic Pro 9 (9.0.0).
    Message
    You can't use this version of the application Logic Pro 9 with this version of Mac OS X
    You have Logic Pro 9 9.0.0.
    I have been told that I can use the Logic Pro 9.1.8 Update (.dmg) which you can download from Apple Logic Support, although when I try to upgrade my I get this message:
    An eligible Logic Pro version was not found in the Applications folder. This update requires Logic Pro version 9.0 or higher.

    Since upgrading to lion, I can't use Logic pro, hope someone can help.  thank you
    Logic Pro 9 (9.0.0).
    Message
    You can't use this version of the application Logic Pro 9 with this version of Mac OS X
    You have Logic Pro 9 9.0.0.
    I have been told that I can use the Logic Pro 9.1.8 Update (.dmg) which you can download from Apple Logic Support, although when I try to upgrade my I get this message:
    An eligible Logic Pro version was not found in the Applications folder. This update requires Logic Pro version 9.0 or higher.

  • What is the logical use of defining Dimension Object Relationships in DBI?

    Hi!
    I am reading the Oracle Daily Business Intelligence Implementation Guide and as I am following the guide on how to extend DBI, I saw a section which discusses how to create dimension object relationships. Until now, I could not fully realize what is the logical use of defining this relationship among dimension objects. I hope someone can enlighten me on this matter...
    Thanks.

    It LIVES ON FOREVER, and starts to take on its own personality, hungrily chasing down other objects in memory and ATTACKING THEM AT WILL. Also it grows over time, in its evil attempt to CONSUME YOUR ENTIRE MACHINE, and comes out and EATS YOU UP TOO! MWAHHHAAAHHHAAAA
    No wait, that was a sci-fi. It just lives until no more references to it exist and thus becomes eligible for garbage collection, and is only a "JAVA" feature not JDBC.

  • Can u tell me where we exactly use the logical file.

    hi,
    this is pandu,can u tell me where we exactly use the logical file,
    what is the use of the logical file in detailed explanation.
    regards,
    pandu.

    http://help.sap.com/saphelp_nw04/helpdata/en/9f/db95e635c111d1829f0000e829fbfe/content.htm
    http://help.sap.com/saphelp_nw04/helpdata/en/8d/3e4ec2462a11d189000000e8323d3a/content.htm

  • How to call UPDATE statements in the timesten

    Hi i want to know how can i call UPDATE statements from the c program
    as of now i am using SQLPREPARE and SQLEXECUTE for the same.
    but i get the following error.
    Is there any special way of calling UPDATE and INSERT routines.
    As my select statements are doing fine, but i m getting error with UPDATE and INSERT. I am getting the following error
    Can Anyone guide me ?
    ========================================================
    [TimesTen][TimesTen 6.0.4 ODBC Driver][TimesTen]TT5102: Cannot load backend library 'libttorD.a' for Cache Connect. OS error message 'Symbol resolution failed
    for /disk3/users/timesten/TimesTen/TT_EUDEV10G/lib/libttorD.a because:
    Symbol ora_ldap_unbind (number 224) is not exported from dependent
    module /disk1/users/oracle/product/9.2.0/lib/libclntsh.a[shr.o].
    Symbol ora_ldap_memfree (number 225) is not exported from dependent
    module /disk1/users/oracle/product/9.2.0/lib/libclntsh.a[shr.o].
    Symbol
    *** ODBC Error/Warning = S1000, Additional Error/Warning = 5102
    *** (Note: error message was truncated.
    Disconnecting from the data source...
    ==========================================================

    Hi,
    It looks like you are using either :
    1. A READONLY CACHE GROUP with PassThrough > 0.
    or
    2. An SWT CACHE GROUP
    Is that correct? This looks like a mismatch between the TT Oracle library and the version of the Oracle client that you have installed (or maybe a bad setting of LD_LIBRARY_PATH).
    What is the exact version of TimesTen you are using (output of ttVersion command)?
    What is the exact version of Oracle?
    Thanks, Chris

  • Create a Purchase order using the BAPI using the data in the XML file.

    Hello Gurus,
    here is the scenario can anyone help me how to proceed explaining the procedure?
    Create a Purchase order using the BAPI using the data in the XML file.
    comprehensive explanations are appreciated.
    thanks in advance.

    hi,
      first use fm "bapi_po_create".
      then use fm "BAPI_ACC_GL_POSTING_POST"
    The demo environment was made with real business scenario in mind, but following subjects need to be addressed in a live implementation:
    •     No exceptions and error handling is implemented, except the order rejection (e.g. partly delivery);
    •     In Navision both XML Ports and the XML DOM has been used to integrate with SAP XI, because XML ports has some drawbacks regarding to Namespaces in XML Documents (mandatory in SAP XI);
    •     A minimum of SAP and Navision customization is required to implement this solution. (e.g. user exit in SAP, Navision XML DOM).

  • How to write a case statement for the totals column of two different years (2013 and 2014) of the same month so that I can get a +/- column

    Please Help!!!
    How to write a case statement for the totals column of two different years (2013 and 2014) of the same month so that I can get a +/- column.
                                      January 2014         January
    2013                            +/-
                    Region   Entry   Exit  Total    Entry   Exit   Total   (Total of Jan2014-Total of Jan2013)
                    A               2         3      
    40        5       7        30                    40-30= 10

    What is a table structure? Sorry cannot test it right now..
    SELECT <columns>,(SELECT Total FROM tbl WHERE Y=2014)-(SELECT Total FROM tbl WHERE Y=2013)
    FROM tbl
    Best Regards,Uri Dimant SQL Server MVP,
    http://sqlblog.com/blogs/uri_dimant/
    MS SQL optimization: MS SQL Development and Optimization
    MS SQL Consulting:
    Large scale of database and data cleansing
    Remote DBA Services:
    Improves MS SQL Database Performance
    SQL Server Integration Services:
    Business Intelligence

  • When playing a home video DVD using DVD Player I tried to use the "Controls, Use current frame as jacket picture" facility to create a printable image but with no success. Can anybody point me in the right direction?

    When playing a home video DVD (created on my Panasonic DVD/Hard Disc recorder)  using the Mac DVD Player, I tried to use the "Controls, Use current frame as jacket picture" facility to create a printable image but with no success. I assume that any file created by this action would be stored somewhere in a common format but cannot find any such file. Can anybody point me in the right direction?

    Hi Sinious,
    Interesting to know about 10.8 and Flash. I'll hold off upgrading until they work together. Currently using 10.6.8 at home and same on the Universtity's computers.
    Haven't verified on Windows but shall do later in the week if I can get access to a Windows machine.
    Both the Flash player and the Projector come up not full screen, and if I leave it that way then things work OK as long as I don't make the video full screen (using the full screen button on the skin).
    However if I make the swf or projector full-screen (by using CMD-F or the menu option) then when I click on the menu item to take me to the page with the video on it, instead of a page with a smallish video and back button I get a black screen with no obvious controls. If I then press Escape I get my normal screen back and I am in the page that should have the video but there is not video and the back button does not work. So something wierd is going on here.
    If I make a file without any videos with a similar navigation structure everyting works ok except that when I go full screen I lose the finger cursor when I roll over my buttons (which is also wierd).

  • I do not remember what name and password and it uses the device used and I can not open it is at activation

    I do not remember what name and password and it uses the device used and I can not open it is at activation

    Hey there Haimnus!
    I have two articles that I believe will help you resolve this issue:
    iCloud: Find My iPhone Activation Lock in iOS 7
    http://support.apple.com/kb/ht5818
    Find My iPhone Activation Lock: Removing a device from a previous owner’s account
    http://support.apple.com/kb/ts4515
    Take care, and thanks for visiting the Apple Support Communities.
    Cheers,
    Braden

  • I installed an airport express, on my mac book i can use the airplay using iTunes, but on my iPhone en ipad the icon for airplay not appears on the screan when i start the music player.

    I installed an airport express, on my mac book i can use the airplay using iTunes, but on my iPhone en ipad the icon for airplay not appears on the screan when i start the music player.

    Chances are, you have already tried this and already know the answer.
    But, if not....sorry, but no......since your printer is not AirPrint compatible, you must use the extra software workaround in the Mac.
    A newer AirPrint printer would allow you to do what you want.

  • Can the format of a SQL Statement modify the execution time of an SQL ....

    Can the format of a SQL Statement modify the execution time of an SQL statement?
    Thanks in advance

    It depends on:
    1) What oracle version are you using
    2) What do you mean for "format"
    For example: if you're on Oracle9i and changing format means changing the order of the tables in the FROM clause and you're using Rule Based Optimizer then the execution plan and the execution time can be very different...
    Max
    [My Italian Oracle blog|http://oracleitalia.wordpress.com/2009/12/29/estrarre-i-dati-in-formato-xml-da-sql/]

  • Can We use FDM as ETL tool between SQL and Oracle

    I want to use FDM as ETL tool between SQL and Oracle. Can it be possible. I didn,t found any target adapter for oracle database.My source system is SQL and Target system is Oracle database.
    Rahul
    Edited by: user12190125 on Nov 9, 2009 4:23 AM

    Rahul,
    I believe this is possible to do, but not an easy one and there are a few considerations:
    How much data are you processing? FDM has a lot of features which support the business process. While this is great for users and audit trail etc. it slows down performance if you want to process a lot of data. It also depends on the type of mappings you use (Like mappings are slower than explicit mappings).
    How familiar are you with VBScript? There is no explicit target adapter for Oracle, but there is a data mart adapter which can be used for anything. You have to implement everything yourself though, mainly the Export and Load actions. In there you will also have to handle the the connections to the MSSQL and Oracle databases.
    Check the data mart adapter and see if you feel comfortable with defining the vb code in there. There are reasons for and against this approach. ODI would probably be the better choice unless you really need to have FDM's process support.
    Regards,
    Matt

  • What are the logical structure and physical structure in oracle

    what are the logical structure and physical structure in oracle and how can allocate a DB block size as default size is 8192?

    From the Concepts Guide
    http://download-east.oracle.com/docs/cd/B19306_01/server.102/b14220/toc.htm
    The physical structures are:
    Datafiles
    Control Files
    Redo Log Files
    Archive Log Files
    Parameter Files
    Alert and Trace Log Files
    Backup Files
    The Logical Structures are:
    Tablespaces
    Oracle Data Blocks
    Extents
    Segments

  • How to check/find the size of current ROLLBACK segment in oracle 10g

    How to check/find the size of current ROLLBACK segment in oracle 10g ? Kindly help

    A rollback segment name like "_SYSSMU231$" is used when you have Automatic Undo Management enabled.
    The only relevant parameters are :
    1. UNDO_MANAGEMENT=AUTO
    2. UNDO_RETENTION=n minutes ==> this is what everyone should be interested in
    3. The sizes of the Undo Tablespace datafiles and whether AUTOEXTEND is ON or OFF
    No one should be interested in the size of a single undo segment when Automatic Undo Management is enabled.
    Possible causes of ORA-01555 errors in Automatic Undo Management
    a. UNDO_RETENTION is too low
    b. Undo tablespace is too small
    Hemant K Chitale

  • See the detalis of DDL commands executing on oracle 10g

    Hi,
    how can i see the detail of DDL command executed on oracle 10g on ECC 6.0
    ECC 6.0
    HPUX
    Regards,

    Did you activated the auditing mechanish on the Oracle? If it is active, you can query the audit table;
    select * from sys.aud$;
    Another way is using Oracle Log Miner. You can find the related information, on the link below;
    http://docs.oracle.com/cd/B10501_01/server.920/a96521/logminer.htm
    Best regards,
    Orkun Gedik

Maybe you are looking for

  • Windows Update Error (code: 80070490)

    Dear Moderator, I have a problem, i could not use windows update from 3 days ago. I've tried to fix it by system restore, but it didn't work. I read the information at http://support.microsoft.com/kb/958044, the problem may occur if there is corrupti

  • How to write the expression for multiple texbox selection using single textbox status

    Hii frnz, can you see  the below image  if the value of the text box is stopped means Red i want to display the entire row(all the texboxs values should be displayd in the red colour only) should be display in Red colour only.  How to implemet it is

  • Event Flow

    Hi! If i have a container, with some sprites and this sprites containes other sprites, wich is the best way to target the Event to the second level of sprite? Container: - sprite1 ---> contain n sprite - sprite 2 --> contain n sprite - sprite 3 --> c

  • Using the isight camera in the bootcamp setup with windows 8.1

    Hi I am running OSX Maverick in a bootcamp setup with Windows 8.1 and have played around with the isight camera but I would like to know what folder the photo's/video's are sent to? Also, are there any settings or user guide for the isight camera in

  • Error: Failed To Read Phone's File System

    I'm using PC Suite 7.0.8.2 on XP SP3 connected to a Nokia 6300. I keep getting an error message when I click on Nokia Video Manager. The message states "Failed to read phone's file system. Internal error occurred". Video manager then hangs. I see it