dbTalk Databases Forums  

Conditional Union ?

comp.databases.oracle.misc comp.databases.oracle.misc


Discuss Conditional Union ? in the comp.databases.oracle.misc forum.



Reply
 
Thread Tools Display Modes
  #11  
Old   
General Fear
 
Posts: n/a

Default Re: Conditional Union ? - 06-20-2008 , 05:54 AM






On Jun 20, 1:58 am, Carlos <miotromailcar... (AT) netscape (DOT) net> wrote:
Quote:
On 20 jun, 06:32, General Fear <richma... (AT) earthlink (DOT) net> wrote:



I am using 10g.

Below is a crude example of what I am trying to do

Procedure
( pi_input as interger
)

is

Cursor A
is
Select 'A' as Letter from Dual;

Cursor B
is
Select 'A' as Letter from Dual;
Union
Select 'B' as Letter from Dual;

If pi_input = 1 then
Open A
Else
Open B
End If

Notice that Select 'A' as Letter from Dual is in two cursors. If I
have to make a change to Cursor A, I also have to do it again in
cursor B because "Select 'A' as Letter from Dual' is in two cursors.

Is it possible to eliminate repeat code in the above example? What do
I need to do.

Not so sure about what you're trying to do but:

Select 'A' as Letter from Dual
Union ALL
Select 'B' as Letter from Dual
WHERE 1 = i_input;

should eliminate redundant code.

HTH

Cheers.

Carlos.
Thanks. This is a good lead.

The problem is the user will be given two choices. If they click one
way. It is a simple select in Oracle, however, if they pick another
option on the Visual Basic GUI, that means several unions.

I wanted to avoid maintaining several cursors that are basically the
same.

Thanks!


Reply With Quote
  #12  
Old   
General Fear
 
Posts: n/a

Default Re: Conditional Union ? - 06-20-2008 , 05:54 AM






On Jun 20, 1:58 am, Carlos <miotromailcar... (AT) netscape (DOT) net> wrote:
Quote:
On 20 jun, 06:32, General Fear <richma... (AT) earthlink (DOT) net> wrote:



I am using 10g.

Below is a crude example of what I am trying to do

Procedure
( pi_input as interger
)

is

Cursor A
is
Select 'A' as Letter from Dual;

Cursor B
is
Select 'A' as Letter from Dual;
Union
Select 'B' as Letter from Dual;

If pi_input = 1 then
Open A
Else
Open B
End If

Notice that Select 'A' as Letter from Dual is in two cursors. If I
have to make a change to Cursor A, I also have to do it again in
cursor B because "Select 'A' as Letter from Dual' is in two cursors.

Is it possible to eliminate repeat code in the above example? What do
I need to do.

Not so sure about what you're trying to do but:

Select 'A' as Letter from Dual
Union ALL
Select 'B' as Letter from Dual
WHERE 1 = i_input;

should eliminate redundant code.

HTH

Cheers.

Carlos.
Thanks. This is a good lead.

The problem is the user will be given two choices. If they click one
way. It is a simple select in Oracle, however, if they pick another
option on the Visual Basic GUI, that means several unions.

I wanted to avoid maintaining several cursors that are basically the
same.

Thanks!


Reply With Quote
  #13  
Old   
General Fear
 
Posts: n/a

Default Re: Conditional Union ? - 06-20-2008 , 05:54 AM



On Jun 20, 1:58 am, Carlos <miotromailcar... (AT) netscape (DOT) net> wrote:
Quote:
On 20 jun, 06:32, General Fear <richma... (AT) earthlink (DOT) net> wrote:



I am using 10g.

Below is a crude example of what I am trying to do

Procedure
( pi_input as interger
)

is

Cursor A
is
Select 'A' as Letter from Dual;

Cursor B
is
Select 'A' as Letter from Dual;
Union
Select 'B' as Letter from Dual;

If pi_input = 1 then
Open A
Else
Open B
End If

Notice that Select 'A' as Letter from Dual is in two cursors. If I
have to make a change to Cursor A, I also have to do it again in
cursor B because "Select 'A' as Letter from Dual' is in two cursors.

Is it possible to eliminate repeat code in the above example? What do
I need to do.

Not so sure about what you're trying to do but:

Select 'A' as Letter from Dual
Union ALL
Select 'B' as Letter from Dual
WHERE 1 = i_input;

should eliminate redundant code.

HTH

Cheers.

Carlos.
Thanks. This is a good lead.

The problem is the user will be given two choices. If they click one
way. It is a simple select in Oracle, however, if they pick another
option on the Visual Basic GUI, that means several unions.

I wanted to avoid maintaining several cursors that are basically the
same.

Thanks!


Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.