On 11/08/2013 06:52 AM, Ricardo Aráoz wrote:
I want to query the database from within a form which already has a
bizObject defined.
In the wiki HowToCreateATempCursor page recommends using
getTempCursor() stating that "The above will not
change/touch/overwrite the CustomerBizObj data.".
In the wiki DataSet page we get a DataSet and then we use execute() to
perform the query, with the added advantage that we are able to query
the bizObject's table by using "dataset" to refer to it, and other
dataSets by using a dictionary of dataSets. This is nice because if I
have virtual fields defined I can query them without having to worry
about them.
But in the API page (at paul.dabodev.com) of the bizObject I can read
about execute() "Execute the sql on the cursor. Dangerous. Use
executeSafe instead." and we also have an executeSafe() which says
"This is considered 'safe', because it won't harm the contents of the
main cursor.". Now I understand the bizObject is not the same as a
DataSet, but in the same API site under dCursorMixin I can see both
methods execute() (without the "Dangerous" warning) and the
executeSafe() method which says it is "safe" (that would imply that
execute() is not(?)).
So I'm sitting here wondering about the hidden dangers (not specified
anywhere) of issuing a query.
I will probably use the dataSet.execute() method as it allows me to
query the bizObj defined view but I would like to be sure.
"There should be one-- and preferably only one --obvious way to do it."
I use the getTempCursor() all the time. I create some thing like
tc=self.PrimaryBizObj.getTempCursor()
sql = some sql statement
tc.execute(sql)
if I have a small dataset and need to manipulate the dataset I will use
something like this:
ds = self.listData.getDataSet()
self.txndata = ds.execute("select * from dataset where somefield = %s")
I have discovered that using the dataset (as in above) and having a
large dataset that the performance in not very good. So I will just make
a new query.
I don't use filters very often. So I can't really comment.
I also avoid some of the extra queries by just opening the table a
second time (see datasourcename) and setting what I want in the bizobj.
As far as being safe I have never seen where Dabo did any damage to any
data or dataset. It maybe an issue of the dataset pointer moving and
you should check it just to be sure.
Johnf
_______________________________________________
Post Messages to: [email protected]
Subscription Maintenance: http://mail.leafe.com/mailman/listinfo/dabo-users
Searchable Archives: http://leafe.com/archives/search/dabo-users
This message: http://leafe.com/archives/byMID/[email protected]