Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.server -> Re: a problem in about CHAR column in the select statement

Re: a problem in about CHAR column in the select statement

From: spencer <spencerp_at_swbell.net>
Date: 2000/07/10
Message-ID: <lCxa5.306$BC3.96570@nnrp2.sbc.net>#1/1

change your sql statement:

  prepareStatement("select id from temp where col = ?");

to:

  prepareStatement("select id from temp where col = RPAD( ? ,128)");

or:

  prepareStatement("select id from temp where col = PAD(SUBSTR( ? ,1,128),128)"); HTH <xinhuang00_at_my-deja.com> wrote in message news:8k5964$1lm$1_at_nnrp1.deja.com...
> Hi everyone, I really need a help here:
> I try to select a record from a table in Oracle by a CHAR
 column, but
> the record can not match because of the tailing blanks in the
 column:
>
> >Class.forName( "oracle.jdbc.driver.OracleDriver" );
> >System.out.println ("registered driver");
> >Connection conn =
> > DriverManager.getConnection

 ("jdbc:oracle:thin:@localhost:1521:orcl","scott", "tiger");
> >conn.setAutoCommit (true);
> >Statement stmt = conn.createStatement ();
> >ResultSet rset;
> >rset = stmt.executeQuery("create table temp (id int, col
 char(128))");
> >PreparedStatement pstmt;
> >pstmt = conn.prepareStatement("insert into temp (id, col)
 values
 (?,?)");
> >pstmt.setInt(1,1);
> >pstmt.setString(2,"aa");
> >rset = pstmt.executeQuery();
> >pstmt = conn.prepareStatement("select id from temp where col

Received on Mon Jul 10 2000 - 00:00:00 CDT

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US