Page Index Toggle Pages: [1] 2 3  Send Topic Send Topic Print Print
Very Hot Topic (More than 25 Replies) Combining Elements to Make Unique Ext. Key (Read 4302 times)
Bharat_Naik
Senior Member
Members
*****
Offline


Ever ready to learn and
share

Posts: 1202
Location: Chicago,  Illinois
Joined: Dec 16th, 2003
Combining Elements to Make Unique Ext. Key
Apr 2nd, 2005 at 8:14pm
Print Post Print Post  
Sesame Development Team:

There are times, while using x-family commands and functions, there is no unique external key in a database with the use of one element but if one can combine two elements that would give Unique value and hence ability to get a single value as desirable.  The way it stands, it does not allow to combine two external keys in lookups and because of that we have to make structural change in application in the form of making one more elment combining two existing elements and making Unique Key.

I believe, it could be implemented to allow combining elements to make unique ext. key in the x-family functions particularly xlookups. I have heard that it is being done in the other database programs.

Since you have provided us with so many different tools, nothing is impossible but this will be easier way to have solution with minimal code. Thank you very much for the great product. We want you to know that we appreciate your efforts and enjoying working with Sesame  and accomplishing what we had only dreamt once.
  
Back to top
 
IP Logged
 
Bob_Hansen
Senior Member
Members
*****
Offline


WOW, They have the Internet
on computers now!

Posts: 1861
Location: Salem, NH
Joined: Nov 24th, 2002
Re: Combining Elements to Make Unique Ext. Key
Reply #1 - Apr 2nd, 2005 at 9:05pm
Print Post Print Post  
It is usually done in other databases by having a "dual-field" key. (Can be more than dual).  This is done by selecting the individual fields to be part of the key.

You can make your own "multi-value" key fields in Sesame now, just by adding a bound field, invisible if you want, definitely ReadOnly, and using that key for your XLU. 

When you change any of the elements that compose the multi-value key, then programming should be set to update the multi-value key.  You should also do some programming to make sure you have a unique value, which is something you would be doing even if you only had a single element key field.

-----------------------------
When you do your XLU from the other database, you can concatenate values, elements, etc. when you decide what to look for. 

Example looking for a multi-key value made up from three different fields that looks like 123-abc-xyz:

vValue = @XLU(@FN,LE1 + "-" + LE7 + "-" + @Right(LE4,3), "FormName!mulit-value key", "SourceElement" )

--------------------
Edited from original bad posting that left out the Source Element and some quotes.  Thanks to Bharat_Naik for pointing that out.
« Last Edit: Apr 2nd, 2005 at 11:15pm by Bob_Hansen »  



Bob Hansen
Sesame Database Manager Professional
Sensible Solutions Inc.
Salem, NH
603-898-8223
Skype ID = sensiblesolutions
Back to top
IP Logged
 
Bharat_Naik
Senior Member
Members
*****
Offline


Ever ready to learn and
share

Posts: 1202
Location: Chicago,  Illinois
Joined: Dec 16th, 2003
Re: Combining Elements to Make Unique Ext. Key
Reply #2 - Apr 2nd, 2005 at 10:01pm
Print Post Print Post  
Quote:
vValue = @XLU(@FN,mulit-value key, LE1 + "-" + LE7 + "-" + @Right(LE4,3) )


I have difficulties understanding. @xlu( ) has four elements to it, namely filename, key, "form!ext.key", "source")

In the above @xlu( ), you have only 3 elements to it. More over external key will be in quotes, will it not?

I was looking for documentation in Programming guide under mulit-key, multikey, multi external key... I am not finding anything. Where is this documented?  Do you have to make any additional element in the form?

Please help me understand, I am little lost.
  
Back to top
 
IP Logged
 
Bharat_Naik
Senior Member
Members
*****
Offline


Ever ready to learn and
share

Posts: 1202
Location: Chicago,  Illinois
Joined: Dec 16th, 2003
Re: Combining Elements to Make Unique Ext. Key
Reply #3 - Apr 2nd, 2005 at 10:10pm
Print Post Print Post  
Quote:
You can make your own "multi-value" key fields in Sesame now, just by adding a bound field, invisible if you want, and using that key for your XLU. 


Are you speaking of adding one more element in the form and value of it to be calculated based on the existing elements?

LastName:
Birthdate:   
KeyField:

KeyField: LastName + Birthdate


  
Back to top
 
IP Logged
 
Bob_Hansen
Senior Member
Members
*****
Offline


WOW, They have the Internet
on computers now!

Posts: 1861
Location: Salem, NH
Joined: Nov 24th, 2002
Re: Combining Elements to Make Unique Ext. Key
Reply #4 - Apr 2nd, 2005 at 11:14pm
Print Post Print Post  
Code
Select All
LastName:
Birthdate:
KeyField:

