NetTalk Central

Author Topic: Handling table records  (Read 4936 times)

rupertvz

  • Sr. Member
  • ****
  • Posts: 326
    • View Profile
    • Email
Handling table records
« on: November 13, 2011, 01:25:36 PM »
Hi Guys,

I have a NetWebForm calling a NetWebBrowse.
On the tab after the browse in the NetWebForm I'd like to "handle" and check the records being added by the user and give totals or warning upon their input.

I have added code in the "NextTab, Start" embed to loop through the records in the table, but for some reason my loop and record handling doesn't want to work.

Here is my code: * This code is only suppose to count the records according to the key-value ...


CASE lower(p_web.PageName)
OF lower('fWizard_nexttab_' & 8)

   ACCESS:TABLE.OPEN()
   ACCESS:TABLE.USEFILE()

   RESET(TABLE,1)                                                  !Reset the record pointer

   TABLE:REC_ID = GLO:REC_ID                                 !GLO:RecID stored in previous instance
   SET(REC_ID_KEY,REC_ID_KEY)
   LOOP UNTIL ACCESS:TABLE.Next() <> LEVEL:Benign
      IF TABLE:REC_ID = GLO:REC_ID
          TOT:Cnt += 1
      ELSE
        
         BREAK
      END
   END

   ACCESS:TABLE.Close()
« Last Edit: November 13, 2011, 01:32:35 PM by rupertvz »

kevin plummer

  • Hero Member
  • *****
  • Posts: 1195
    • View Profile
    • Production Accounting and Software Payroll
Re: Handling table records
« Reply #1 on: November 13, 2011, 03:01:38 PM »
For starters I would change GLO:REC_ID to a SSV otherwise it could create other problems down the track.

Secondly I would also set your TOT:Cnt as a SSV at the end of your loop. BTW is this a local variable or a table field?

Stu

  • Hero Member
  • *****
  • Posts: 510
    • View Profile
    • Email
Re: Handling table records
« Reply #2 on: November 13, 2011, 08:05:23 PM »
Rupert,

Hi there.

The first question that comes to me is "What do you mean by - doesn't want to work -?"

That is, does your code error out? Or are you getting the right information from your code BUT it's not getting to where it should go?

Which leads me to the more important thing (Kevin points at it), Nettalk runs a lot on Session vars.

If you are wanting the information to display on the next tab, are the fields you are displaying being set by your code? Usually this would be done through p_web.SSV().

Also, are they (the display fields in the 2nd tab) being refreshed on a tab change or after the browse has been operated on?
Cheers,

Stu Andrews

rupertvz

  • Sr. Member
  • ****
  • Posts: 326
    • View Profile
    • Email
Re: Handling table records
« Reply #3 on: November 15, 2011, 04:30:16 AM »
Hi Kevin, Stu,

Thanks for your repies;

I did a few tests and the problem is arising when I include the following line (bold below):

TABLE:REC_ID = GLO:REC_ID                                 !GLO:RecID stored in previous instance
   SET(REC_ID_KEY,REC_ID_KEY)
   LOOP UNTIL ACCESS:TABLE.Next() <> LEVEL:Benign
      IF TABLE:REC_ID = GLO:REC_ID
          TOT:Cnt += 1
      ELSE
       
         BREAK
      END
   END

When I remove this line out, the loop handles all records (CORRECT)
As soon as I put this line back, the loop doesn't handle ANY records ...
It is not making any sense, as with the line:  TABLE:REC_ID = GLO:REC_ID
I am only starting the record processing at the record with the set-value ... correct?

I have even tried setting TABLE:REC_ID = 4  .... (constant)
There is a record with ID (4), but when I add this line, the loop doesn't process any records.

It's not making any sense ...
Any help please?

kevin plummer

  • Hero Member
  • *****
  • Posts: 1195
    • View Profile
    • Production Accounting and Software Payroll
Re: Handling table records
« Reply #4 on: November 15, 2011, 04:52:50 PM »
Hi Rupert,

where ever you are setting GLO:RecID change it to p_web.SSV('Glo:Rec_ID',the record id here, no quotes) !you should substitute globals to SSV's - read the docs why...

Then change TABLE:REC_ID = GLO:REC_ID to TABLE:REC_ID = p_web.gsv('GLO:REC_ID')

+ change IF TABLE:REC_ID = GLO:REC_ID to IF TABLE:REC_ID = p_web.gsv('GLO:REC_ID')

You then need to store TOT:Cnt to a SSV at the end of the loop if you want to use it elsewhere or update that value in your table.

Stu

  • Hero Member
  • *****
  • Posts: 510
    • View Profile
    • Email
Re: Handling table records
« Reply #5 on: November 15, 2011, 07:31:41 PM »
Rupert,

Just wondering, when you have TABLE:REC_ID, you mean TABLEPREFIX:REC_ID right?
Cheers,

Stu Andrews

Bruce

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 11250
    • View Profile
Re: Handling table records
« Reply #6 on: November 15, 2011, 10:04:50 PM »
Rupert,

two things

a) what is the line
RESET(TABLE,1)         
 for ? I don't think I've seen that since DOS days

b) delete your global variable completely. I mean don't just "not use it" literally delete it. It has no place in a WebServer app.

then re-write the code correctly using Session values instead of global variables.

cheers
Bruce

terryd

  • Hero Member
  • *****
  • Posts: 759
    • View Profile
    • Davcomm
    • Email
Re: Handling table records
« Reply #7 on: November 15, 2011, 11:20:29 PM »
Hi rupert
The Reset(Table,1) is what is making it work when you remove the TABLE:REC_ID = GLO:REC_ID         line since the table is set to the beginning and would therefore traverse the file from the beginning.
That said do what Bruce said  :)
Terry Davidson
Windows 10 64 bit/Windows7 64bit
Clarion 9.1.11529/Clarion10 12567
Nettalk 913
Nettalk 1015
StringTheory267/Winevent515/XFiles298/MessageBox239/Cryptonite186

rupertvz

  • Sr. Member
  • ****
  • Posts: 326
    • View Profile
    • Email
Re: Handling table records
« Reply #8 on: November 18, 2011, 05:00:04 AM »
Thanks Guys!

I incorporated all these changes and seems to be working now :-)

Regards
Rupert