Results 1 to 3 of 3
  1. #1
    Join Date
    Dec 2012
    Posts
    3

    Unanswered: Encrypting varchar

    Hi,
    I am on DB2 Version 9.7. I create a table with below definition:

    db2 "create table tvar2(name varchar(10))"

    and then I try to insert into the above table using below command:

    db2 "insert into tvar2 values(encrypt('a'))"

    which throws below error:
    SQL0433N Value " ~" is too long. SQLSTATE=22001

    Why is it not allowing me to insert data into encrypted form?

  2. #2
    Join Date
    Mar 2003
    Posts
    280
    Quote Originally Posted by db2udbuser View Post
    Hi,
    I am on DB2 Version 9.7. I create a table with below definition:

    db2 "create table tvar2(name varchar(10))"

    and then I try to insert into the above table using below command:

    db2 "insert into tvar2 values(encrypt('a'))"

    which throws below error:
    SQL0433N Value " ~" is too long. SQLSTATE=22001

    Why is it not allowing me to insert data into encrypted form?
    It does, you just have to allocate room for it:

    $ db2 "describe values encrypt('a','bbbbbb')"

    Column Information

    Number of columns: 1

    SQL type Type length Column name Name length
    -------------------- ----------- ------------------------------ -----------
    448 VARCHAR 16 1 1
    --
    Lennart

  3. #3
    Join Date
    Apr 2006
    Location
    Belgium
    Posts
    2,514
    Provided Answers: 11
    as indicated in doc :
    The result data type of the function is VARCHAR FOR BIT DATA.
    - When the optional hint parameter is specified, the length attribute of the result is equal to the length attribute of the unencrypted data + 8 bytes + the number of bytes until the next 8-byte boundary + 32 bytes for the length of the hint.
    - When the optional hint parameter is not specified, the length attribute of the result is equal to the length attribute of the unencrypted data + 8 bytes + the number of bytes until the next 8-byte boundary.
    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

Posting Permissions

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