NetTalk Central

Author Topic: Updating a Table From a Browse Based on a View  (Read 2832 times)

BMcGinnis

  • Newbie
  • *
  • Posts: 3
    • View Profile
    • Email
Updating a Table From a Browse Based on a View
« on: June 06, 2011, 08:36:35 AM »
I have a browse that is from a back-end view that comprises a few columns from a table, (Table1) and some aggregates; let's call it VwBrowse1.  The back-end view is non-updatable.

So, when the user clicks on the insert, update, or delete buttons, I need to get it to update the underlying table for the view, (Table1),  not the view itself (VwBrowse1).  I've looked all over for a way to do this, but can't seem to get it done.

Anyone have any tips for me?

Thanks,
-Brian


kevin plummer

  • Hero Member
  • *****
  • Posts: 1195
    • View Profile
    • Production Accounting and Software Payroll
Re: Updating a Table From a Browse Based on a View
« Reply #1 on: June 06, 2011, 04:41:30 PM »
As long as the View and the actual table have the same unique ID or there is some link between them you should be able to do it. You need to set the unique ID of the table into the SSV before the form opens.

It's a bit vague but HTH's

Kev

BMcGinnis

  • Newbie
  • *
  • Posts: 3
    • View Profile
    • Email
Re: Updating a Table From a Browse Based on a View
« Reply #2 on: June 08, 2011, 10:49:50 AM »
Perhaps I need to be a bit more specific...
The name of the backend view is VwGroups and is defined in Clarion as a table with the prefix VGP.

The underlying table is called ContactGroups, also defined in Clarion as a table with the prefix CGP.

The primary key in the view is then VGP:SysIdCGP whereas the table is CGP:SysIdCGP.

Somehow, I need to set CGP:SysIdCGP to the value of VGP:SysIdCGP and pass it to the update form instead of VGP:SysIdCGP since it is the proper primary key for the table.

How does one do this?

kevin plummer

  • Hero Member
  • *****
  • Posts: 1195
    • View Profile
    • Production Accounting and Software Payroll
Re: Updating a Table From a Browse Based on a View
« Reply #3 on: June 08, 2011, 03:30:40 PM »
There is an embed on the browse called User Did Something in Browse, User Clicked on a Row in the Browse. I would add the code p_web.ssv('CGP:SysIdCGP', p_web.GSV('VGP:SysIdCGP'))

You would also need to do this when the browse opens so it sets the value of the first entry in the browse.

HTH's

Kev

Bruce

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 11194
    • View Profile
Re: Updating a Table From a Browse Based on a View
« Reply #4 on: June 09, 2011, 12:29:03 AM »
Hi Brian,

I've done this whole "browse one table edit another table" thing before - but I don't remember the details out of my head at the moment. I'll see if I can add that to one of the examples though for the next build.

cheers
Bruce


jorgemir

  • Jr. Member
  • **
  • Posts: 71
    • View Profile
    • Email
Re: Updating a Table From a Browse Based on a View
« Reply #5 on: June 09, 2011, 04:03:31 AM »
From memory, I think you did it in Example 23, but this has never worked well.
Jorge

charl99

  • Full Member
  • ***
  • Posts: 185
    • View Profile
    • Email
Re: Updating a Table From a Browse Based on a View
« Reply #6 on: June 09, 2011, 06:33:11 AM »
Hi Brian,

How about using the normal Update procedure _but_ with no fields from the Update Browse itself.

In the Pre-Update embed point, set CGP:SysIdCGP = p_web.gsv('VGP:SysIdCGP') and get the table.  Set some locals (or local Session variables if you prefer to call it that) to the values of the CGP table, and in the Validate All embed point update the CGP table from these values and write the CGP table.

I update numerous tables using this technique (although I usually have at least one field from the main table).

Cheers
Charl

BMcGinnis

  • Newbie
  • *
  • Posts: 3
    • View Profile
    • Email
Re: Updating a Table From a Browse Based on a View
« Reply #7 on: June 09, 2011, 10:57:18 AM »
After some additional debugging, I think I've found the simplest solution:

I embedded the following line in the update procedure in "Processed Code" at the very top:

Code: [Select]
p_web.SetValue('CGP:SysIdCGP',p_web.RestoreValue('VGP:SysIdCGP'))
 

The problem with the other tips is that they revolved around session variables while the update logic seems to use the value queue to obtain the primary key value...  I had to add some code to dump both the session variables and value queues while examining the NetWebServerWorker class to arrive at the fix.