Building data base aps with Rev
Jan Schenkel
janschenkel at yahoo.com
Sun May 18 09:03:00 EDT 2003
--- Jan Schenkel <janschenkel at yahoo.com> wrote:
> [snip]
>
> on PopulateFields pConnectionID, pColumns, pTables,
> pCondition
> -- 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
> tCursor
> if tCursor is not a number then answer tCursor
> else
> repeat with i = 1 to
> revDatabaseColumnCount(tCursor)
> 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
>
Hmm, appearently my brain was still partially on
holiday, so let me correct the above:
if tCursor is not a number then answer tCursor
else
repeat with i = 1 to
revDatabaseColumnCount(tCursor)
put revDatabaseColumnNumbered(tCursor,i) into
field i
end repeat
end if
--- and ---
put revDatabaseColumnNames(tCursor) into \
tColumnNames
repeat for each item tColumnName in tColumnNames
if there is a field tColumnName then put \
revDatabaseColumnNamed(tCursor, tColumnName)
\
into field tColumnName
end repeat
Sorry about any confusion I may have caused.
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.
http://search.yahoo.com
More information about the use-livecode
mailing list