Welcome to NeoOffice developer notes and announcements
NeoOffice
Developer notes and announcements
 
 

This website is an archive and is no longer active
NeoOffice announcements have moved to the NeoOffice News website


Support
· Forums
· NeoOffice Support
· NeoWiki


Announcements
· Twitter @NeoOffice


Downloads
· Download NeoOffice


  
NeoOffice :: View topic - "Error inserting the new record" when adding row i
"Error inserting the new record" when adding row i
 
   NeoOffice Forum Index -> NeoOffice Beta Releases
View previous topic :: View next topic  
Author Message
pluby
The Architect
The Architect


Joined: Jun 16, 2003
Posts: 11949

PostPosted: Sat Apr 02, 2011 9:35 pm    Post subject: Re: Update

Although it is not feasible to backport the OpenOffice.org 3.3 code, a quick Google search did yield some suggestions that might provide a workaround to the problems that you are seeing.

Here is how I changed your SQL in your previous post to make NeoOffice 3.2 Beta handle your case. Note my comments in the SQL below:

Code:
CREATE TABLE test
(
  -- Set key1 to serial type so that Base knows it should only allow
  -- input to key2
  key1 serial NOT NULL,
  key2 integer NOT NULL,
  CONSTRAINT test_pkey PRIMARY KEY (key1, key2)
)
WITH (
  OIDS=FALSE
);

-- No sequence is needed since test.key1 uses the serial type

CREATE OR REPLACE FUNCTION test_it()
  RETURNS trigger AS
$BODY$BEGIN
  -- NEW already has a serial value assigned to it so don't assign
  -- any values in this function. Instead, throw exceptions for bad
  -- values and if all values are good, return NEW
  IF NEW.key2 > 10 THEN
    RAISE EXCEPTION 'Value cannot be greater than 10';
  END IF;
  RETURN NEW;
END$BODY$
  LANGUAGE plpgsql VOLATILE SECURITY DEFINER
  COST 100;

-- No changes needed to test_it trigger
CREATE TRIGGER test_it
  BEFORE INSERT
  ON test
  FOR EACH ROW
  EXECUTE PROCEDURE test_it();


Using the above changes, Base recognizes that test.key1 is an autogenerated field and will not allow input in that column. Then, in the test_it() function, returning NEW tells the trigger that it is OK to insert. Raising an exception for any bad conditions (my test_it() function does not allow key2 to be greater than 10) will cancel the insert and the exception string will be displayed in Base.

Hope that helps.

Patrick
Back to top
kuba
Agent


Joined: Mar 19, 2010
Posts: 12

PostPosted: Mon Apr 04, 2011 6:09 am    Post subject:

Understood. Thanks Patrick for spending time on this! I will use OO.org 3.3 for the database work, then.
Back to top
kuba
Agent


Joined: Mar 19, 2010
Posts: 12

PostPosted: Mon Apr 04, 2011 6:10 am    Post subject:

The previous reply was to your earlier post, not having seen the one above. Your changes to the SQL make sense and allow me to keep using NeoOffice. Thank you very much!!
Back to top
pluby
The Architect
The Architect


Joined: Jun 16, 2003
Posts: 11949

PostPosted: Mon Apr 04, 2011 8:24 am    Post subject:

kuba wrote:
The previous reply was to your earlier post, not having seen the one above. Your changes to the SQL make sense and allow me to keep using NeoOffice. Thank you very much!!


I am glad to hear that using my SQL works. If it works in NeoOffice, it should also work with all versions of OpenOffice.org and LibreOffice with both JDBC 3 and 4 drivers as well.

Patrick[/list]
Back to top
Display posts from previous:   
   NeoOffice Forum Index -> NeoOffice Beta Releases All times are GMT - 7 Hours
Goto page Previous  1, 2
Page 2 of 2

 
You can post new topics in this forum
You can 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
You cannot attach files in this forum
You cannot download files in this forum

Powered by phpBB © 2001, 2005 phpBB Group

All logos and trademarks in this site are property of their respective owner. The comments are property of their posters, all the rest © Planamesa Inc.
NeoOffice is a registered trademark of Planamesa Inc. and may not be used without permission.
PHP-Nuke Copyright © 2005 by Francisco Burzi. This is free software, and you may redistribute it under the GPL. PHP-Nuke comes with absolutely no warranty, for details, see the license.