Oracle FAQ Your Portal to the Oracle Knowledge Grid

Home -> Community -> Usenet -> c.d.o.server -> Re: QUESTION - "Rulebook" for character delimiting...??

Re: QUESTION - "Rulebook" for character delimiting...??

From: joel garry <>
Date: 7 Jun 2006 12:15:16 -0700
Message-ID: <>

BD wrote:
> Hey, all.
> I'm on AIX 5.2. Oracle
> I'm trying to create a shell script that generates an RMAN recovery
> script. I'm trying to retrieve data from dba_datafiles, v$logfile, etc,
> and generate a script for rman that includes, for example, the set
> newname commands.
> So, for example, in my sqlplus script, I include:
> select 'set newname for datafile '||file_id||' to
> '''||file_name||''';'from dba_data_files order by file_id;
> that bit works. It spits out a bunch of 'set newname' commands, which
> get stuck in a 'run' statement that I'm generating.
> But I also want to include some 'sql "<insert sql statement here>"'
> commands, which requires that the double-quotes are generated as part
> the output.
> I'm becoming frustrated because I haven't internalized all the rules
> for how to delimit characters.
> Is there a document somewhere that outlines the rules? At this point,
> I'm just kind of thrashing. ;-))

Besides the simple answer already given, search on for the word: quoting.
Metalink 1005607.6 and Note:1014426.6 are useful, too.

Since I sometimes have to do some bizzaro ETL going from csv to Oracle (like "take all the data from this spreadsheet and if this code is at the end of a part code put it in all the stores in this other spreadsheet, and if this other code..."), or sometimes make revisionist historical data for some users, I'm a big fan of awk. Among other things, it lets you print \047 as part of text strings (the octal value of single quote), and it's not too bad for figuring out quoted strings with commas and such in them. When I'm really brain-dead and in a hurry going through multiple shells and languages, sometimes I'll even output some string like @0_at_0@0_at_0 and sed it to a single quote (or double if necessary).

As far as quoting in the shell:

Bourne shell: ' " \ are quoting characters - ` is not. 'xxx' Disable all special characters in xxx "xxx" Disable all special characters in xxx except $, ` and / \x Disable special meaning of character x

See also or google for bourne shell quoting.


-- is bogus.
"I just was amused by the misguided fans who thought his stuff was
high art and a great investment."
Received on Wed Jun 07 2006 - 14:15:16 CDT

Original text of this message