KeyField: LastName + Birthdate [ 


Yes, that is correct.  You can create mulitple "multi-key" kields if you want. 

LastName:
Birthdate:   
KeyField1: 

KeyField1: LastName + #Str(Birthdate)
KeyField2: @Mid(Birthdate,3,2) + LastName

--------------------------
Also remember to make KeyField ReadOnly and check for unique value after creating Keyfield.  Something like this:

Code
Select All
var vOK as Int

vOK = @XLookup(@FN, ThisElement, LEName, LEName)
IF  NOT @Error THEN {
	@MsgBox("This is not a unique Key Value!", "", "")
	  ThrowFocus(ThisElement)
	} 



---------------------------------------------
Thanks for pointing out my syntax error on earlier posting.  Sorry for any confusion.  I have corrected it in the original posting.  Double check the syntax here also, don't have access to Sesame right now......
  



Bob Hansen
Sesame Database Manager Professional
Sensible Solutions Inc.
Salem, NH
603-898-8223
Skype ID = sensiblesolutions
Back to top
IP Logged
 
Bharat_Naik
Senior Member
Members
*****
Offline


Ever ready to learn and
share

Posts: 1202
Location: Chicago,  Illinois
Joined: Dec 16th, 2003
Re: Combining Elements to Make Unique Ext. Key
Reply #5 - Apr 3rd, 2005 at 1:35am
Print Post Print Post  
Bob, this is understandable.  And that is what exactly we have to do it now, that I pointed out in my initial post. What I am looking for and what is desirable is Not to have to change anything in the form you are looking up value.  One has to be able to do it only by using code.

In the above example, instead of creating external keyfield, having ability to have following.

var vstring as String
vString = ClientLastName + Birthday

vValue = @xlookup (@fn, vString, "Customer!(Name + Birthday)",  "Contact Info")

I see a quite a bit of uses of the above. As I also mentioned, in sesame you can practically achieve anything with various tools available.  Even without creating any change in the external file, that is without creating keyfield and making it invisible, you can have it done creating Array and going through couple of loops, that is I have pointed out in the link

http://www.lantica.com/Forum2/cgi-bin/yabb/YaBB.pl?board=gen_disc;action=display...

Yes, it seems very easy that by creating a field you can do that, if you have to do it quite frequently with several databases of application in several places will end up making unnecessary fields if it could be achieved by just simple code.

  
Back to top
 
IP Logged
 
Bob_Hansen
Senior Member
Members
*****
Offline


WOW, They have the Internet
on computers now!

Posts: 1861
Location: Salem, NH
Joined: Nov 24th, 2002
Re: Combining Elements to Make Unique Ext. Key
Reply #6 - Apr 3rd, 2005 at 4:25am
Print Post Print Post  
Good example of suggested syntax, I like it!  Now I have a better understanding of what you were proposing, has no need to create keys if none exist.

It accomplishes the same thing that is done now by combining two XLUs which is what must be done now if keys don't exist.

Modification to proposal would be not to limit the number of concatenated fields to only two. (Doesn't take long to get greedy, huh!).
  



Bob Hansen
Sesame Database Manager Professional
Sensible Solutions Inc.
Salem, NH
603-898-8223
Skype ID = sensiblesolutions
Back to top
IP Logged
 
Bharat_Naik
Senior Member
Members
*****
Offline


Ever ready to learn and
share

Posts: 1202
Location: Chicago,  Illinois
Joined: Dec 16th, 2003
Re: Combining Elements to Make Unique Ext. Key
Reply #7 - Apr 3rd, 2005 at 5:50am
Print Post Print Post  
Quote:
Modification to proposal would be not to limit the number of concatenated fields to only two. (Doesn't take long to get greedy, huh!)


I agree...

And may be, just may be... (I know, I am going out of control here)  accomodation of little code, such as

vValue = @xlookup (@fn, vString, "Customer!(Name + Birthday + @Left (zip, 5))",  "Contact Info")

Is it too much of asking? I hope Erika and Mark are listening.

Thanks Bob.

In the past,  in order to shorten long pickup list, we used @xuserselectr ( ) and used the filter function and loops. But now Sesame Development team gave us @xlookupall ( ) and the same thing can be achieved in just one statement.  They really got us spoiled by giving all those goodies!!!   Grin
  
Back to top
 
IP Logged
 
Bharat_Naik
Senior Member
Members
*****
Offline


Ever ready to learn and
share

Posts: 1202
Location: Chicago,  Illinois
Joined: Dec 16th, 2003
Re: Combining Elements to Make Unique Ext. Key
Reply #8 - Apr 5th, 2005 at 4:01pm
Print Post Print Post  
I would appreciate feedback from any of the lanticans on this topic as to whether it is do-able or/and worthwhile.

The problem with flat file database structure is usually duplication of data as everything that needs to have output has to be in the same layout and database you are working with. In Q&A at least we could merge data from other databases in write module and same thing we could do with the report. In Sesame, we are handicapped in this regard with the exception of subform where one has direct connection with other subform and subdatabase. This leads to adding so many other element in the layout and database just to facilitate output. Naturally the goal would be to conserve resources to have application slim and fast. Considering this, whatever helps less coding and minmum necessary elements should help towards this goal.

I will appreciate your feedback on this matter and help to guide us towards the goal of making fast and practical applications to run our business.

Thank you.
« Last Edit: Apr 5th, 2005 at 6:14pm by Bharat_Naik »  
Back to top
 
IP Logged
 
Hammer
YaBB Administrator
Lanticans
*****
Offline


Fire bad. Tree pretty.

Posts: 3436
Location: Ohio
Joined: Nov 22nd, 2002
Re: Combining Elements to Make Unique Ext. Key
Reply #9 - Apr 5th, 2005 at 4:14pm
Print Post Print Post  
It is worthwhile. While it is doable, it requires a large amount of work and increases the complexity of the X-commands by at least an order or magnitude. Being able to query against multiple values inside these commands is something we would like to have. We'll see if this is reasonably doable, and if it is the best method by which to provide this capability.
  

- Hammer
The plural of anecdote is not data.
Back to top
IP Logged
 
Bharat_Naik
Senior Member
Members
*****
Offline


Ever ready to learn and
share

Posts: 1202
Location: Chicago,  Illinois
Joined: Dec 16th, 2003
Re: Combining Elements to Make Unique Ext. Key
Reply #10 - Apr 5th, 2005 at 4:32pm
Print Post Print Post  
Thanks Erika.
  
Back to top
 
IP Logged
 
digimom1962
Junior Member
**
Offline


Natalie Gann

Posts: 92
Location: here
Joined: Nov 26th, 2004
Re: Combining Elements to Make Unique Ext. Key
Reply #11 - Apr 7th, 2006 at 4:44pm
Print Post Print Post  
Cannot seem to find any info as to if this ever became possible? Just so happens I was about to post a similar (if less coherent) question and since this post was from over a year ago, was hoping I might have just overlooked the update & solution.

Thanx
~Natalie
  

So much time and so little to do . . . strike that, reverse it.
Back to top
YIM YIM  
IP Logged
 
Hammer
YaBB Administrator
Lanticans
*****
Offline


Fire bad. Tree pretty.

Posts: 3436
Location: Ohio
Joined: Nov 22nd, 2002
Re: Combining Elements to Make Unique Ext. Key
Reply #12 - Apr 7th, 2006 at 5:20pm
Print Post Print Post  
It's not possible in 1.1. We are still looking at it for 2.0.
  

- Hammer
The plural of anecdote is not data.
Back to top
IP Logged
 
digimom1962
Junior Member
**
Offline


Natalie Gann

Posts: 92
Location: here
Joined: Nov 26th, 2004
Re: Combining Elements to Make Unique Ext. Key
Reply #13 - Apr 7th, 2006 at 6:28pm
Print Post Print Post  
Ah well, I'll keep my fingers crossed Roll Eyes
Thanx for the update!

~Natalie
  

So much time and so little to do . . . strike that, reverse it.
Back to top
YIM YIM  
IP Logged
 
Carl Underwood
Senior Member
Members
*****
Offline



Posts: 1350
Location: New Hampshire
Joined: Mar 11th, 2003
Re: Combining Elements to Make Unique Ext. Key
Reply #14 - Apr 7th, 2006 at 7:26pm
Print Post Print Post  
Quote:
There are times, while using x-family commands and functions, there is no unique external key in a database with the use of one element but if one can combine two elements that would give Unique...

You know, I'm sure this can be worked out in programming with @XLookupSourceListAll and the string array functions.

I'm already using @XLookupSourceListAll to place a bunch of records in a string array, on which I can sort them by date, and end up finding which one is the most recent. So, I'm effectively retrieving a record based on 2 criteria: the name AND the maximum date.

I'm pretty sure this technique could be adapted, to say, find all records where ZIP code = nnnnn, and then run those through a loop to find which one meets a second criteria. Or if that is likely to get more than one record, you could run those results through another loop to narrow it down to a third criteria, etc, etc.

Hmm...
This give me an idea for an Inside Sesame article. Now just to find time to write it.
  


Carl Underwood
CDU Computer Consulting LLC
Epsom, New Hampshire
Back to top
IP Logged
 
Page Index Toggle Pages: [1] 2 3 
Send Topic Send Topic Print Print