0

I am trying to use Pro*C to access a TimesTen database. The code to create a table in TimesTen is

create table testtable(id number(4) not null primary key, ename  char(10));

I use Pro*C to fetch data from this table. When I use this SQL:

select * from testtable where ename like 'wxd'

I get no results. But when I use this:

select * from testtable where ename like 'wxd       '

I get the right results. I must fill enough space into the field. Is there some other way to can get the right result?

Mat
  • 202,337
  • 40
  • 393
  • 406
sky蓝色
  • 1
  • 2

2 Answers2

0

This is not a problem with Pro*C but a characteristic of the data type you have chosen for the column. CHAR(10) means that the field is always 10 characters wide, even if the value you insert is shorter. The database will pad a short value with spaces which is why you had to add the extra spaces in the query.

If you want a variable length column, use VARCHAR(10) instead.

Burhan Ali
  • 2,258
  • 1
  • 28
  • 38
0

You can also use the following which works with both CHAR and VARCHAR columns:

select * from testtable where ename like 'wxd%'

A SQL like condition usually has a wildcard.