kiran kumar
kiran kumar

Reputation: 1

Oracle table column contain $

I'm currently migrating AIX to Linux. The Oracle script contains a $ in the column name. While fetching through the shell script, I set the escape character to $, but it does not work. The query is like below:

Set escape $

Select c.logoff$time from temp c;

When run from shell script I'm getting "c.logoff invalid identifier".

How can I fix this?

Upvotes: 0

Views: 33

Answers (1)

Alex Poole
Alex Poole

Reputation: 191570

This isn't an SQL*Plus (I assume that's your client) problem, so the set escape isn't doing anything - that's for escaping things SQL*Plus tries to interpret - see the docs.

This is a shell issue/feature. the $time part is being treated as a shell variable, and that doesn't exist, so the final table name doesn't have it. You can escape that at shell level, referring to \$time; e.g. if you're using a heredoc:

sqlplus -s -l usr/pass@db <<EOF

select c.logoff\$time from temp c;

EOF

Upvotes: 5

Related Questions