I have a CubeSQL database and am trying to INSERT a new record (see below) using SQLDatabaseMBS, but I want to return the new record ID so I am appending ‘RETURNING id’.
INSERT INTO Lockers (ApplicationName, CloudStorageID, Created, DatabaseFieldID, DatabaseFieldName, DatabaseName, DatabaseTable, ExpiryDate, isActive, isArchived, isDeleted, isFile, isFolder, isImmovable, isImmutable, isMarkedForDeletion, isNotifyOwner, isOnCloud, isOnLocalDrive, isOut, isPublic, isString, isTemplate, isURL, Keywords, LastOutDate, LastOutIPAddress, LastOutUserID, LockerURL, Modified, Notes, ObfuscatedPathParent, Status, UserID, VersionsToKeep, Name, NativePathParent, ObfuscatedFilename, ZipPassword) VALUES (:ApplicationName, :CloudStorageID, :Created, :DatabaseFieldID, :DatabaseFieldName, :DatabaseName, :DatabaseTable, :ExpiryDate, :isActive, :isArchived, :isDeleted, :isFile, :isFolder, :isImmovable, :isImmutable, :isMarkedForDeletion, :isNotifyOwner, :isOnCloud, :isOnLocalDrive, :isOut, :isPublic, :isString, :isTemplate, :isURL, :Keywords, :LastOutDate, :LastOutIPAddress, :LastOutUserID, :LockerURL, :Modified, :Notes, :ObfuscatedPathParent, :Status, :UserID, :VersionsToKeep, :Name, :NativePathParent, :ObfuscatedFilename, :ZipPassword) RETURNING id;
When I leave off the ‘RETURNING id’ the record inserts properly (no exception, but I get no ID). When I include the ‘RETURNING id’ it gives me an SQLErrorExceptionMBS of ‘another row available’.
It fails on the line (SelectSQL gives the same exception.):
rs = tempSQLPreparedStatementMBS.SelectSQLMT
Yet if I do a manual SQL INSERT command, it works eg
INSERT INTO Lockers (ApplicationName) VALUES ('myApp Name') RETURNING id;
I’m the only user on the database. What is the cause or solution? I can’t find any solutions on the Forum or in web searches. Is it likely to be an MBS issue?