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

DB2 Alter Table command - default value


IBM Mainframe Forums -> DB2
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
chan2004

New User


Joined: 28 Mar 2007
Posts: 16
Location: India

PostPosted: Thu Sep 13, 2007 6:05 pm
Reply with quote

Hi,

I am trying to run the following DB2 command to alter a column to set its default value as given below.



ALTER TABLE OA2A.TCK020A1
ALTER COLUMN CK020032 SET DEFAULT '0';

But this gives me an error:-

DSNT408I SQLCODE = -199, ERROR: ILLEGAL USE OF KEYWORD DEFAULT, TOKEN DATA WAS EXPECTED

DSNT418I SQLSTATE = 42601 SQLSTATE RETURN CODE
DSNT415I SQLERRP = DSNHPARS SQL PROCEDURE DETECTING ERROR
DSNT416I SQLERRD = 0 0 0 -1 103 0 SQL DIAGNOSTIC INFORMATION
DSNT416I SQLERRD = X'00000000' X'00000000' X'00000000' X'FFFFFFFF'
X'00000067' X'00000000' SQL DIAGNOSTIC INFORMATION

-------------------------------------------------
The column is a character field
I want to have a default value of zero('0').

When I checked the manuals for the alter command, it didn't have any command to set a default value for an existing table.
My DB2 version is 7
Pls give me some advice to proceed further

Thanks in advance
Chan
Back to top
View user's profile Send private message
Craq Giegerich

Senior Member


Joined: 19 May 2007
Posts: 1512
Location: Virginia, USA

PostPosted: Thu Sep 13, 2007 6:55 pm
Reply with quote

chan2004 wrote:
Hi,

I am trying to run the following DB2 command to alter a column to set its default value as given below.



ALTER TABLE OA2A.TCK020A1
ALTER COLUMN CK020032 SET DEFAULT '0';

But this gives me an error:-

DSNT408I SQLCODE = -199, ERROR: ILLEGAL USE OF KEYWORD DEFAULT, TOKEN DATA WAS EXPECTED

DSNT418I SQLSTATE = 42601 SQLSTATE RETURN CODE
DSNT415I SQLERRP = DSNHPARS SQL PROCEDURE DETECTING ERROR
DSNT416I SQLERRD = 0 0 0 -1 103 0 SQL DIAGNOSTIC INFORMATION
DSNT416I SQLERRD = X'00000000' X'00000000' X'00000000' X'FFFFFFFF'
X'00000067' X'00000000' SQL DIAGNOSTIC INFORMATION

-------------------------------------------------
The column is a character field
I want to have a default value of zero('0').

When I checked the manuals for the alter command, it didn't have any command to set a default value for an existing table.
My DB2 version is 7
Pls give me some advice to proceed further

Thanks in advance
Chan


You have to set the default value when you define the column.
Back to top
View user's profile Send private message
chan2004

New User


Joined: 28 Mar 2007
Posts: 16
Location: India

PostPosted: Fri Sep 14, 2007 11:04 am
Reply with quote

Hi Craig,

Isn't there any way i can alter the definition cause it will be a lot of rework
icon_sad.gif

Thanks,
Chan
Back to top
View user's profile Send private message
Craq Giegerich

Senior Member


Joined: 19 May 2007
Posts: 1512
Location: Virginia, USA

PostPosted: Fri Sep 14, 2007 7:32 pm
Reply with quote

chan2004 wrote:
Hi Craig,

Isn't there any way i can alter the definition cause it will be a lot of rework
icon_sad.gif

Thanks,
Chan

No way that I know of.
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


Joined: 20 Oct 2006
Posts: 6966
Location: porcelain throne

PostPosted: Sat Sep 15, 2007 2:53 am
Reply with quote

chan2004,

you need to work on your attention to detail - that's why your original create was erroneous.

Mr Giegerich's first name is Craq not Craig.
Back to top
View user's profile Send private message
Craq Giegerich

Senior Member


Joined: 19 May 2007
Posts: 1512
Location: Virginia, USA

PostPosted: Sat Sep 15, 2007 9:07 am
Reply with quote

dbzTHEdinosauer wrote:
chan2004,

you need to work on your attention to detail - that's why your original create was erroneous.

Mr Giegerich's first name is Craq not Craig.


Actually CRAIG is correct, I fat fingered it when I registered and haven't bothered correcting it.
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


Joined: 20 Oct 2006
Posts: 6966
Location: porcelain throne

PostPosted: Sat Sep 15, 2007 8:47 pm
Reply with quote

Craig,

I stand corrected - about the spelling of your name.
Back to top
View user's profile Send private message
chan2004

New User


Joined: 28 Mar 2007
Posts: 16
Location: India

PostPosted: Mon Sep 17, 2007 10:21 am
Reply with quote

guys,

first of all i would like to mention is that the new change has been asked by the client after the declaration.
there's nothing i could have done

anyway, thanks for the quick reply

Chan icon_smile.gif
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 -> DB2

 


Similar Topics
Topic Forum Replies
No new posts RACF - Rebuild SETROPTS command which... All Other Mainframe Topics 3
No new posts Load new table with Old unload - DB2 DB2 6
No new posts Routing command Address SDSF to other... TSO/ISPF 2
No new posts Pulling a fixed number of records fro... DB2 2
No new posts DTL - how to define key with stacked ... TSO/ISPF 3
Search our Forums:

Back to Top