I have a procedure in a service program where I need to find out if a
record exists in a file. I don't want or need the record, I just need
to know if it exists.
I could define a file in the procedure (V6R1) but then if the file
layout changes, the service program needs recreated, so I thought
embedded SQL would be better.
I could do this:
Exec SQL Select Count(*)
Into :Count
From MyFile
Where CUSNR = :cusnr;
and then check Count. I did some googling on 'SQL check record
existence' and found some really interesting discussions on EXISTS and
IN and JOINing and who knows what else. Some of the examples got
fairly complex for what I would say is a simple thing to do.
CUSNR is the primary key, so Count would either be 0 or 1. Is there a
generally accepted way to do this in SQL? Or is it whatever floats
your boat?
As always, for me, readability is far more important than performance.
This routine will be called 300-600 times a day.
Thanks.
As an Amazon Associate we earn from qualifying purchases.
This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact
[javascript protected email address].
Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.