Results 1 to 11 of 11
  1. #1
    Join Date
    Feb 2004
    Location
    earth
    Posts
    96

    Unanswered: Oracle and DB2 10.5

    Hi,
    In Oracle, you can create a table such as

    Create table abc
    (col1 varchar2(100),
    col2 varchar2(100),
    col3 char(1 char) not null)
    IN "tablespace1"

    I have created db2 database with oracle compatibility=ora, however when I try to create the above table object, it will give an error of
    An unexpected token "CODEUNITS32" was found following "<length>". Expected tokens may include: ")".. SQLCODE=-104, SQLSTATE=42601, DRIVER=4.16.53

    Does DB2 support col3 char(1 char not null) or is there any alternative?

    Thank you

  2. #2
    Join Date
    Apr 2006
    Location
    Belgium
    Posts
    2,514
    Provided Answers: 11
    according the doc
    col3 char(1) not null
    Best Regards, Guy Przytula
    Database Software Consultant
    Good DBAs are not formed in a week or a month. They are created little by little, day by day. Protracted and patient effort is needed to develop good DBAs.
    Spoon feeding : To treat (another) in a way that discourages independent thought or action, as by overindulgence.
    DB2 UDB LUW Certified V7-V8-V9-V9.7-V10.1-V10.5 DB Admin - Advanced DBA -Dprop..
    Information Server Datastage Certified
    http://www.infocura.be

  3. #3
    Join Date
    Jun 2003
    Location
    Toronto, Canada
    Posts
    5,516
    Provided Answers: 1
    This syntax should work in 10.5, but only if the database is created with the UTF-8 code set. What's the output of
    Code:
    db2 get db cfg | grep "code set"
    ---
    "It does not work" is not a valid problem statement.

  4. #4
    Join Date
    Dec 2008
    Location
    Toronto, Canada
    Posts
    399
    it should be
    col3 char(1) not null
    DB2 9.5/9.7 on Unix/AIX 6.1/Linux

  5. #5
    Join Date
    Feb 2004
    Location
    earth
    Posts
    96
    Hello Prytula, will there any issue if I create col3 as char(1) to store multibyte character?

    Hello n_i,
    The database codeset is UTF-8.
    When I try to create the above table abc, it will return the following error.
    SQL0104N An unexpected token "CODEUNIT32" was found following "<length>". Expected tokens may include: ")".SQLSTATE=42601.

    Thanks in advance!

  6. #6
    Join Date
    Feb 2004
    Location
    earth
    Posts
    96
    Hi MarkamDBA,

    Thanks for reply.
    Will it give an issue such as truncate with col3 char(1) not null when store multibyte character such as chinese,korea, japanese? Thank you

  7. #7
    Join Date
    Jun 2003
    Location
    Toronto, Canada
    Posts
    5,516
    Provided Answers: 1
    Quote Originally Posted by eshl View Post
    The database codeset is UTF-8.
    When I try to create the above table abc, it will return the following error.
    SQL0104N An unexpected token "CODEUNIT32" was found following "<length>". Expected tokens may include: ")".SQLSTATE=42601.
    Looks like this is a documentation error. CHAR (or CODEUNITS32) length semantics support is not yet there.

    Note that "col3 char(1) not null" will define the column with the length of 1 byte. If you intend to store multibyte characters, increase the lengths of character fields accordingly.
    ---
    "It does not work" is not a valid problem statement.

  8. #8
    Join Date
    Feb 2004
    Location
    earth
    Posts
    96
    Thanks n_i. I have created char(3) for the length of 1 byte and it allow to insert the character. Thank you

  9. #9
    Join Date
    Apr 2006
    Location
    Belgium
    Posts
    2,514
    Provided Answers: 11
    or graphic(1) could be used to store 1 character composed of 1 - multi bytes
    Best Regards, Guy Przytula
    Database Software Consultant
    Good DBAs are not formed in a week or a month. They are created little by little, day by day. Protracted and patient effort is needed to develop good DBAs.
    Spoon feeding : To treat (another) in a way that discourages independent thought or action, as by overindulgence.
    DB2 UDB LUW Certified V7-V8-V9-V9.7-V10.1-V10.5 DB Admin - Advanced DBA -Dprop..
    Information Server Datastage Certified
    http://www.infocura.be

  10. #10
    Join Date
    Jun 2003
    Location
    Toronto, Canada
    Posts
    5,516
    Provided Answers: 1
    Quote Originally Posted by eshl View Post
    I have created char(3) for the length of 1 byte
    The length of a CHAR(3) data type is 3 bytes.
    ---
    "It does not work" is not a valid problem statement.

  11. #11
    Join Date
    Feb 2004
    Location
    earth
    Posts
    96
    Thanks Przytula.
    Yes, you are right n_i. char(3) data type is 3 bytes.

Posting Permissions

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