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

Problem with SELECT INTO CACHED workaround

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


Joined: 26 Nov 2007
Posts: 1

PostPosted: Mon Nov 26, 2007 4:13 am    Post subject: Problem with SELECT INTO CACHED workaround Reply with quote

Hi,

I read about the SELECT INTO CACHED workaround for the SELECT INTO problem.
However, the new problem is that this workaround creates a new table where i cant edit the entries. I can still add new columns to it in the design table view though. Anyway to unlock the newly created table?
Back to top
View user's profile Send private message
Sliderule
Super User
Super User


Joined: 29 May 2004
Posts: 2474
Location: 3rd Rock From The Sun

PostPosted: Tue Nov 27, 2007 11:29 am    Post subject: Reply with quote

sunkist:

You asked about being able to "edit the entries" in a table you have created with a SELECT INTO CACHED statement.

Just for others reading this, I will assume, you have 'created' a new table . . . let us assume for example . . . you have a table named "MY_TABLE" and you want to create a 'new' table named "MY_TABLE_NEW" as a subset of it ( based on the table field "DATE_FIELD" ) . . . so . . . from the Menu: Tools -> SQL... -> you then entered:
Code:
SELECT * INTO CACHED "MY_TABLE_NEW" FROM "MY_TABLE" WHERE "DATE_FIELD" >= '2007-02-28' AND "DATE_FIELD" <= '2007-07-15'

Well . . . the above will create your table, BUT, it does NOT yet have a PRIMARY KEY . . . therefore, within BASE, you can 'read' it, but not Modify the data.

So, in order to create the PRIMARY KEY ( must be 'UNIQUE' for each record ) . . . according to HSQL documentation at: http://www.hsqldb.org/doc/guide/ch09.html#alter_table-section
Quote:
ALTER TABLE <tablename> ADD [CONSTRAINT <constraintname>] PRIMARY KEY (<column list>);

Adds a primary key constraint to the table, using the same constraint syntax as when the primary key is specified in a table definition.

So, with the above example, from the Menu: Tools -> SQL... -> you then might enter:
Code:
ALTER TABLE "MY_TABLE_NEW" ADD PRIMARY KEY ("DATE_FIELD", "TIME_FIELD");

This will create your designated PRIMARY KEY on fields DATE_FIELD and TIME_FIELD, so, you will be able to "Edit" the entries ( values ) of your newly created table ( of course change the field names BETWEEN PARENTHESES, to reflect YOUR table requirements ).

I hope this helps, please be sure to let me / us know.

Sliderule

Thanks to add [Solved] in your first post title (edit button) if your issue has been fixed / resolved.
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