473,386 Members | 1,733 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

How to declare timestamp variable with default as current timestamp not working.

I have a variable declaration inside a procedure which is not compiling in db2 9.5 :-
DECLARE VSTARTTIME TIMESTAMP DEFAULT CURRENT TIMESTAMP;

The procedure is a test procedure :-
DROP PROCEDURE ABC_1
@
CREATE PROCEDURE ABC_1
(
INOUT STARTTIME TIMESTAMP ,
INOUT ENDTIME TIMESTAMP ,
OUT DIFFTIME DECIMAL(15,10)
)
LANGUAGE SQL
BEGIN
DECLARE VSTARTTIME TIMESTAMP DEFAULT CURRENT TIMESTAMP;
BEGIN
SET STARTTIME = VSTARTTIME ;
VALUES CURRENT TIMESTAMP INTO ENDTIME;
VALUES ENDTIME-STARTTIME INTO DIFFTIME;
END;

END
@

COMPILATION ERROR --
SQL0104N An unexpected token "CURRENT TIMESTAMP" was found following "ME
TIMESTAMP DEFAULT". Expected tokens may include: "<literal>". LINE
NUMBER=9. SQLSTATE=42601

Please suggest why this is not working?
Sep 3 '10 #1
1 11802
Cannot specify a default like that.. set the variables instead.
Oct 9 '10 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

29
by: Friday | last post by:
Sorry if this is the wrong group. I tried to find the one I thought would be most relevant. I'm an old PHP guy, who knows little about asp and NOTHING about asp.net, but need to learn at least...
0
by: qwerty_1997 | last post by:
Hi, I can't work out exactly what I need to do with datetime and timestamp, can anyone help? I would like a column created_timestamp to be populated on record creation (and preferably not...
2
by: Alex | last post by:
Hi all, Got a small problem here. I have a number of web caches here that generate loads and loads of log files and instead of keeping them for analysis I want to write them to a db/2...
2
by: ross.oneill | last post by:
Hi, I am having trouble with a simple task of declaring a variable. Is this possible? Here is what I want to do. DECLARE start_date date; DECLARE end_date date; SET start_date =...
16
by: Brian Tkatch | last post by:
I have a PROCEDURE that test other PROCEDUREs. Timings_Call ------------------ Id Group Name Text Timings_Log
1
by: tiedyelime | last post by:
is there a way to use the current system timestamp as a variable in XML? <FMCmd> <ParentId>860aa610677211daa185a5634fbc8490</ParentId> <NewsItem> ...
5
by: shethsheetal | last post by:
I am having some problem with the below mentioned trigger. CREATE TRIGGER D.TBA AFTER UPDATE OF TBAA.CIC ON TBAA REFERENCING NEW AS NEW_ROW FOR EACH ROW MODE DB2SQL BEGIN ATOMIC DECLARE RS...
1
rickbray66
by: rickbray66 | last post by:
DB2 Express for Windows: DB2 v9.1.200.166 Hello. I've recently started working with DB2. I'm in the process of migrating a DDL from MySQL over to DB2. Consider the following snipet: ...
7
by: Damir | last post by:
I have a situation on a DB server where the "current timestamp" command shows the actual system time offset by one hour, which has never been noticed before?!? The DB2 is V9.1 (FP03), running on...
4
by: KEV999 | last post by:
Would like any suggestions please on how to achieve this - I'm using MS Access 2003. At present for a simple data entry situation using a form, the user entering the data enters their intials into...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.