AmbroseChapel
AmbroseChapel

Reputation: 12097

Data in oracle DB has trailing spaces but they're being stripped by sqlplus

I'm retrieving data from an oracle database using sqlplus.

The command is something like this:

select property_name||'|'||property_value from some_table where x = 'foo' 

and the data in the database definitely has trailing spaces (this is a thing which causes problems in an application I work with).

When I retrieve that data the spaces have been automatically trimmed somehow. I can see them when I use SQLDeveloper and when retrieved by the application directly.

Is there a way I can stop this happening?

Upvotes: 0

Views: 132

Answers (1)

thatjeffsmith
thatjeffsmith

Reputation: 22467

Here is how it should be working.

SQL> create table spaces (blanks varchar2(20));

Table created.

SQL> insert into spaces values ('A');

1 row created.

SQL> insert into spaces values ('A     ');

1 row created.

SQL> insert into spaces values ('A  ');

1 row created.

SQL> Insert into SPACES (BLANKS) values ('A   

B   ');

SQL> commit;

Commit complete.


SQL> select blanks, length(blanks), blanks || '!' from spaces;

BLANKS               LENGTH(BLANKS) BLANKS||'!'
-------------------- -------------- ---------------------
A                    1               A!
A                    6               A    !
A                    3               A  !
A                    9               A
B                                    B  !

SQL> 

The last column shows that none of the 'blanks' are being trimmed. Can you share your scenario in your question details? Or try what I've demonstrated and compare.

Upvotes: 1

Related Questions