Jump to content


Photo
- - - - -

Accessing a file in 'B'oth-mode


8 replies to this topic

#1 barry kavanagh

barry kavanagh

    Newbie

  • Members
  • Pip
  • 6 posts
  • Gender:Male
  • Location:London, England

Posted 20 March 2007 - 04:15 PM

Does anyone know of a system variable (or know of a coding trick) that can be used in the after-read-no-error logic for a file accessed in BOTH-mode that will indicate whether or not the required record exists or not. I could access the same record twice (in Add & Change mode) but would rather not go that route. The content (or absence) of the file variables is of no help to me at this time either as they could be set from a previous record or they could even be nulls from the current record.
Regards - Barry




Environment is Proiv kernel 5.5r517, VIP 5.5927 on a Unix platform.

#2 Chris Mackenzie

Chris Mackenzie

    ProIV Guru

  • Members
  • PipPipPipPipPip
  • 368 posts
  • Gender:Male
  • Location:Bristol, United Kingdom

Posted 20 March 2007 - 04:42 PM

Does anyone know of a system variable (or know of a coding trick) that can be used in the after-read-no-error logic for a file accessed in BOTH-mode that will indicate whether or not the required record exists or not. I could access the same record twice (in Add & Change mode) but would rather not go that route. The content (or absence) of the file variables is of no help to me at this time either as they could be set from a previous record or they could even be nulls from the current record.
Regards - Barry




Environment is Proiv kernel 5.5r517, VIP 5.5927 on a Unix platform.


I know you said you don't want to use the file variables but that's how
I'd do it = set an unusual value in BR (e.g. ~~~~~~~~) and check if it is still there in AR-NE
The content and views expressed in this message are those
of the poster and do not represent those of any organisation.

#3 Mike Nicholson

Mike Nicholson

    Expert

  • Members
  • PipPipPipPip
  • 196 posts
  • Gender:Male
  • Location:Stockholm, Sweden

Posted 21 March 2007 - 12:49 PM

AKAIK there's no P4 var that will tell you this. You either need to:

- Use add and change mode
- Use lookup and B mode (but then you might as well use add and change)
- Pick a var that's never null and blank it in the BR logic. If you then have a value then it's a change.

#4 barry kavanagh

barry kavanagh

    Newbie

  • Members
  • Pip
  • 6 posts
  • Gender:Male
  • Location:London, England

Posted 21 March 2007 - 04:16 PM

Okay - Thanks for those responses.

I've resorted to the Add & Change approach - but it always seems a clumsy solution to me.

#5 Mike Nicholson

Mike Nicholson

    Expert

  • Members
  • PipPipPipPip
  • 196 posts
  • Gender:Male
  • Location:Stockholm, Sweden

Posted 23 March 2007 - 09:37 AM

On a related note, can somebody remind me whether P4 tries the add or the change first. i.e. which way around is B mode optimised?

I used to know this ... :D

Cheers

Mike

#6 Rob Donovan

Rob Donovan

    rob@proivrc.com

  • Admin
  • 1,640 posts
  • Gender:Male
  • Location:Spain

Posted 25 March 2007 - 10:00 AM

Hi,

In BR Logic, the kernel does a read on the file, with the key at that point.

Then in BW logic it either adds or changes the record, depending on the state from BR Logic.

Rob.

#7 Kevin English

Kevin English

    Member

  • Members
  • PipPip
  • 14 posts
  • Gender:Male
  • Location:Bozeman, MT US
  • Interests:Snow Skiing, Windsurfing, and of course programming

Posted 25 March 2007 - 03:26 PM

Hi,

In BR Logic, the kernel does a read on the file, with the key at that point.

Then in BW logic it either adds or changes the record, depending on the state from BR Logic.

Rob.


In some cases (CISAM files anyway) wouldn't the add have to be done earlier
so that a record lock can be obtained?

KE

#8 Rob Donovan

Rob Donovan

    rob@proivrc.com

  • Admin
  • 1,640 posts
  • Gender:Male
  • Location:Spain

Posted 25 March 2007 - 04:29 PM

Hi Kevin,

With C-ISAM, there is no record lock on Add mode.

Only ProISAM does the lock on add mode.

Rob.

#9 Chris Pepper

Chris Pepper

    ProIV Guru

  • Members
  • PipPipPipPipPip
  • 369 posts
  • Gender:Male
  • Location:United Kingdom

Posted 25 March 2007 - 05:33 PM

This is why After Write Error should be tested!<br /><br />Also some developers assume that a B mode access can never fail. In long running transactions where there are nested file accesses in subsequent LUs by the time ProIV gets back to the write part of the B mode access then the state may have changed (i.e. another Function may have added or deleted the record). (In those file systems where the lock is not held).

Edited by Chris Pepper, 25 March 2007 - 05:34 PM.




Reply to this topic



  


0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users