[Date Prev][Date Next][Thread Prev][Thread Next]
[Author Index] [Date Index] [Thread Index]
[SQR-USERS Info] [SQRUG Home Page]

Help with Insert



Hi Gurus,

I'm working on uploading employees' time from a flat file to a
temporary table. Besides a few earnings
codes, everything is a straight  upload. I'm having problems with the
'DIM', 'TPT' earnings codes.
when 'DIM' is read from the file and the employee posts xhours for DIM,
the program will
assign xhours to DIM and (xhours * .5) to 'REG'. If TPT is read with
xhours, xhours will be posted
for TPT and xhours for 'REG'. Here are the steps I follow.

1. Read the input file
2. Put what is read into variables
3. Validate employee data (if exists).
4. Edit earning codes
5. Check if employee already has a REG earning code for the same date
(Apr. 9,1999)
6. If yes
        if earning code = 'DIM'
                let #Input-hours = #Input-hours
                Insert the DIM record then
                Update the REG record by adding #Input-hour/2 to it
7. If no,
                Insert the DIM and REG records.
8. Similar process for the 'TPT' earning code.
9. When I read earnings codes other than 'DIM' and 'TPT', I check for a
REG line before inserting
   the record.
   If exists,
           Update the existing record by adding to the existing line
   if not, insert the new line.

All other earning codes load properly execpt 'REG'. I have an error
message saying 'ORA error, trying
to insert a NULL value in a column that doesn't allow NULL values.)

Any ideas on why it's happening. Thanks in advance for your insight.

BS.


_________________________________________________________
Do You Yahoo!?
Get your free @yahoo.com address at http://mail.yahoo.com
!--------------------------------------------------------------------------------------
begin-procedure Process-Erncd
!--------------------------------------------------------------------------------------

    display 'Inside Process Erncd'

    evaluate $Input-Erncd
        when = 'DIM'
          display 'Found one DIM Worker'
                 if $ErrorFound = 'N' and $Input-Work-Dt <= $pay_end_dt
                        display 'Sunday erncd to be processed: ' noline
                        display $Input-erncd
                       let #Input-hours = #Input-hours
                        display #Input-hours
                        add #Input-hours to #total-hours
                      do Insert-New-Record
                        do Find-Existing-Reg-Record
                        if $Found_Reg = 'Y'
                           move 'REG' to $input-Erncd
                           let #Input-hours = #Input-hours * .5
                           let $Input-hours = to_char(#Input-hours)
                           display 'New hours for REG: ' noline
                           display #Input-hours
                           do Update-Regular-Earnings

                        else
                           move $jobcode to $jobcode_save
                           move 'REG' to $input-Erncd
                           let #Input-hours = #Input-hours * .5
                           let $Input-hours = to_char(#Input-hours)
                           display 'New hours for REG: ' noline
                           display #Input-hours
                                if $jobcode = $jobcode_save
                                        do Insert-New-Record
                                end-if
                        end-if
                  end-if
        do Clean-Variables
          break


        when = 'TPT'
          display 'Found a Shift Premium Earning Code'
                 if $ErrorFound = 'N' and $Input-Work-Dt <= $pay_end_dt
                        display 'Shift erncd to be processed: ' noline
                        display $Input-erncd
                        display #Input-hours
                        add #Input-hours to #total-hours
                      do Insert-New-Record
                        do Find-Existing-Reg-Record
                        if $Found_Reg = 'Y'
                           display 'Found existing REG record for employee: ' 
noline
                           display $Input-emplid
                           move 'REG' to $input-Erncd
                           let #Input-hours = #Input-hours
                           let $Input-hours = to_char(#Input-hours)
                           display 'Updating REG for: ' noline
                           display #Input-hours
                           do Update-Regular-Earnings
                        else
                           if $Found_Reg = 'N'
                               display 'Did not find REG, inserting: ' noline
                               display #Input-hours
                               move $jobcode to $jobcode_save
                               display 'Jobcode: ' noline
                               display $jobcode_save
                               move 'REG' to $input-Erncd
                                display $Input-erncd
                               let #Input-hours = #Input-hours
                               let $Input-hours = to_char(#Input-hours)
                               move $jobcode to $jobcode_save
                               display 'Jobcode: ' noline
                               display $jobcode_save
                               if $jobcode = $jobcode_save
                                      do Insert-New-Record
                               end-if
                           end-if
                        end-if
                  end-if
        do Clean-Variables
          break

          when-other
              if $ErrorFound = 'N' and $Input-Work-Dt <= $pay_end_dt

                 if $Input-erncd <> 'REG'
                           add #Input-hours to #total-hours
                          do Insert-New-Record
                 else
                        do Find-Existing-Reg-Record
                           if $Found_Reg = 'Y'
                              add #Input-hours to #total-hours
                              do Update-Regular-Earnings
                           else
                      display 'Earning: ' noline
                              display #Input_hours
                              add #Input-hours to #total-hours
                              do Insert-New-Record
                           end-if
                end-if
           end-if
           break
        do Clean-Variables
     end-evaluate
     display 'Total Hours uploaded from the file: ' noline
     display #total-hours

end-procedure