Home » SQL & PL/SQL » SQL & PL/SQL » Timestamp gets truncated from cursor for loop (PL/SQL 11)
Timestamp gets truncated from cursor for loop [message #608535] Thu, 20 February 2014 11:31 Go to next message
DIPRINKS
Messages: 57
Registered: July 2013
Location: Michigan
Member
DECLARE
  P_JOB_NUMBER long;
  P_ERROR_IND  nchar;
BEGIN
P_JOB_NUMBER:=6666;
P_ERROR_IND:='Y';
  dbms_output.put_line('Job ' || P_JOB_NUMBER || ' Ended Status=' ||
                       P_ERROR_IND);
  IF P_ERROR_IND='N'
    THEN 
      DBMS_OUTPUT.PUT_LINE('No Errors in Admin Utility for this Group');
      ELSE
        DBMS_OUTPUT.PUT_LINE('---------------------------------------------------------------------------------');
        DBMS_OUTPUT.PUT_LINE('Note:Following errors can also be seen in the control report through Admin Utility');
  FOR cursor1 IN ( SELECT m.*
    FROM OWBREP.mdrlogd m
    WHERE --to_char(mdrlogd_run_date,'mm/dd/yyyy') =to_char(sysdate-13,'mm/dd/yyyy')---match till hh:mm
    trunc(mdrlogd_run_date) =trunc(sysdate-13)
       and mdrlogd_message like '%Error%'AND
          NVL(mdrlogd_jobno, 1)= NVL(P_JOB_NUMBER, 1)
        AND   mdrlogd_process ='EDW_DIM_GR2' ----'&MDRLOGD_PROCESS'--- 
    ORDER BY mdrlogd_sequence)
   
  LOOP   
    DBMS_OUTPUT.PUT_LINE('*** Run Date = ' || cursor1.mdrlogd_run_date ||'; Mapping = ' || cursor1.mdrlogd_procedure||';Error Message = ' || cursor1.mdrlogd_message ||';
    Process = ' || cursor1.mdrlogd_process||'; Job No = ' || cursor1.mdrlogd_jobno);
  END LOOP;
    END IF;                 
                       
END;


The output of the above code is :

Job 6666 Ended Status=Y
---------------------------------------------------------------------------------
Note:Following errors can also be seen in the control report through Admin Utility
*** Run Date = 07-FEB-14; Mapping = CODE_DETAIL;Error Message = Error: Mapping Failed;
Process = EDW_DIM_GR2; Job No = 6666


In the database table OWBREP.mdrlogd,the value of this date column "mdrlogd_run_date" is 2/7/2014 12:17:32 AM.I want to display the same date with timestamp as run date.But it is getting truncated and converted to dd-mon-yy format.Please help.

Thanks.
Re: Timestamp gets truncated from cursor for loop [message #608536 is a reply to message #608535] Thu, 20 February 2014 11:40 Go to previous messageGo to next message
BlackSwan
Messages: 26766
Registered: January 2009
Location: SoCal
Senior Member
use TO_CHAR() function
Re: Timestamp gets truncated from cursor for loop [message #608537 is a reply to message #608536] Thu, 20 February 2014 11:42 Go to previous message
DIPRINKS
Messages: 57
Registered: July 2013
Location: Michigan
Member
Got it.Thanks

[Updated on: Thu, 20 February 2014 11:43]

Report message to a moderator

Previous Topic: how to get previous row value?
Next Topic: Retrieve Data from a Table based on OR condition
Goto Forum:
  


Current Time: Fri Apr 26 10:14:25 CDT 2024