Am Donnerstag, den 11.08.2005, 17:50 +0200 schrieb Marc Santhoff:
> Am Donnerstag, den 11.08.2005, 08:28 +0200 schrieb Frank Schönheit - Sun
Me again, I've done some testing and ran into something strange.
First, it is not a MS-SQL server but an old MySQL-Server (3.23.x) and
currently driven by the "com.mysql.jdbc.Driver" jdbc stuff (read over
too quickly).
Secondly, there is no oConnection.createInstance in OOo 1.1.3 but this
code does in fact work:
sub quoteSQL
oDataSource = createUnoService( _
"com.sun.star.sdb.DatabaseContext" ).getByName( "test j" )
' "com.sun.star.sdb.DatabaseContext" ).getByName( "Bibliography" )
oConnection = oDataSource.getConnection( "marc", "nonono" )
oCmp = oConnection.createQueryComposer()
'oCmp.setQuery("SELECT Indentifier FROM biblio")
' NOT Okay -oCmp.setQuery("SELECT A, B, C, D, E, F, G FROM test.TestTab
Testtab WHERE ((A=15021) OR (A=15020))")
' Okay - oCmp.setQuery("SELECT * FROM TestTab WHERE ((A=15021) OR
(A=15020))")
' Okay - oCmp.setQuery("SELECT A FROM TestTab WHERE ((A=15021) OR
(A=15020))")
' Okay - oCmp.setQuery("SELECT A, B FROM TestTab WHERE ((A=15021) OR
(A=15020))")
' Okay - oCmp.setQuery("SELECT A, B, C FROM TestTab WHERE ((A=15021) OR
(A=15020))")
' NOT Okay (css.sdbs.SQLException: "Syntax error in SQL expression"):
oCmp.setQuery("SELECT A, B, C, D FROM TestTab WHERE ((A=15021) OR
(A=15020))")
msgbox oCmp.getComposedQuery()
oConnection.close()
end sub
But have a look at the different SQL statements, up to two single column
names it work, but stops at the fourth.
How can I check if this is a problem with the JDBC-driver or with OOo?
And why does it occur? Column names are Okay (see below)...
mysql> use test
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A
Database changed
mysql> describe TestTab;
+-------+---------------+------+-----+---------+-------+---------------------------------+
| Field | Type | Null | Key | Default | Extra | Privileges
|
+-------+---------------+------+-----+---------+-------+---------------------------------+
| A | int(11) | | PRI | 0 | |
select,insert,update,references |
| B | varchar(50) | YES | | NULL | |
select,insert,update,references |
| C | double | YES | | NULL | |
select,insert,update,references |
| D | float | YES | | NULL | |
select,insert,update,references |
| E | decimal(12,2) | YES | | NULL | |
select,insert,update,references |
| F | date | YES | | NULL | |
select,insert,update,references |
| G | date | YES | | NULL | |
select,insert,update,references |
+-------+---------------+------+-----+---------+-------+---------------------------------+
7 rows in set (0.02 sec)
TIA,
Marc
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]