🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.databases.oracle.server
Article #74

Re: Dynamic SQL in PRO-C (type 3), problem with NULL

#74
From: John Gasch
Date: Fri, 31 Mar 2000 00:00
54 lines
2412 bytes
This is kludgy but I believe this should work. Try adding an outer-join
of DUAL.

A simple query such as:

   SELECT myTable.aField
      FROM myTable
      WHERE ...
      ;

Change to:
   SELECT NVL(myTable.aField, valueIfNull)
      FROM myTable, Dual
      WHERE ...
      AND   myTable.aField(+) IS NOT NULL;

If your query involves a join, wrap it as follows:

   SELECT whatever
      FROM ( SELECT NVL(aTable.aField, valueIfNull) anAlias
                FROM aTable, bTable
                WHERE ...
           ) myQuery,
           Dual
      WHERE myQuery.anAlias(+) IS NOT NULL
      ;
 
Another technique would be to wrap your query into a PL/SQL block with
an exception handler to catch the NO_DATA_FOUND condition.

Good luck.

John Gasch



"Riccardo D.S." wrote:
> 
> I use e dynamic SQL statment (pro c - type 3 ) to estract
> the value of single column and put it in the host-variable.
> When the return of query is Null the SQL statment  go in error .
> Is it possible when this occur continue the process?
> Now use the NVL function to return a particulat string
> or number when the value is NULL. I prefer ignore the select
> when tha value is Null and continue to other select.
> 
> Thanks,
> Sorry for my english...
> 
> I'm italian
> 
> Dott. Riccardo Di Stefano
> Alenia Marconi System s.p.a.
> Rome - Italy
Technical Details
Message-ID: <38E55B95.B4A03A7F@erols.com>
Path: arc1-ca.pugleaf.net!unknown!not-for-mail
References: <38E49951.D6D2CB0A@aleniasystems.finmeccanica.it>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: f5464,a8bbdcae33011cd9
X-Google-Attributes: gidf5464,public
X-Google-Thread: fa4f9,a8bbdcae33011cd9
X-Google-Attributes: gidfa4f9,public
X-Google-Thread: f99a8,a8bbdcae33011cd9
X-Google-Attributes: gidf99a8,public
X-Google-Thread: 103117,a8bbdcae33011cd9
X-Google-Attributes: gid103117,public
From: John Gasch <jgasch@erols.com>
Subject: Re: Dynamic SQL in PRO-C (type 3), problem with NULL
Date: 2000/03/31
Message-ID: <38E55B95.B4A03A7F@erols.com>
X-Deja-AN: 605073776
Content-Transfer-Encoding: 7bit
References: <38E49951.D6D2CB0A@aleniasystems.finmeccanica.it>
X-Sender: "John Gasch" <@smtp.erols.com> (Unverified)
X-Accept-Language: en
Content-Type: text/plain; charset=us-ascii
X-Complaints-To: abuse@rcn.com
X-Trace: MZVqGr1FNFKq4wVd4BKGvTIoe4TD7Iw88ngzV/hSkd8=
Mime-Version: 1.0
NNTP-Posting-Date: 1 Apr 2000 02:01:06 GMT
Newsgroups: comp.databases.oracle.server,comp.databases.oracle.tools,cern.oracle.cde,comp.databases.oracle.misc