If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > DB2 > How do I set the default value of a new BIT DATA column?

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 05-03-04, 12:16
wayneb64 wayneb64 is offline
Registered User
 
Join Date: Aug 2003
Posts: 58
How do I set the default value of a new BIT DATA column?

I need to add a new column for 8 bytes of data to a table that will not
be null. The following produces the error below:

ALTER TABLE MSTRDATA.USERS ADD COLUMN ENCRYPTEDPW VARCHAR(8) FOR BIT DATA NOT NULL DEFAULT 0

SQL0574N DEFAULT value or IDENTITY attribute value is not valid for column
"ENCRYPTEDPW" in table "MSTRDATA.USERS". Reason code: "1". SQLSTATE=42894

Thanks,
Wayne
Reply With Quote
  #2 (permalink)  
Old 05-03-04, 12:31
wayneb64 wayneb64 is offline
Registered User
 
Join Date: Aug 2003
Posts: 58
On the same subject, I cannot find any documentation or examples
on how to work with a BIT DATA column. What is the syntax
for an INSERT, UPDATE, or a QUERY?

Also, for java.sql, I have worked with ints, floats, strings, timestamps,
and a little with blobs, but have no clue, nor can I see any documentation
on how to work with an 8 byte field. Any help would be greatly appreciated.

Thanks,
Wayne
Reply With Quote
  #3 (permalink)  
Old 05-03-04, 13:09
wayneb64 wayneb64 is offline
Registered User
 
Join Date: Aug 2003
Posts: 58
And the answer is:

ALTER TABLE MSTRDATA.USERS ADD COLUMN ENCRYPTEDPW VARCHAR(8) FOR BIT DATA NOT NULL DEFAULT x'0000000000000000';

iaw, DB2 understands a hex syntax (BUT DOES NOT DOCUMENT IT IN AN
EASY TO FIND PLACE IF AT ALL!!!)


But, I still dont know how to use this with java.sql.*

Last edited by wayneb64; 05-03-04 at 13:13.
Reply With Quote
  #4 (permalink)  
Old 05-03-04, 13:12
bmujeeb bmujeeb is offline
Registered User
 
Join Date: Mar 2004
Posts: 448
use that

ALTER TABLE MSTRDATA.USERS ADD COLUMN ENCRYPTEDPW VARCHAR(8) FOR BIT DATA NOT NULL DEFAULT '0'

if you select from that table you will see x'31' this is the hexadecimal equivalent.
bit data are not relevant to specific codepage.
I never tried that but can we use 0x000.....

regards,

mujeeb
Reply With Quote
  #5 (permalink)  
Old 05-03-04, 14:02
n_i n_i is offline
:-)
 
Join Date: Jun 2003
Location: Toronto, Canada
Posts: 4,449
Quote:
Originally Posted by wayneb64

But, I still dont know how to use this with java.sql.*
Use PreparedStatement and supply it with a String containing your encrypted password.
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On