Results 1 to 4 of 4
  1. #1
    Join Date
    May 2003
    Posts
    2

    Red face Unanswered: casting in default value clause

    I am using UDB version 7.1. I want to create a tbale with one varchar column. I want the column to have default value that of current timestamp. I declared the column as col1 VARCHAR(25) DEAFULT VARCHAR( CURRENT TIMESTAMP)

    But I am getting an error which says the value does not match the column type.

    Can you tell me how to get around the problem ? Is VARCHAR casting is allowed in the default clause of the create table statement.


    Thanks in advance
    Debjit

  2. #2
    Join Date
    May 2003
    Posts
    113

    Re: casting in default value clause

    There are two things you can try:
    1) use COL1 VARCHAR(19), or VARCHAR(26), I am not very sure about the length. But your can figure it out by: select length(VARCHAR(CURRENT TIMESTAMP) ) from anytable
    2) use biF VARCHAR_FORMAT() insteads of VARCHAR()

    GOOD LUCK

    Originally posted by debjit_das
    I am using UDB version 7.1. I want to create a tbale with one varchar column. I want the column to have default value that of current timestamp. I declared the column as col1 VARCHAR(25) DEAFULT VARCHAR( CURRENT TIMESTAMP)

    But I am getting an error which says the value does not match the column type.

    Can you tell me how to get around the problem ? Is VARCHAR casting is allowed in the default clause of the create table statement.


    Thanks in advance
    Debjit

  3. #3
    Join Date
    May 2003
    Location
    USA
    Posts
    5,737
    Just out of curiosity, if the length is always the same (26 with the embedded dashes and periods), why would you use varchar instead of char(26)? Of course the obvious question is why not use timestamp (which only uses 10 bytes), but there must be a story behind that one.

  4. #4
    Join Date
    May 2003
    Posts
    113
    An easy answer for entry level user is they don't know TIME/DATE/TIMESTAMP DATATYPE or don't know how to use it.

    An tech answer for expert user is TIME/DATE/TIMESTAMP datatype is sort of sql datatype, that is host language don't have base datatype to
    map it. Such as c/c++, java, a string type is easier to code and to query


    Originally posted by Marcus_A
    Just out of curiosity, if the length is always the same (26 with the embedded dashes and periods), why would you use varchar instead of char(26)? Of course the obvious question is why not use timestamp (which only uses 10 bytes), but there must be a story behind that one.

Posting Permissions

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