web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics AX (Archived)

ODBC statement: Cannot insert the value NULL into column 'RECID'

(0) ShareShare
ReportReport
Posted on by 505

Hi All,

I am creating ODBC connection and want to insert record in table from one DB to another.

I am using following job for this.

 Statement                       statement;
    str                             query, criteria;
    LoginProperty                   loginProperty;
    OdbcConnection                  odbcConnection;
    
    loginProperty = new LoginProperty();
    loginProperty.setDSN('AX_ETL');
    
    odbcConnection = new OdbcConnection(loginProperty);
    
    statement = odbcConnection.createStatement();
    
    query = "INSERT into Target.dbo.Test (EXECUTIONID) select  ExecutionId from Source.Budget where TransactionCurrencyAmount = 300";//
    
    new SqlStatementExecutePermission(query).assert();  
    
    statement.executeUpdate(query);
    
    CodeAccessPermission::revertAssert();

Above query will return more than one record.

where Target database is AX database and Source database is another DB in same SQL Server.

When I run this job I am getting error

*This post is locked for comments

I have the same question (0)
  • Ishu.caddengg@hotmail.com Profile Picture
    505 on at

    Error screen shot

    8510.Error.png

    If single record is also inserted in Ax table, the Job gave same error.

    For now there is no primary index in the table. As far I understand this RECID should automatically generated by AX itself. Please correct me if I am wrong.

    Thanks in Advance

  • Sohaib Cheema Profile Picture
    49,438 User Group Leader on at

    each AX table need a recid to save as mandatory. your ODBC SQL query is trying to insert record without a recid. Destination(SQ Server) is complaining about this.

    although there are ways to consume recid(s) by getting next recid and sending that as part of your insert BUT what is the reason to bypass AX framework? what business needs has forced you avoid X++ and use direct SQL

  • Martin Dráb Profile Picture
    237,844 Most Valuable Professional on at

    Your design is horribly wrong. Please don't try again to bypass AX business logic when creating records.

    The recommended way for integration is the Application Integration Framework (document exchange, web services) and you may use other techniques as well, such as DIXF or Master Data Management. All of them go through AOS, therefore they can handle Record IDs, respect security, don't corrupt cache and so on...

  • Suggested answer
    Ishu.caddengg@hotmail.com Profile Picture
    505 on at

    Thanks for the reply martin.

    I managed the same thing by selecting the record from source table with sql query and then inserting the resultset from AX only.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics AX (Archived)

#1
Priya_K Profile Picture

Priya_K 4

#1
Martin Dráb Profile Picture

Martin Dráb 4 Most Valuable Professional

#3
Ali Zaidi Profile Picture

Ali Zaidi 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans