user2592495
user2592495

Reputation: 1

OCI8 for PHP (Oracle Connection) values come with spaces (completed to full lenght)

I am using OCI8 for PHP for connecting to an Oracle 11g database.

Everything is working fine, but the imported values from Oracle database come with spaces, completed to full lenght.

For example, the value on DB is with NCHAR(10 CHAR)

'value'

OCI8 returns

'value     ' 

with 5 spaces, 10 chars total.

Any ideas or recommendations?

Upvotes: 0

Views: 61

Answers (1)

Narf
Narf

Reputation: 14762

Yes, all *char types in Oracle have spaces appended all the way to the end, this is not PHP-specific. Use RTRIM() if you don't want them:

SELECT RTRIM(field_name) AS field_name ...

... or PHP's own rtrim() of course.

Upvotes: 1

Related Questions