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

How to check if a table exists and replace if it does?

 
Post new topic   Reply to topic    OOoForum.org Forum Index -> OpenOffice.org Macros and API
View previous topic :: View next topic  
Author Message
prholland
General User
General User


Joined: 23 Oct 2005
Posts: 31
Location: Royston, Herts, UK

PostPosted: Sun Jan 07, 2007 3:33 pm    Post subject: How to check if a table exists and replace if it does? Reply with quote

How do you check if a table exists and replace if it does?

I've tried "DROP TABLE x IFD EXISTS":

rs=st.executeQuery("DROP TABLE " & MDB_TABLE & " IF EXISTS")

but I get error messages like:
Message: syntax error, unexpected DROP, expecting BETWEEN or SQL_TOKEN_IN or SQL_TOKEN_LIKE.

................Phil
_________________
--
Philip R Holland
[OOo 1.1.5 + 2.3.1, WinXP Pro/Ubuntu 7.10]
Holland Numerics Ltd, Royston, Herts, UK
Back to top
View user's profile Send private message Visit poster's website
prholland
General User
General User


Joined: 23 Oct 2005
Posts: 31
Location: Royston, Herts, UK

PostPosted: Thu Jan 11, 2007 5:32 am    Post subject: How to check if a table exists and replace if it does? Reply with quote

I think I've resolved my own problem. The table I was trying to delete was connected using sdbc:dbase:, which, unfortunately, can only be connected as Read Only, so this caused the error message.

.........Phil
_________________
--
Philip R Holland
[OOo 1.1.5 + 2.3.1, WinXP Pro/Ubuntu 7.10]
Holland Numerics Ltd, Royston, Herts, UK
Back to top
View user's profile Send private message Visit poster's website
Danad
OOo Advocate
OOo Advocate


Joined: 22 Feb 2004
Posts: 293
Location: Brasil

PostPosted: Thu Jan 11, 2007 5:57 am    Post subject: Reply with quote

I guess you´ve to:
- get a container with getTables
- call method dropByIndex or dropByName
- append a new table

It seems there is not any API to replace a table.

HTH
Back to top
View user's profile Send private message
prholland
General User
General User


Joined: 23 Oct 2005
Posts: 31
Location: Royston, Herts, UK

PostPosted: Thu Jan 11, 2007 6:11 am    Post subject: How to check if a table exists and replace if it does? Reply with quote

When I converted the table the HSQLDB, the code I used worked fine, as the connection was now Read/Write. The performance of the data load, however, was not acceptable when adding 200K records, so I've reverted to just reading an existing CSV file instead.

.........Phil
_________________
--
Philip R Holland
[OOo 1.1.5 + 2.3.1, WinXP Pro/Ubuntu 7.10]
Holland Numerics Ltd, Royston, Herts, UK
Back to top
View user's profile Send private message Visit poster's website
Danad
OOo Advocate
OOo Advocate


Joined: 22 Feb 2004
Posts: 293
Location: Brasil

PostPosted: Thu Jan 11, 2007 6:26 am    Post subject: Reply with quote

Well, HSQL works with TEXT TABLES maybe it is good to you, more info:

http://www.hsqldb.org/web/hsqlDocsFrame.html

Chapter 6 - Text Tables

HTH
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 Macros and API 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