6 Replies Latest reply on Aug 19, 2019 1:21 PM by 2710859

    need help on plsql

    2710859

      very new to the PLSQL and need help on the below requirement:

      Need to remove day and month from the current existing DOB column and keep YEAR only but not sure how to do this. Was able to query and display YEAR by using extract function

       

      CREATE OR replace PROCEDURE update_DOB

      IS

        CURSOR x IS

          SELECT dateofbirth

          FROM   personal;

       

      BEGIN

          FOR dob_update IN x LOOP

              declare update_sql varchar2(225);

              update_sql := 'UPDATE personal SET  '

                            || personal.dateofbirth

                            || '= EXTRACT(YEAR FROM dateofbirth, 'YYYY')';

          END LOOP;

      END;

      Procedure UPDATE_DOB compiled

      LINE/COL  ERROR
      --------- -------------------------------------------------------------
      10/20     PLS-00103: Encountered the symbol "=" when expecting one of the following:     constant exception <an identifier>    <a double-quoted delimited-identifier> table columns long    double ref char time timestamp interval date binary national    character nchar The symbol "<an identifier>" was substituted for "=" to continue.
      12/61     PLS-00103: Encountered the symbol "YYYY" when expecting one of the following:     * & = - + ; < / > at in is mod remainder not rem    <an exponent (**)> <> or != or ~= >= <= <> and or like like2    like4 likec between || member submultiset
      Errors: check compiler log