NetTalk Central

Author Topic: Multi field key in lookup  (Read 4951 times)

Djordje Radovanovic

  • Full Member
  • ***
  • Posts: 237
    • View Profile
Multi field key in lookup
« on: February 15, 2013, 02:14:39 PM »
I have multipart key in lookup table but I have only one field to address in lookup settings.
How can I solve this trivial problem?

Djordje Radovanovic

Djordje Radovanovic

  • Full Member
  • ***
  • Posts: 237
    • View Profile
Re: Multi field key in lookup
« Reply #1 on: February 16, 2013, 08:28:12 AM »
Am I the first one with this problem?

Bruce

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 11250
    • View Profile
Re: Multi field key in lookup
« Reply #2 on: February 17, 2013, 10:22:06 PM »
Hi Djordje,

you may well be. Multi-field lookups are a reflection of bad database design, so I guess maybe others have done it too <g>...

Have you tried the "more assignments" list?

cheers
Bruce


Djordje Radovanovic

  • Full Member
  • ***
  • Posts: 237
    • View Profile
Re: Multi field key in lookup
« Reply #3 on: February 17, 2013, 11:10:35 PM »
Sure I tried "more assignments" list and it works just like I want. It assign more values from lookup file to primary file, but this is not near to what I asked.

Let us suppose that this is really bad database design but clarion let me handle this. Clarion has plenty of embeds points in their templates what we adopted through all this years and we can tune our applications as easy as peace of pie. Clarion even let you to specify in a browse so called "Higher Key Component" for us who are bad in databases design.

Maybe NetTalk templates does this tuning features too, but with this lack of documentation it is pretty hard to pick all the good things from your templates.

Regards,

Djordje Radovanovic

Bruce

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 11250
    • View Profile
Re: Multi field key in lookup
« Reply #4 on: February 18, 2013, 05:53:03 AM »
Hi Djordje,

Sure I understand there are folk that have old database designs, and some might be less than perfect. We can't always change stuff that is in place, so we try and support it as much as possible.

>> Am I the first one with this problem?

I guess the answer to this then is "yes".
Perhaps you can tweak one of the simple examples - say example 3, so that the two tables are related with multiple fields? ie create a small example there so the lookup needs to populate multiple components. Then post that here and I can take a look as to what might be involved to support it.

Obviously I can build the example here (and I will if you don't) but I have a lot to get through so making an example definitely makes it go faster.

cheers
Bruce

Djordje Radovanovic

  • Full Member
  • ***
  • Posts: 237
    • View Profile
Re: Multi field key in lookup
« Reply #5 on: February 18, 2013, 03:32:43 PM »
Ok. I made little example using nettalk wizzad but I received over hundred errors related to NetWebRelationManager and similar.

Than I let clarion abc wizzard to made application and everything was ok, so I am uploading dct and both plain nettalk wizzard application and plain clarion abc application.

Maybe you find something more than you expect.

Best regards,

Djordje Radovanovic


[attachment deleted by admin]

Djordje Radovanovic

  • Full Member
  • ***
  • Posts: 237
    • View Profile
Re: Multi field key in lookup
« Reply #6 on: February 22, 2013, 06:01:07 PM »
Ok. I see that Bruce has no enough time for all of us with our questions, so I dig a little and found something interesting in
NetWebServerWorker.GetDescription method

  If not codekey &= NULL
    if codekey{prop:components} > 1
      ! higer component fields are assumed to be set in the session queue.
      self._RestoreFields(p_file,codekey,Net:Web:SessionQueue)
      ! set lowest key componet field to p_value
      y = codeKey{PROP:Components}
      Loc:KeyField &= what(loc:record,codeKey{prop:field,y})
      Loc:KeyField = p_value
      ! whole key is primed so try and get the record.
      err = self._getfile(p_file,CodeKey)
    else
      loc:value[1] = p_value
      err = self._LoadRecord(p_file,codekey,loc:value)
    end

My question is how to set higher key components in the session queue?
It will make my day.

Best regards,
Djordje Radovanovic



Bruce

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 11250
    • View Profile
Re: Multi field key in lookup
« Reply #7 on: February 24, 2013, 11:44:03 PM »
Hi Djordje,

first your wizarded app - it gives lots of errors, as if the global extension was added to the app multiple times. It's generating all the global code 4 times, which indeed would cause problems. I'm not sure how that happened (di you wizard up different parts of the app while the app was open maybe?)

Anyway, I ran the wizard again on the dict, and it seemed to do better - this time just 3 errors;
Label Duplicated Acc:Curid:IsInvalid (BrowseTransaction)
Routine / Goto Label duplicated      (BrowseTransaction)
Label Duplicated Account::State    (UpdateTransaction)

It's trivial to fix - in the BrowseTransaction procedure the Id field has been included twice. (removing one sorts out the issue)

In the UpdateTransaction field the same table (Account) has been added twice to the Other Files list (at least internally).

Both of the above are caused by the dual-field relationship you have for your lookup - so I guess to answer your very first question;
>> Am I the first one with this problem?
The answer would appear to be "yes".

I'll use your dict, and tweak the wizard a bit, to see it it could generate a bit smarter in this situation.

cheers
Bruce





Djordje Radovanovic

  • Full Member
  • ***
  • Posts: 237
    • View Profile
Re: Multi field key in lookup
« Reply #8 on: February 26, 2013, 04:25:32 PM »
HI Bruce,

I believe that my solution is not the best solution but I tweaked your template and insert new embed point before

  ! GetDescription resets the 'NewValue' to the code, if the description is found. Returns 1 if code valid.

and now I am able to insert code like this

  clear(ROB:Record)
  ROB:PGod = PGod
  ROB:RobID = p_web.GetValue('Value')
  if ROB:RobID = 0
      ROB:RobID=p_web.GetSessionValue('ZHP:ROBID')
  END
  if Access:RPROB.Fetch(ROB:PK_RPROB) <> LEVEL:Benign
      clear(ROB:Record)
   END
   p_web.SSV('ROB:PGod',clip(PGod))

and it seems to me that my urgent problem is solved, but of course I'll be happy to see better solution through your template code.

Best regards,

Djordje Radovanovic