🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: comp.databases.oracle.server
3 messages
3 total messages Started by Riccardo D.S. Fri, 31 Mar 2000 00:00
Dynamic SQL in PRO-C (type 3), problem with NULL
#73
Author: Riccardo D.S.
Date: Fri, 31 Mar 2000 00:00
16 lines
1411 bytes
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
Re: Dynamic SQL in PRO-C (type 3), problem with NULL
#74
Author: 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
Re: Dynamic SQL in PRO-C (type 3), problem with NULL
#75
Author: Keith Jamieson
Date: Tue, 04 Apr 2000 00:00
28 lines
1899 bytes
What you shoud do is actually declare a variable as short int.

your select then looks something like follows:

exec select  column_name into column_value:null_ind;

Now if you retrieve a select, null_ind is set to -1.
This is the correct way to code for Nulls using PRO*C.

Riccardo D.S. wrote in message
<38E49951.D6D2CB0A@aleniasystems.finmeccanica.it>...
>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
>
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads