Results 1 to 5 of 5
  1. #1
    Join Date
    Aug 2003
    Posts
    58

    Unanswered: 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

  2. #2
    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

  3. #3
    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 14:13.

  4. #4
    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

  5. #5
    Join Date
    Jun 2003
    Location
    Toronto, Canada
    Posts
    5,516
    Provided Answers: 1
    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.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •