Normal Topic XResultSetValue question (Read 1589 times)
tcgeo
Full Member
***
Offline



Posts: 278
Location: Traverse City, Michigan
Joined: May 13th, 2008
XResultSetValue question
Dec 8th, 2009 at 3:27pm
Print Post Print Post  
I’ve been using XPOST to grab data from one LE on the last retrieved record in database #1 and coping over data with that data in an LE in database #2.  While reading through all of the posts covering XPOST, some of them suggest using XResultSetValue instead of XPOST because it’s faster and  ”XPOST only exists for Q&A compatibility. Always use XResultSet to update an external record.”
 
I understand that if I was in database #2 that I can pull the data from database #1 and place it in an LE in database #2, but I don’t want to have to go to database #2 to perform this.  Is it possible to use XResultSetValue or any other XResultSet command to set the value of an LE in database #2 from an LE in database #1 while still in database #1?    

Thanks
  
Back to top
IP Logged
 
Hammer
YaBB Administrator
Lanticans
*****
Offline


Fire bad. Tree pretty.

Posts: 3436
Location: Ohio
Joined: Nov 22nd, 2002
Re: XResultSetValue question
Reply #1 - Dec 8th, 2009 at 7:38pm
Print Post Print Post  
XResultSetValue sets a value in an external database. So, yes, you can set a value in database #2 by running XResultSetValue from database #1.
  

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



Posts: 278
Location: Traverse City, Michigan
Joined: May 13th, 2008
Re: XResultSetValue question
Reply #2 - Dec 8th, 2009 at 7:54pm
Print Post Print Post  
Ok, can you tell me how I would go about it please.

This is what I see in the manual:
"This command takes as its first argument the "handle" to the result set. The next
argument is the field name of the field to set. The last argument is the actual value to
set."

Would the field name of the field to set include the name of the database, such as: database#2!Field name?

And then how would it designate which record in database#2?

Thanks
  
Back to top
IP Logged
 
The Cow
YaBB Administrator
*****
Offline



Posts: 2530
Joined: Nov 22nd, 2002
Re: XResultSetValue question
Reply #3 - Dec 8th, 2009 at 9:40pm
Print Post Print Post  
You would use @XResultSetSearch to get the handle, specify the database, and select the appropriate records. Take a look in list browser for an example.
  

Mark Lasersohn&&Programmer&&Lantica Software, LLC
Back to top
IP Logged
 
tcgeo
Full Member
***
Offline



Posts: 278
Location: Traverse City, Michigan
Joined: May 13th, 2008
Re: XResultSetValue question
Reply #4 - Dec 8th, 2009 at 10:54pm
Print Post Print Post  
Hi,

I'm already using @XResultSetSearch to get the data from an LE in database#1 that needs to be placed into database#2 without trouble.  I can also use XResultSetValue to place that data in an LE in database#1 without trouble.

I'm sure it's my limited ability to understand and please forgive me but I've scoured the list browser and the forms for a week or two on how to use XResultSetValue to place the data into an external database and can't seem to be able to figure it out.

Erika said: "XResultSetValue sets a value in an external database" so how do I designate this external database when all that the list browser says for XResultSetValue is: "This command takes as its first argument the "handle" to the result set. The next argument is the field name of the field to set. The last argument is the actual value to set."

Again, I have no trouble using it to set a value in an LE in the current database.  How do I change the second argument to set the field in an external database on the correct record?

This is the current XPost command I’m using:
XPOST(@Fn, 1, "Database#2!Record who’s value will be changed", Database#1 LE that contains value, Database#2 LE that gets value", "")

So, I know it’s my lack of knowledge on how the XResultSet commands work, but I can’t seem to understand the logic. Are there other XResultSet commands that must be use together to make this work?

Thanks for your help & patience.
  
Back to top
IP Logged
 
The Cow
YaBB Administrator
*****
Offline



Posts: 2530
Joined: Nov 22nd, 2002
Re: XResultSetValue question
Reply #5 - Dec 9th, 2009 at 1:40am
Print Post Print Post  
If you are getting the values from one result set and placing them in a second result set, you will need to use two @XResultSetSearch commands. First do an @XResultSetSearch to get the result set you are reading from, and use @XResultSetValue to read the value(s) you interested in. If your search returns more than one record, use XResultSetCurrentPosition to control which record(s) it is reading values from. Then use another call to @XResultSetSearch to second a second handle to the second database. Then use XResultSetValue with that second handle to write the values into the fields in the appropriate records. If your second search returns more than one result, use XResultSetCurrentPosition to control which records are being written to. Then close both result sets with two calls to XResultSetClose, one for each "open" handle.

If we assume that each search only returns one record:
Code
Select All
// search database1 ("Pricing") for a particular region
handle1 = @XResultSetSearch(@FN, "Pricing", SEARCH_MODE_OR, SEARCH_SYNTAX_QA, "RegionID=" + vRegion)
if(handle1 <> -1)
{
    // search the second database ("Inventory") for an item ID
    handle2 = @XResultSetSearch(@FN, "Inventory", SEARCH_MODE_OR, SEARCH_SYNTAX_QA, "ItemID=" + vItem)
    if(handle2 <> -1)
    {
         // get the price from database 1 (for the specific region)
         vPrice = @XResultSetValue(handle1, "Price")

         // write the value to a different field in the record in database 2, as returned by the search
         XResultSetValue(handle2, "ItemPrice", vPrice)

         // close the result set for database 2
         XResultSetClose(handle2)
    }
    // close the result set for database 1
    XResultSetClose(handle1)
}
 



I don't have access to Sesame right now, so I couldn't test the code above and wrote it from memory. But it should be enough to give you the basic idea of how to use two result sets from two different databases. You will, of course, have to include the steps I left out, like declaring variables.
  

Mark Lasersohn&&Programmer&&Lantica Software, LLC
Back to top
IP Logged
 
tcgeo
Full Member
***
Offline



Posts: 278
Location: Traverse City, Michigan
Joined: May 13th, 2008
Re: XResultSetValue question
Reply #6 - Dec 9th, 2009 at 11:57am
Print Post Print Post  
Thank you Mark,

That pushed me in the right direction.  I never would have thought to do it with two @XResultSetSearch commands.   You've definitely expanded my thinking on this and I'll go to work on it.

Thanks again,

Brandon
  
Back to top
IP Logged