Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

reading the just generated identity throws an exception [ODBC208] #191

Open
firebird-automations opened this issue May 4, 2018 · 0 comments

Comments

@firebird-automations
Copy link

Submitted by: Michael von Boetticher (michael)

With MS-Access I used the identity column as primary key for table joining.
Firebird gives the possibility to create a similar table with:

CREATE TABLE TestTable (ID INTEGER GENERATED BY DEFAULT AS IDENTITY PRIMARY KEY, Name VARCHAR(50));

The whole app is written with ADO, so I'd like to use the firebird ODBC. But here occurs the following problem:
reading the just generated identity throws an exception, I didn't have with MS-Access.

            ADODB::\_RecordsetPtr prs = NULL;
            CREATEINSTANCE\(prs, ADODB::Recordset\);
            prs\-\>CursorLocation = ADODB::adUseClient;
            prs\-\>Properties\-\>Item\["Update Resync"\]\-\>Value = \(long\)ADODB::adResyncAll;
            prs\-\>Open\(\_bstr\_t\("SELECT \* FROM TestTable WHERE 1=0"\), \(IDispatch \*\)m\_pConnection, ADODB::adOpenKeyset, ADODB::adLockOptimistic, ADODB::adCmdText\);

            prs\-\>AddNew\(\);
            prs\-\>Fields\-\>Item\["Name"\]\-\>Value = "Some Text";
            prs\-\>Update\(\);

            long id = \(long\)prs\-\>Fields\-\>Item\["ID"\]\-\>Value;              // throws an DB\_E\_DELETEDROW

            prs\-\>Close\(\);
            prs = NULL;

I need to know the generated ID for further actions in other subtables.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants