473,382 Members | 1,705 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,382 software developers and data experts.

Generated Column

10
I want a generated column which will have the current date as well as a running number concatenated yyyymmddxxxxxx
where xxxxxx is a running sequence.

Can I use a SQL query to generate the sequence No? I tried the follwing, but even something as simple as this doesnt work. It doesnt take Current date in the expression.

CREATE TABLE JS.TEST (
C1 INTEGER NOT NULL GENERATED ALWAYS AS (select month(current date) from sysibm.sysdummy1),
C2 CHARACTER (10) NOT NULL )
IN TS03_16K_OES INDEX IN IX03_4K_OES ;

Any help would be appreciated.
Aug 16 '07 #1
1 1633
Rahul B
11
Don't you have to do current_date instead of current date?

I want a generated column which will have the current date as well as a running number concatenated yyyymmddxxxxxx
where xxxxxx is a running sequence.

Can I use a SQL query to generate the sequence No? I tried the follwing, but even something as simple as this doesnt work. It doesnt take Current date in the expression.

CREATE TABLE JS.TEST (
C1 INTEGER NOT NULL GENERATED ALWAYS AS (select month(current date) from sysibm.sysdummy1),
C2 CHARACTER (10) NOT NULL )
IN TS03_16K_OES INDEX IN IX03_4K_OES ;

Any help would be appreciated.
Aug 18 '07 #2

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

Similar topics

2
by: db2group88 | last post by:
i would like to know when i create a table with identity column, should i used generated by default or generated as always. since when i create this table, i might copy some data from another table...
1
by: Robert Stearns | last post by:
I have two related questions. Why did I have to: SET INTEGRITY FOR is3.animals OFF; before doing: alter table is3.animals add column pseudo_id generated always as (coalesce(regnum,...
2
by: valerio | last post by:
Hi all, I've some problem to import data to DB2 using the db2move and db2look tools. Follow the problem : I have exported data from db2 v. 7 database on windows server, using the db2look and...
17
by: Darek | last post by:
Hi, I have a table, something similar to: create table my_table ( id char(32) not null primary key, num integer not null, code varchar(2) not null, name varchar(60) not null,
3
by: Jessard | last post by:
Hi all, Can anyone give me an example of how to change what code the designer will generate when creating a typed dataset using the VS wizard? I have been informed that this is possible but...
5
by: Veeru71 | last post by:
Given a table with an identity column (GENERATED BY DEFAULT AS IDENTITY), is there any way to get the last generated value by DB2 for the identity column? I can't use identity_val_local() as...
1
by: Manuel Jaen | last post by:
Hi everybody, I'm starting up with those generated columns of the DB2, but all the examples that I come up are simple, and as far as I've read the thing I want to do is not possible. Can someone...
3
by: tonialbrown | last post by:
I am having some problems with an update statement. The problem is the data comes from a list box lstDelFrom that the user selects for the required record that they are copying the data from. This...
4
by: Bernard Dhooghe | last post by:
Table definition: CREATE TABLE "SCHEMA1 "."X2" ( "C1" CHAR(20) NOT NULL , "C2" CHAR(10) NOT NULL , "C3" CHAR(30) NOT NULL GENERATED ALWAYS AS (C1|| C2) ) IN "USERSPACE1" ; -- DDL...
1
by: Frank Swarbrick | last post by:
We're trying to take advantage of the new ROW CHANGE TIMESTAMP option. Here is a simple table: CREATE TABLE "ACCTASGN"."NUMBER_STATUS" ( "STATUS_CODE" CHAR(1) NOT NULL , "STATUS_DESCRIPTION"...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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
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: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

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.