Subject | Re: [IBO] Post on required fields |
---|---|
Author | Fernando Azevedo |
Post date | 2007-04-17T11:27:46Z |
Problem solved, I was calling a query.Refresh in a procedure
directly after the query.Post statement. Using a query.Open instead
eliminated the error.
Thank you!
Fernando Azevedo
Helen Borrie escreveu:
directly after the query.Post statement. Using a query.Open instead
eliminated the error.
Thank you!
Fernando Azevedo
Helen Borrie escreveu:
>
> At 05:51 AM 18/04/2007, you wrote:
> > I have two questions:
> > I'm working with three tables: Book, Author and Book_Author. When
> >inserting a new book, I open the Author table and select the ones I want
> >do associate with the book, and that will be put in the Book_Author
> >table. To do that, I use this :
> >
> > qryBook_Author.Insert;
> > qryBook_Author.FieldByName('BOOK_ID').AsInteger :=
> >qryBook.FieldByName('BOOK_ID').AsInteger;
> > qryBook_Author.FieldByName('AUTHOR_ID').AsInteger :=
> >qryAuthor.FieldByName('AUTHOR_ID').AsInteger;
> > qryBook_Author.Post;
> >
> > If I use this without entering all the not null fields, I get an
> >error informing that the required fields cannot be null. Of course they
> >can't, by I'm just using a Post, not a Commit !
>
> Post writes the new record to the database. If the underlying INSERT
> statement includes non-nullable fields that contain no values then
> the Post will fail and you get an exception.
>
> >Is it necessary that all the not null fields of the master table to
> >be filled before I use a Post command ?
>
> Yes.
>
> > Nevertheless, if I fill the required fields, and try to use the code
> >above, I get the error: "Problem in binding cursor". What's this about ?
>
> It is about a reference to a record in an unavailable set. It may
> have to do with attempting to masterlink a record to a set that has
> been closed or is awaiting some action to resolve a prior
> exception. Can't be more explicit without more information but,
> before calling Insert on the Book_Author dataset, test to make sure
> it is open.
>
> If you are writing this intersection record "invisibly" then use the
> BeforeInsert handler of the Book_Author dataset to apply the
> non-nullable values. If the key value of this set is a generator
> then use GeneratorLinks for that value.
>
> Helen
>
>
> ------------------------------------------------------------------------
>
> No virus found in this incoming message.
> Checked by AVG Free Edition.
> Version: 7.5.446 / Virus Database: 269.4.0/762 - Release Date: 15/4/2007 16:22
>