Page 1 of 1

revdb_execute vs revExecuteSQL

Posted: Thu Jun 02, 2011 3:29 am
by Peter K
Any preference on which to use? I know that revdb_execute was introduced in version 1.1 and revExecuteSQL was introduced in version 2.0. Is revExecuteSQL an update for redb_execute?

Thanks,

Peter

Re: revdb_execute vs revExecuteSQL

Posted: Thu Jun 02, 2011 10:47 am
by SparkOut
The Livecode dictionary under the entry for revdb_execute wrote:Comments:
Evaluating the revdb_execute function has the same effect as executing the revExecuteSQL command. The only difference is that one is a function call and the other is a command.
Specifically the return value from the revdb_execute function should contain the number of rows affected by the query which should be available in the "it" variable. revExecuteSQL will return a value in "the result" which indicates the number of rows affected, or any error message.

Re: revdb_execute vs revExecuteSQL

Posted: Thu Jun 02, 2011 3:39 pm
by Peter K
Are there situations in which you would want to use one over the other? Or is it personal perference?

Thanks,

Peter

Re: revdb_execute vs revExecuteSQL

Posted: Sun Jun 05, 2011 12:14 pm
by Janschenkel
Nope, the two are equivalent, so it is a matter of programming style. The revdb_execute function was there first, when the revDB external was introduced back in version 1.1.1 - and all of the commands and functions in that external library were prefixed with 'revdb_' to make it easier to know where they were coming from. Around version 2.0, synonyms were added that simply start with 'rev' but were less low-level technical sounding (revdb_connect <> revOpenDatabase). And for fans of the command-query separation principle, it makes more sense to have a command than a function if you're modifying data.

I don't think either form will go away - but I personally hope that at some point in the future, the database calls get nice syntax baked into the language :-)

Jan Schenkel.