Menu

#57 Problem doing inserts with autoinc field

open
nobody
SQL (11)
7
2013-01-13
2003-01-23
Anonymous
No

Exported from Bugzilla, issue 4189.

--- Comment added on 12/16/02 11:00:17 AM ---
John Jacobson

I have an interesting problem that I don't see documented in the fixes list
for FF2.12.

I have a parameterized query I use for an insert to a table with an autoinc
primary key. If I don't prepare the query every time, I get a key violation on
the second and all subsequent inserts. Is there a known workaround for this?

The situation is very simple. The code segment below works fine (though slowed
by the need to prepare the query every time), but if I comment out the line
that unprepares the query I get a key violation on every iteration but the
very first.

Here is the code segment:

with qryInsertXOVER do begin
Check;
if not Prepared then begin
sSQL := 'INSERT INTO MESSAGE_( MSGID, MSGID_CRC, PARENTMSGID,
PARENTMSGID_CRC, SUBJECT, SIZE_, DATE_, ARTICLEINDEX, FROM_TEXT,
FROM_TEXT_CRC) ' +
' VALUES( :MSGID, :MSGID_CRC, :PARENTMSGID, :PARENTMSGID_CRC, :SUBJECT,
:SIZE_, :DATE_, :ARTICLEINDEX, :FROM_TEXT, :FROM_TEXT_CRC )';
SQL.Clear;
SQL.Add( sSQL );
Prepare;
end;
Params[ 0 ].AsString := XOVERHeader.GetMsgId;
Params[ 1 ].AsInteger := MCRC;
Params[ 2 ].AsString := ParentMsgId;
Params[ 3 ].AsInteger := PCRC;
Params[ 4 ].AsString := trim(XOVERHeader.GetSubject);
Params[ 5 ].AsInteger := XOvERHeader.GetSize;
Params[ 6 ].AsDateTime := XOVERHEader.GetPostDate;
Params[ 7 ].AsInteger := XOVERHeader.GetArticleIndex;
Params[ 8 ].AsString := trim(XOVERHeader.GetSender);
Params[ 9 ].AsInteger := SCRC;
ExecSQL;
Unprepare; //This unprepare is a temporary workaround. There seems to be a
bug in FF2.12 regarding inserts not updating the autoinc primary key
end; // with

Discussion


Log in to post a comment.

MongoDB Logo MongoDB