Re: ResultSet type default to FORWARD_ONLY with mysql db ?

Frank Schönheit - Sun Microsystems Germa ny <[email protected]>
Newsgroups gmane.comp.openoffice.dba.user
Message-ID <[email protected]>
Hi Alex,

> And the answer is...
> 
> com.sun.star.sdb.OResultset

This one inherits ResultSetType and ResultSetConcurrency from the
driver's result set, which then suggests that in fact the MyODBC driver
does only allow FORWARD_ONLY.

> Hmmm, that is what I thought too, although the documentation doesn't
> seem to make this very clear, it just says that it gets the "default
> properties" without stating what they are ;-)

Which "the documentation"? :) css.sdb.ResultSet? css.sdbcx.ResultSet?
css.sdbc.ResultSet? Other?

> Option explicit
> 
> Sub LireResultatRequeteSQL()
> Dim maSource as Object, monDBContext as Object
> Dim login as String, password as String, user as String
> dim maRequete as Object, resuQuery as Long, resuQuery1 as Object
> dim instrSQL as String, monSignet as Variant
> dim execOK as Boolean, info as String, cr as String
> cr = chr(13)
> 
> monDBContext = CreateUnoService("com.sun.star.sdb.DatabaseContext")
> maSource = monDBContext.getByName("mybase")
> maConnexion = maSource.getConnection("user","pwd")
> 
> 
> instrSQL = "INSERT INTO file_num (file_num_id) VALUES (NULL)"
> maRequete = maConnexion.createStatement()
> resuQuery = maRequete.executeUpdate(instrSQL)
> 
> instrSQL = "SELECT file_num_id from file_num where file_num_id =
> last_insert_id()"
> maRequete = maConnexion.createStatement()
> resuQuery1 = maRequete.executeQuery(instrSQL)

To be on the safe side, you might want to do
  rowSet = createUnoService( "com.sun.star.sdb.RowSet" )
  rowSet.ActiveConnection = maConnexion
  rowSet.CommandType = com.sun.star.sdb.COMMAND
  rowSet.Command = "SELECT file_num_id from file_num where" + _
    "file_num_id = last_insert_id()"

  ' not sure if you also need:
  rowSet.DataSourceName = maSource.Name

  rowSet.execute

Then, use rowSet instead of resuQuery1 (and don't forget
"rowSet.dispose" when you're done with it).

Or, alternatively, change your algorithm to not need any other call than
"next" :)

Ciao
Frank

-- 
- Frank Schönheit, Software Engineer         [email protected] -
- Sun Microsystems                      http://www.sun.com/staroffice -
- OpenOffice.org Database                   http://dba.openoffice.org -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.