Marc Santhoff wrote:

sub quoteSQL
        oDataSource = createUnoService( _
                "com.sun.star.sdb.DatabaseContext" ).getByName( "test j" )
        oConnection = oDataSource.getConnection( "marc", "*******" )
        oCmp = oConnection.createQueryComposer()
        oCmp.setQuery("SELECT A, B FROM TestTab WHERE ((A=15021) OR (C=1,2))")
        msgbox oCmp.getComposedQuery()

        oConnection.close()

end sub


OK - well let's prime the pump so to speak.

Looking at the above to convert from the use of a SQLQueryComposer to a SingleSelectQueryComposer



sub quoteSQL
  oDataSource = createUnoService( _
    "com.sun.star.sdb.DatabaseContext" ).getByName( "test j")
  oConnection = oDataSource.getConnection( "marc", "*******" )

  REM
  REM The SingleSelectQueryComposer is returned by a
  REM a factory, so we need to use createInstance
  REM and tell the factory what type of service
  REM provider we want
  REM

  oCmp = oConnection.createinstance( _
        "com.sun.star.sdb.SingleSelectQueryComposer")

  oCmp.setQuery("SELECT A, B FROM TestTab WHERE ((A=15021) OR (C=1,2))")

  REM the method getComposedQuery is not supported
  REM
  REM SingleSelectQueryCAnalyzer has instead two
  REM properties:
  REM
  REM  ElementaryQuery
  REM    Returns the SQL as stored
  REM
  REM  QueryWithSubstitution
  REM
  REM    Returns the SQL as it will be
  REM    sent to the database engine
  REM
  REM so here I would use

  msgbox oCmp.QueryWithSubstitution

  REM but in reality  for the SQL used
  REM ElementaryQuery and
  REM QueryWithSubstitution will return
  REM identical strings

  oConnection.close()

end sub

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to