Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

Db2 interview Question

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> Mainframe Interview Questions
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    Post subject: Db2 interview Question
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

Site Director


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

PostPosted: Sun Mar 16, 2014 3:26 am    Post subject:
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

Senior Member


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

PostPosted: Sun Mar 16, 2014 10:34 pm    Post subject:
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: 35
Location: India

PostPosted: Thu Oct 15, 2015 8:49 pm    Post subject: Reply to: Db2 interview Question
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

Senior Member


Joined: 21 Sep 2010
Posts: 1610
Location: NY,USA

PostPosted: Fri Oct 16, 2015 1:23 am    Post subject:
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: 1715
Location: UK

PostPosted: Fri Oct 16, 2015 4:56 pm    Post subject:
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    IBMMAINFRAMES.com Support Forums -> Mainframe Interview Questions All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts Fault Analyzer - listings question. egrove IBM Tools 4 Thu Aug 11, 2016 5:31 pm
No new posts dataset copy question - REPRO or some... atulxp TSO/ISPF 2 Wed Aug 03, 2016 10:56 pm
No new posts SQL Order By related question Joseph K Thomas DB2 8 Fri Mar 18, 2016 12:53 pm
No new posts DFSort Question krrp DFSORT/ICETOOL 9 Mon Mar 07, 2016 7:11 pm
No new posts Where can i find Interview questions ... Elixir Mainframe Interview Questions 4 Sat Feb 20, 2016 12:38 am


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us