Building data base aps with Rev (Jan Schenkel)

Jan Schenkel janschenkel at
Tue May 20 06:52:01 EDT 2003

--- Jan Schenkel <janschenkel at> wrote:
> --- Sadhunathan Nadesan <sadhu at>
> wrote:
> > | 
> > | If you wanted to go the 'non-scripting way', I
> can
> > | have a look at it tomorrow ; don't have my
> > 'database'
> > | computer with me this evening.
> > | 
> > 
> > 	Yes, for sure, I'd be interested in that too.
> > 
> > 	Again, wow!  Many thanks.  I don't know about
> stuff
> > like
> > 	portal fields and custom props but you have given
> > so many
> > 	clues that, I am going to enjoy figuring it out.
> > 
> > 	Gee, this is really wonderful of you.  
> > 
> > 	Gratefully,
> > 	Sadhu
> Hi Sadhu,
> As promised, I had a look at how to accomplish the
> same thing without (too much) scripting. Here's what
> I
> found:
> [snip]

After I had hit the 'send' button, I realised I wasn't
finished yet in terms of a master-detail form ; so
there's one more thing to solve in the point-and-click
scenario : synchronising the master and details.

DISCLAIMER: Pleas note that this is based on diving
deep into the revDatabase functions, below the
published API ; as such, it may not work in future
versions !

What we need to do is alter the portal and detail
queries dynamically upon moving along the master
record cursor.

First we change the Portal and Detail queries with the
query builder, so that they get the form
  SELECT * FROM locations WHERE country = "BEL"

Note that "BEL" would be the primary key for the
master records and the foreign key for the detail

One of the features of the buttons that are linked to
queries, is that they get a mouseUp after having
handled the record move.

So put the following script into the "Next" button
(other buttons are analogous).

on mouseUp
  -- fetch the new primary key
  put quote & field "countryID" & quote \
      into tPrimaryKey
  -- fetch references to the query objects
  put the cREVDatabase["queryobject"] of fld \
      "Portal" into tPortalObject
  put revQueryLongName(tPortalObject) into \
  put the cREVDatabase["queryobject"] of fld \
      "Detail1" into tDetailObject
  put revQueryLongName(tDetailObject) into \
  -- fetch the query and adapt it
  put the cREVDatabaseQuery["sqlquery"] of \
      tPortalObject into tSQLQuery
  put tPrimaryKey into word -1 of tSQLQuery
  -- now update the query objects
  -- auto refresh + move to the first record
  send "revSetSQLOfQuery" && tPortalObject & \
      comma & tSQLQuery
  send "revSetSQLOfQuery" && tDetailObject & \
      comma & tSQLQuery
  -- and select the first line in the portal
  set the hilitedLines of fld "Portal" to 1
end mouseUp

Admittedly, this piece of script and similar
adventures are not for the faint-hearted, as it
requires a good look around the 'revDatabase'

Nevertheless, I hope this helped,

Jan Schenkel.

"As we grow older, we grow both wiser and more foolish at the same time."  (La Rochefoucauld)

Do you Yahoo!?
The New Yahoo! Search - Faster. Easier. Bingo.

More information about the use-livecode mailing list