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: PL/SQL Questions

Re: PL/SQL Questions

From: Connor McDonald <mcdonald.connor.cs_at_bhp.com.au>
Date: Thu, 05 Nov 1998 15:56:25 +0800
Message-ID: <36415A29.3F09@bhp.com.au>


Stewart Burnett wrote:
>
> 1. Try this;
>
> DECLARE
> CURSOR c1 IS
> SELECT *
> FROM my_table
> ORDER BY my_order;
> BEGIN
> OPEN c1;
> FETCH c1 INTO r1;
> IF c1%NOTFOUND THEN
> -- No rows returned error!
>
> END IF;
> CLOSE c1;
>
> -- Now have one row in r1
>
> END;
> /
>
> 2. Not sure about this one, RTRIM(LTRIM(r1.text_field)) will get rid of any
> at the beginning or end. Have a look at the TRANSALATE function, this could
> save you having to write your own code to scan the text.
>
> Ed Wallace wrote in message
> <01be06b8$139c1da0$b44fe8cd_at_IT3483.garlock-inc.com>...
> >Two questions - 1st - knowing that I'm not supposed to use an exit to
> >terminate a cursor FOR loop, what is the best way to get a single 'row' of
> >data? Is a cursor even the best way? One example of where I am doing this
> >is I am selecting and ordering data. I am fetching into a list of
> >variables the first ordered occurrence of this data. These variables are
> >then written to an output file. Then I exit my cursor. Any better way to
> >do this?
> >
> >2nd - Another problem I've come across is when I am fetching data from a
> >cursor to make up a fixed width output file, one of the fields may contain
> >tabs or carriage returns, which messes up the fixed-width file as they are
> >interpreted. What is the best way to get rid of them or ignore them? Do I
> >need to scan the string and do a replace or something?
> >
> >Thanks in advance
> >
> >Ed
> >
> >
> >

Look at the "replace" command...

Depending on your environment, tab should be chr(9), and hard returns chr(10)...

eg x := replace(replace(my_string,chr(9),''),chr(10),''); --



Connor McDonald
BHP Information Technology
Perth, Western Australia
"The difference between me and a madman is that I am not mad" Received on Thu Nov 05 1998 - 01:56:25 CST

Original text of this message

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