4 Replies Latest reply on May 8, 2002 2:50 PM by rgjawanda

    ORACLE CHAR  type and String length problems.

    rgjawanda

      I have an oracle table that (Oracle 7) that has CHAR(16) fields that I can't change. The data comes out with spaces prepending the data.
      For example

      char(16) name
      When I print out the name the Java String looks like this

      "myname"

      But the length is 16.
      Is there any way to resolve this using JBOSS?

      It is possible that the data is being inserted in with blanks in the actual data " myname"
      but the extraction of the data via jboss CMP 1.0 In jboss 2.2.4 seems to drop the spaces but ???
      I am confused.
      Hope someone can help me.
      Ron

        • 1. Re: ORACLE CHAR  type and String length problems.
          rgjawanda

          Oh yeah..
          This is how my string is defined

          <java-type>java.lang.String</java-type>
          <jdbc-type>VARCHAR</jdbc-type>
          <sql-type>VARCHAR2(255)</sql-type>



          But my field is char(16) and i guess it is using this mapping because it does fill in the string.


          • 2. Re: ORACLE CHAR  type and String length problems.
            rgjawanda

            SQL> describe baan.ttisfc954001;
            Name Null? Type
            ------------------------------- -------- ----
            T$CPRJ NOT NULL CHAR(6)
            T$HPRD NOT NULL NUMBER
            T$MITM NOT NULL CHAR(16)
            T$MPOL NOT NULL NUMBER
            T$MORD NOT NULL NUMBER
            T$MREV NOT NULL CHAR(6)
            T$PONO NOT NULL NUMBER
            T$SEQN NOT NULL NUMBER
            T$OCMP NOT NULL NUMBER
            T$INDT NOT NULL DATE
            T$EXDT NOT NULL DATE
            T$SITM NOT NULL CHAR(16)
            T$OPOL NOT NULL NUMBER
            T$REVI NOT NULL CHAR(6)
            T$SORD NOT NULL NUMBER
            T$QANA NOT NULL NUMBER
            T$ADDN NOT NULL NUMBER
            T$REFCNTD NOT NULL NUMBER
            T$REFCNTU NOT NULL NUMBER

            SQL>


            SQL> select T$SITM from baan.ttisfc954001 where T$CPRJ='219657' and T$HPRD=200448 and T$MITM='
            2330549';

            T$SITM
            ----------------
            KIT
            013X08
            344X28
            386X68
            832X41
            2083918
            CLAMP
            INJECTION
            2339296

            9 rows selected.

            SQL>


            My sql query returns "INJECTION" with a length of 16 even though it is 9 in length.

            • 3. Re: ORACLE CHAR  type and String length problems.
              l.g.

              Try:
              <java-type>java.lang.String</java-type>
              <jdbc-type>CHAR</jdbc-type>
              <sql-type>CHAR(16)</sql-type>

              • 4. Re: ORACLE CHAR  type and String length problems.
                rgjawanda

                Thanks
                I think that did it.
                Ron