OpenOffice.org Forum at OOoForum.orgThe OpenOffice.org Forum
 
 [Home]   [FAQ]   [Search]   [Memberlist]   [Usergroups]   [Register
 [Profile]   [Log in to check your private messages]   [Log in

Table not found in statement ?

 
Post new topic   Reply to topic    OOoForum.org Forum Index -> OpenOffice.org Base
View previous topic :: View next topic  
Author Message
oodev
Newbie
Newbie


Joined: 07 Oct 2006
Posts: 4

PostPosted: Mon Oct 09, 2006 1:55 pm    Post subject: Table not found in statement ? Reply with quote

Hi,
I've a very simple SQL statement, that can be executed as a query in the OO Base IDE (2.0.3) but not in a macro.
To get sure that the table exists I print all tablenames.
But the same table name('mytab') in my sql statement fails.Sad

Can anyone help?

Code:

Sub Main
Const sDBBaseName$ = "MyOODB"

Dim ctx As Object
Dim ds As Object
Dim con As Object
Dim stmnt As Object
Dim rs As Object
Dim sql As String
Dim txt As String

sql = "SELECT * FROM mytab"
ctx = CreateUnoService("com.sun.star.sdb.DatabaseContext")
ds = ctx.getByName(sDBBaseName$)
con = ds.getConnection("", "")

oTables = con.getTables()
For iCount = 0 To oTables.Count - 1
   txt = txt + " " + oTables.ElementNames(iCount)
Next iCount
Print txt

stmnt = con.createStatement()
rs = stmnt.executeQuery(sql)
'SQLException
'Message:Table not found in statement [SELECT * FROM mytab]

If Not isNull(rs) Then
    txt = ""
   While rs.next()
      txt = txt + " " + rs.getString(1)
   Wend
Else
   MsgBox("rs is null")
End If

con.close()
End Sub
Back to top
View user's profile Send private message
DrewJensen
Super User
Super User


Joined: 06 Jul 2005
Posts: 2616
Location: Cumberland, MD

PostPosted: Mon Oct 09, 2006 3:53 pm    Post subject: Reply with quote

The problem is quoting.

The rule for HSQLDB, as used in Base's embedded database model.

If column names or table names are not ALL CAPITAL they must be double quoted.

sql = "SELECT * FROM ""mytab"""
Back to top
View user's profile Send private message Send e-mail Visit poster's website
oodev
Newbie
Newbie


Joined: 07 Oct 2006
Posts: 4

PostPosted: Tue Oct 10, 2006 1:24 pm    Post subject: Reply with quote

just thanx, thanx, thanx Idea

A little bit strange, but ok I'll get used to it
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    OOoForum.org Forum Index -> OpenOffice.org Base All times are GMT - 8 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group