Is it possible to run a SQLPLUS script on a file encoded as UTF-8 with BOM
Asked Answered
R

2

8

I'm trying to run a collection of scripts which have been auto-generated from a large number of sources. Unfortunately some of these have been generated as UTF-8 with BOM. I have in place a system for automatically removing the BOM, but its a bit of a messy process.

Failing to remove the BOM generates the error:

SP2-0042: unknown command "" - rest of line ignored.

Is it possible to run SQLPLUS on a script file which has a BOM?

Renelle answered 25/5, 2012 at 16:26 Comment(1)
No idea, but I'd start by looking into the client side character set setting to see if it was different than UTF-8. Actually, if automated, I would leave in place the process to strip the BOM.Mediant
M
4

It is possible to run SQLPLUS with such script, but SQLPLUS will indicate an error on the first line because of BOM.
Probably you wanted to ask if you can avoid this error - it is not possible, AFAIK. Erwin thinks so too.

You can workaround losing any information by generating those files with an empty first line. Then you can just ignore this error.

Market answered 28/2, 2013 at 7:41 Comment(1)
Sadly the SQL script is being used as part of a KSH script. The error output from SQLPlus trips up the KSH script. Thanks for the response though. It confirms that BOM stripping was necessary.Renelle
M
6

This has been a bug open with Oracle for over 6 years now, but it doesn't look like they are interested in fixing it.

Their 'recommended workaround' (Doc ID 788156.1 Section C.6) is to strip the BOM or make your first script line a comment, and then ignore this error.

SP2-0042: unknown command "" - rest of line ignored.

Or

SP2-0734: unknown command beginning "-- Commen..." - rest of line ignored.

Bug 13515585 Details (requires OTN login):

Bug 13515585: ADD SUPPORT FOR THE UTF-8 BOM IN SQLPLUS
Bug Status: Internal (Oracle) Review 
Created: 19-Dec-2011 
Updated: 29-Sep-2015
Menell answered 27/2, 2018 at 23:42 Comment(0)
M
4

It is possible to run SQLPLUS with such script, but SQLPLUS will indicate an error on the first line because of BOM.
Probably you wanted to ask if you can avoid this error - it is not possible, AFAIK. Erwin thinks so too.

You can workaround losing any information by generating those files with an empty first line. Then you can just ignore this error.

Market answered 28/2, 2013 at 7:41 Comment(1)
Sadly the SQL script is being used as part of a KSH script. The error output from SQLPlus trips up the KSH script. Thanks for the response though. It confirms that BOM stripping was necessary.Renelle

© 2022 - 2024 — McMap. All rights reserved.