The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Dummies Questions & Answers
.
google unix.com




View Single Post in the UNIX and Linux Forums - Click on the Thread or Permalink to View Entire Thread -->
  #2 (permalink)  
Old 09-28-2006
jim mcnamara jim mcnamara is offline Forum Staff  
...@...
  
 

Join Date: Feb 2004
Location: NM
Posts: 5,748
Oracle already has date arithmetic, ksh doesn't - use PL/SQL:
Code:
#!/bin/ksh

date_equal()
{

sqlplus -silent rep/Ndk38f7@dw <<END
set pagesize 0 feedback off verify off heading off echo off serverout on size 100000
DECLARE 
   date1 DATE:=NULL;
   date2 DATE:=NULL;
BEGIN
DBMS_OUTPUT.enable(100000);
select trunc(max(chg_dt)) into date1 from NOT_SCHEDULED_INSTALL;
select trunc(sysdate) into date2 from dual;
IF date1 = date2
THEN
	DBMS_OUTPUT.put_line('1');
ELSE
    DBMS_OUTPUT.put_line('0');
END IF;
END;
/
exit;
END

}

if [[ $(date_equal) -eq 1 ]] ; then
# do something 
else
# do something else
fi