4 Replies Latest reply on Jun 24, 2004 2:15 PM by fbiaggi

    CHAR and Blanks

    cyberdoc

      Hi,

      is it possible to create a PK finder method to find values with the SQL type CHAR, without the filling blanks?

      Example:

      IS CHAR Value = 'TEST '

      SELECT VALUE FROM TEST_TABLE WHERE VALUE = 'TEST';
      -> result null

      SELECT VALUE FROM TEST_TABLE WHERE VALUE = 'TEST ';
      -> found one



      thx

      Michael

        • 1. Re: CHAR and Blanks
          aloubyansky

          No.

          • 2. Re: CHAR and Blanks
            cyberdoc

            A workaround?? Or do i need to know every field size?

            Michael

            • 3. Re: CHAR and Blanks
              jkarges

              I'am facing with the same problem.
              In my case: I'm connecting to a DB2 database. Some primary keys are VARCHARs. But in indices, DB2 always stores the max. string size specified in VARCHAR(n). The bevaiour exactly like your problem. The data out of the index comes like for CHAR columns: With spaces.

              As a workaround, I am wondering, if it is possible to trim all columns of type CHAR/VARCHAR in the result set, bevor the data is stored in the entity bean. Actually: No idea.

              • 4. Re: CHAR and Blanks
                fbiaggi

                Hi,
                this is DB dependent,
                for example on DB2/400 work fine.

                May be a good idea to avoid CHAR and use VARCHAR instead.

                Ciao.