Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

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

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

From: joel garry <joel-garry_at_home.com>
Date: 7 Jun 2006 12:15:16 -0700
Message-ID: <1149707716.145834.261320@i40g2000cwc.googlegroups.com>

BD wrote:
> Hey, all.
>
> I'm on AIX 5.2. Oracle 8.1.7.4
>
> 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 tahiti.oracle.com 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 http://www.mpi-sb.mpg.de/~uwe/lehre/unixffb/quoting-guide.html or google for bourne shell quoting.

jg

--
@home.com is bogus.
"I just was amused by the misguided fans who thought his stuff was
high art and a great investment."
http://www.signonsandiego.com/uniontrib/20060604/news_1h04kinkadea.html
Received on Wed Jun 07 2006 - 14:15:16 CDT

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US