Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Programming > Cobol > Re: ProCobol Ou...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 7 of 15 Topic 4108 of 4196
Post > Topic >>

Re: ProCobol Outer join

by Robert <no@[EMAIL PROTECTED] > May 8, 2008 at 06:36 PM

On Thu, 8 May 2008 13:56:21 -0700 (PDT), Robert Jones <rjones0@[EMAIL PROTECTED]
>
wrote:

>On 8 May, 19:01, jeff <jmoore...@[EMAIL PROTECTED]
> wrote:
>> On May 8, 1:54 pm, Robert Jones <rjon...@[EMAIL PROTECTED]
> wrote:
>>
>>
>>
>> > On 8 May, 15:40, jeff <jmoore...@[EMAIL PROTECTED]
> wrote:
>>
>> > > On May 8, 10:24 am, "Michael Mattias" <mmatt...@[EMAIL PROTECTED]
>
wrote:
>>
>> > > > "jeff" <jmoore...@[EMAIL PROTECTED]
> wrote in message
>>
>> > >
>news:c06426f2-e7e7-428c-9350-b3343d6a612c@[EMAIL PROTECTED]
>>
>> > > > >I am having a problem with a left outer join when I add
conditionals.
>>
>> > > > > Select
>> > > > >        A. vehicle,
>> > > > >        B.Vehicle,
>> > > > >        B.acct,
>> > > > >        B.MOYR,
>> > > > >        B.Trancode
>> > > > > from  Table1 A, Table2 B
>> > > > > where A.vehicle=B.vehicle(+)
>> > > > >  and   B.acct='1234'
>> > > > >  and   B.MOYR = '0502'
>> > > > >  and  B.trancode='80'
>> > > > >  order by a.vehicle
>>
>> > > > > I need all a.vehicles for all vehicles to come back in the
cursor
>> > > > > regardless. Any ideas?
>>
>> > > > ALL A.vehicles?
>>
>> > > > Then you can't us the conditionals that way, since that will omit
any
>> > > > a.vehicles which don't have any rows in b matching the
conditions.
>>
>> > > > You can change your select to return a 'nvl'  (oracle) or
'nullif'
>> > > > (something) or CASE (I think that is standard) to return the rows
where the
>> > > > "b" results set columns will be null and eliminate the WHEREs ,
but there
>>  > > are others here who write SQL far far better than do I.
>>  > > > MCM- Hide quoted text -
>>
>> > > > - Show quoted text -
>>
>> > > Yeah that was kind of an overview, I did use NVL for the B.Table
>> > > fields to account for nulls. Thanks for your help
>>
>> > I don't know whether you can explicity state Left outer join in
>> > ProCOBOL, but if you can then presumably the syntax diagrams will
>> > explain how to use it. I think you use ON rather than WHERE for the
>> > matching criteria.
>>
>> > Alternately, in addition to Michael's suggestion, you could try a
>> > UNION for the select with the matching criteria together with a
select
>> > just for table A.
>>
>> > Good luck (I am rather rusty!)
>>
>> > Robert- Hide quoted text -
>>
>> > - Show quoted text -
>>
>> The way you are suggesting do I do a select within a select?
>
>No you do two selects separated/joined by a UNION ALL phrase, each
>select selects the same columns or their logical equivalents, which
>can be values as is the case here.
>
>e.g. something like (without referring to a manual)
>
>Select a.vehicle
>      ,b.vehicle(+)
>      ,b.acct
>      ,b.MOYR
>      ,b.trancode
>  from table1 a, table2 b
> where  a.vehicle=b.vehicle(+)
>   and  b.acct='1234'
>   and  b.MOYR = '0502'
>   and  b.trancode='80'
> union all
>select a.vehicle
>      ,''
>      ,''
>      ,''
>      ,''
>  from table1 a
> order by a.vehicle
>
>(UNION ALL should eliminate any identical rows, which UNION alone does
>not)

You got it backwards -- Union eliminates dups, Union All does not.

b.vehicle(+) in the select list is invalid.

Unmatched quotes in the bottom select are invalid. They should say NULL.

It doesn't matter because there are no duplicates to eliminate. Written
your way, the a
vehicles that match b vehicles will appear twice -- once with b data to
the right and once
without. 

>I don't understand the syntax/meaning of b.vehicle(+), but I expect
>you do.

It's Oracle syntax for LEFT OUTER JOIN.
 




 15 Posts in Topic:
ProCobol Outer join
jeff <jmoore207@[EMAIL  2008-05-08 06:58:32 
Re: ProCobol Outer join
"Michael Mattias&quo  2008-05-08 09:24:01 
Re: ProCobol Outer join
jeff <jmoore207@[EMAIL  2008-05-08 07:40:38 
Re: ProCobol Outer join
Robert Jones <rjones0@  2008-05-08 10:54:52 
Re: ProCobol Outer join
jeff <jmoore207@[EMAIL  2008-05-08 11:01:48 
Re: ProCobol Outer join
Robert Jones <rjones0@  2008-05-08 13:56:21 
Re: ProCobol Outer join
Robert <no@[EMAIL PROT  2008-05-08 18:36:04 
Re: ProCobol Outer join
Robert <no@[EMAIL PROT  2008-05-08 20:40:41 
Re: ProCobol Outer join
"Pete Dashwood"  2008-05-09 15:09:26 
Re: ProCobol Outer join
Robert <no@[EMAIL PROT  2008-05-08 20:48:29 
Re: ProCobol Outer join
"Pete Dashwood"  2008-05-09 15:11:11 
Re: ProCobol Outer join
Robert <no@[EMAIL PROT  2008-05-08 22:55:34 
Re: ProCobol Outer join
"Michael Mattias&quo  2008-05-09 08:17:58 
Re: ProCobol Outer join
"Pete Dashwood"  2008-05-10 12:57:31 
Re: ProCobol Outer join
Robert <no@[EMAIL PROT  2008-05-08 22:25:10 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Sat Jul 26 3:34:46 CDT 2008.