You can prove this yourself. Write a program with SQL and open a cursor.
Step into it with debug and stop before the close cursor. Try to clear the
table. It won't work. Step through the rest of the code and close the
cursor. File will still have a lock. Try to clear the file it will work and
the file will be closed.



On Mon, Nov 13, 2017 at 1:02 PM, Alan Campin <alan0307d@xxxxxxxxx> wrote:

But those are soft locks. If a file is closed in SQL it leaves it open
with a soft lock which means simply that if something needs to do something
with the file with a higher level, it will release the lock by actually
closing the file.

A hard lock will not be released. SQL is designed to use locks more
intelligently.

On Mon, Nov 13, 2017 at 12:53 PM, Hiebert, Chris <
chris.hiebert@xxxxxxxxxxxxxx> wrote:

From: RPG400-L [mailto:rpg400-l-bounces@xxxxxxxxxxxx] On Behalf Of Alan
Campin
--The other question I would have is why anyone would write a service
program these days using file I/O instead of SQL.

With file I/O I get more control over the file locks. When I close a
file, its closed.


SQL doesn't always close the files when you run a close cursor.
So, short of destroying active service program, killing the activation
group, or other extreme methods, that SQL service program is going to hold
onto file locks.



Chris Hiebert
Senior Programmer/Analyst
Disclaimer: Any views or opinions presented are solely those of the
author and do not necessarily represent those of the company.
--
This is the RPG programming on the IBM i (AS/400 and iSeries) (RPG400-L)
mailing list
To post a message email: RPG400-L@xxxxxxxxxxxx
To subscribe, unsubscribe, or change list options,
visit: https://lists.midrange.com/mailman/listinfo/rpg400-l
or email: RPG400-L-request@xxxxxxxxxxxx
Before posting, please take a moment to review the archives
at https://archive.midrange.com/rpg400-l.

Please contact support@xxxxxxxxxxxx for any subscription related
questions.

Help support midrange.com by shopping at amazon.com with our affiliate
link: http://amzn.to/2dEadiD




This thread ...

Replies:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2020 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].