Forum Stats

  • 3,824,914 Users
  • 2,260,439 Discussions


How to get parseable output for ANY select query (ANY data) with sqlplus/SQLcl command line utility?

User_O3ERD Member Posts: 1 Green Ribbon

I am new to Oracle, but was using MS SQL and its sqlcmd utility for some time, als MySql through phpMyAdmin.

I want to run some/any SELECT query with any number of columns, any kind of text in VARCHAR columns (including line breaks, control chars, semicolons, commas, pipes, any kind of brackets, single and double quotes, < ..., etc.) with a command line utility like sqlplus (or now SQLcl) and get an always correctly parseable output.

The statement can be inside a temporary file too, if needed.

Any format will do, best XML, Json, CSV with framing characters for text values - or any other format, that any value is parseable correctly (e. g. null != empty string != string with spaces only ... any character from \x00 to \xFF - nice to have with Unicode).

I tried with SQLplus and SET MARKUP HTML ON, SET COLSEP, SPOOL, but the textual output ist not always correctly parseable, especially, if line breaks etc. are in the values.