As most of us are aware what a Sysdate Function performs , it does return a DATE value when you query the current system date . The Sysdate is a powerful function used very often when you want to consider the system date in various coding practices.If one wants the function to return a immediate next days date then just add a 1 to the sysdate as ( sysdate + 1 ) .This will return the immediate next day's date.
Usage : Select sysdate from dual ;
Coming to the Sql query to see the time stamp component , you need to convert the sysdate format into character specifying what format of date and time you want to see.
Solution : Select to_char ( sysdate , ' DD-MON-YYYY HH24:MI:SS ' ) from dual ;
The result would be similar to this :
The Sysdate includes the timestamp component also but while displaying it only shows the date component and when to convert that using to_char function you could see the time component also.
To exclude the time component from sysdate function ,
use - Trunc ( sysdate )
The above function truncates the time component and returns only date component .
Showing posts with label pl / sql notes. Show all posts
Showing posts with label pl / sql notes. Show all posts
Sunday, October 31, 2010
Friday, October 8, 2010
A small difference in usage of " if - else if - else " in pl/sql , vb , Unix
The underlying logic of all the programs are same , only there is slightly change in their syntax and usage.I had worked on VB 6 past so always in that mode whenever using the other languages like PL/SQL .As i was working on "if-then-else " for pl/sql and found that it was flashing the syntax error . There is a small difference of this usage in three languages .
The following are the differences of IF-THEN-ELSE used in VB , PL/SQL and UNIX shell scripts :
1) VB :
if ( condition ) then
some_statements
else if ( condition )
other_statements
end if
2) PL/SQL :
if ( condition ) then
some_statements ;
elsif ( condition )
other_statements ;
end if ;
UNIX :
if ( condition ); then
some_statements
eif ( condition );
other_statements
The following are the differences of IF-THEN-ELSE used in VB , PL/SQL and UNIX shell scripts :
1) VB :
if ( condition ) then
some_statements
else if ( condition )
other_statements
else
final_statementsend if
2) PL/SQL :
if ( condition ) then
some_statements ;
elsif ( condition )
other_statements ;
else
final_statements ;end if ;
UNIX :
if ( condition ); then
some_statements
eif ( condition );
other_statements
else
final_statements
Subscribe to:
Posts (Atom)
