I am trying to pull data(use sqlplus) from Oracle DB into a file, but as that table's last column is default empty string, how to handle it ?
Note: I have verify the 3rd column existing in Oracle DB, the script works fine on other table if last column is not empty, but for this last column empty table, it failed.
Error information is:
[...@... scripts]$ ./myscript.sh
|| TRIM(THIRD_COLUMN) FROM TEST_TABLE
*
ERROR at line 3:
ORA-00942: table or view does not exist
The related sqlplus is below:
My_Table="TEST_TABLE"
sqlplus -s ${USER}/${PASS}@${HOST} <<EOF
SET PAGESIZE 0
SET COLSEP "|"
...some SET here...
SPOOL $FILE
Select TRIM(FIRST_COLUMN)|| '|'
|| TRIM(SECOND_COLUMN)|| '|'
|| TRIM(THIRD_COLUMN) FROM $My_Table;
SPOOL OFF
EXIT
EOF
How can I pull the last column together with all other columns especially when it is empty string ? Could someone help to figure out, thank you.