IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

Db2 interview Question


IBM Mainframe Forums -> Mainframe Interview Questions
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
trushant.w

New User


Joined: 22 Sep 2013
Posts: 81
Location: pune india

PostPosted: Sat Mar 15, 2014 3:58 pm
Reply with quote

Multiple times i have come across below question in interview.

How to retive current date,time and timestramp from a table and how to recieve them in host varibales

I give them below answers but they wanted to retieve from the table
SELECT CURRENT_TIME FROM SYSIBM.SYSDUMMY1;
SELECT CURRENT_DATE FROM SYSIBM.SYSDUMMY1;
SELECT CURRENT_TIMESTAMP FROM SYSIBM.SYSDUMMY1;
Back to top
View user's profile Send private message
dick scherrer

Moderator Emeritus


Joined: 23 Nov 2006
Posts: 19244
Location: Inside the Matrix

PostPosted: Sun Mar 16, 2014 3:26 am
Reply with quote

Hello,

Quote:
but they wanted to retieve from the table


From which table? I don't understand.
Back to top
View user's profile Send private message
Anuj Dhawan

Superior Member


Joined: 22 Apr 2006
Posts: 6250
Location: Mumbai, India

PostPosted: Sun Mar 16, 2014 10:34 pm
Reply with quote

You could use:

Code:
select current_timestamp from <table-name> fetch first 1 rows only
or
Code:
EXEC SQL
SET :CURRENT-DATE-TIME = CURRENT TIMESTAMP
END-EXEC.
Back to top
View user's profile Send private message
Chetan Kumar

New User


Joined: 03 Dec 2012
Posts: 46
Location: India

PostPosted: Thu Oct 15, 2015 8:49 pm
Reply with quote

Hi, you could use select query as below

SELECT CURRENT_TIME INTO :CURRENT-TIME FROM SYSIBM.SYSDUMMY1;
SELECT CURRENT_DATE INTO :CURRENT-DATE FROM SYSIBM.SYSDUMMY1;
SELECT CURRENT_TIMESTAMP INTO :CURRENT-TIMESTAMP FROM
SYSIBM.SYSDUMMY1;

Where Variable preceding colon (:) are called host variables.

Equivalent in COBOL is X(8), X(10) and X(26) respectively.
Back to top
View user's profile Send private message
Rohit Umarjikar

Global Moderator


Joined: 21 Sep 2010
Posts: 3049
Location: NYC,USA

PostPosted: Fri Oct 16, 2015 1:23 am
Reply with quote

Chetan, thats a year old post.
Back to top
View user's profile Send private message
Nic Clouston

Global Moderator


Joined: 10 May 2007
Posts: 2455
Location: Hampshire, UK

PostPosted: Fri Oct 16, 2015 4:56 pm
Reply with quote

And that is exactly what was posted in the original post.
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> Mainframe Interview Questions

 


Similar Topics
Topic Forum Replies
No new posts Question for file manager IBM Tools 7
No new posts question for Pedro TSO/ISPF 2
No new posts question on Outrec and sort #Digvijay DFSORT/ICETOOL 20
No new posts panel creation question TSO/ISPF 12
No new posts Sort w/OUTREC Question DFSORT/ICETOOL 2
Search our Forums:

Back to Top