Building data base aps with Rev

Jan Schenkel janschenkel at
Sun May 18 08:42:01 EDT 2003

--- Sadhunathan Nadesan <sadhu at> wrote:
> Greetings,
> You folks may know that my thing is building data
> base applications,
> and I'm searching for good tools for our company's
> next generation
> of Internet enabled aps.  Consequently dabbling with
> Revolution, but
> consider myself a newbie.
> So anyway, I'd like to see tools for building
> generic screens and such,
> but in absence of those, I'm looking for code
> examples.  Anyone have a
> suggestion for me?
> [snip]
> I'm fervently hoping there are others on this list
> with the same
> interest.
> And thank you in advance.
> Sadhu

Hi Sadhu,

Off the top of my head there are two ways: 

1) Check out the new Query Builder functionality,
which allows you to store queries in a stack, and then
'hook up' buttons and fields

- Create a new stack

- Menu 'Tools' > Item 'Database Query Builder'
- Click on the '+' button to create a new query
- Give the query a name and fill in the connection
- Click on the 'Connect' button
- Now go to the 'RecordSet' tab
- Select a table, and tweak the SQL query
    Ex: SELECT * FROM locations
- Select the primary key field

- Now place a field on the card
- Open the 'Inspector' palette
- Go to the 'Database' panel
- Select the query you created earlier
- Select the column you want to dsplay in that field
    Ex: location

- Make and link some more fields

- Now place a button on the card
- Open the 'Inspector' palette
- Go to the 'Database' panel
- Select the query you created earlier
- Select the action you want to execute
    Ex: Move to the next record

- Make and link some more buttons to traverse the
records in the query cursor.

-> There you have it, without writing a single line of
code, and you can even refresh and update records if
you want to  *cheers*

2) If you're not afraid of scripting, and are just
populating fields for display, you can do it even more

on PopulateFields pConnectionID, pColumns, pTables,
  -- asuming you have connected already
  --  pConnectionID = the connection number
  -- now let's make good use of the merge function
  --  pColumns   = the column names
  --  pTables    = the table(s) involved
  --  pCondition = the content of the WHERE-clause
  put merge("SELECT [[pColumns]] FROM [[pTables]]
WHERE [[pCondition]] ;") into tSQLQuery
  put revQueryDatabase(pConnectionID,tSQLQuery) into
  if tCursor is not a number then answer tCursor
    repeat with i = 1 to
      put revDatabaseColumnNumbered(i) into field i
    end repeat
  end if
end PopulateFields

Nice and simple, but you'll have more work to do if
you want to update records in the database.
Personally, I prefer to work with the column names,
and that's just as easy to implement, and I like a bit
of error checking as well :

    put revDatabaseColumnNames() into tColumnNames
    repeat for each item tColumnName in tColumnNames
      if there is a field tColumnName then put \
         revDatabaseColumnNamed(tColumnName) into \
         field tColumnName
    end repeat

Hope this gets you going,

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