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

Home -> Community -> Usenet -> c.d.o.misc -> Re: Export to a ascii, tab delimited file

Re: Export to a ascii, tab delimited file

From: Adrian Hands <AHands_at_sprynet.com>
Date: 1998/12/01
Message-ID: <36647BC2.10DD0F93@sprynet.com>#1/1

KeyStroke (Jack L. Swayze Sr.) wrote:

> (Part of
> the Unix mentality, I guess.)

Unix mentality ? How do you figure ?  

> him a day or two to code and test it and deliver it to you. (The one I goaded into this
> did it in half a day.) Then in your Unix scripts, always have the file post-processed by
> that little C program. I would include the C code here, but it was developed using my
> employers resources, and I need to be faithful to my employer.

Why bother? :

$ sed 's@ *$@@' < output.txt > newoutput.txt

For that matter, why bother using sql*plus at all ? :

#!/usr/bin/perl -w

use strict;
use DBI;

sub ora_abend { # Subroutine to abend on sql error:

    if($DBI::err) { die "$_[0] failed!\n$DBI::errstr" } }

# Get a db connection:
my $dbh = DBI->connect('mysid', 'scott', 'tiger', 'Oracle'); &ora_abend('connect'); # Check for errors

# Prepare a cursor:
my $cur =

    $dbh->prepare('SELECT OWNER, TABLE_NAME, TABLESPACE_NAME, CLUSTER_NAME'

		  . ' FROM SYS.ALL_TABLES'
		  );

&ora_abend('prepare'); # Check for errors

# Loop through it:
while(my($owner, $tab_name, $ts_name, $cluster) = $cur->fetchrow()) {

    printf("%s\t%s\t%s\t%s\n", $owner, $tab_name, $ts_name, $cluster); }
&ora_abend('fetch'); # Check for errors

# Done!
$cur->finish();
$dbh->disconnect();

> By the way, when the C programmer then brags that we need to do away with Oracle and use C
> and flat files to do everything, that is when you can spring the news on him that Oracle
> was coded in C.

This CERTAINLY will NOT come as a surprise! After all, what commercial production code is NOT coded in C ? Received on Tue Dec 01 1998 - 00:00:00 CST

Original text of this message

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