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)

Invalid precision value error

(0) ShareShare
ReportReport
Posted on by

I'm getting a native SQL error when trying to insert into a custom table called "MyTable". The custom table contains the following fields:

RecId parentRecId;
Guid entryKey;
MyEntryType entryType; // custom enum
Str500 summary;
Str4000 detail;

Other than the above my custom table has "CreatedDateType" system field turned on.

I got the table synchronized + the the entire DataDictionary AOT node synchronized.

I'm using a job with the following code to insert one record in to the table:

MyTable table;
table.initValue();
table.parentRecId = 5637144583;
table.entryKey = str2guid("{FFB111CB-AF74-4857-8E97-B45440E48336}");
table.entryType = MyEntryType::Type1;
table.summary = "this is a short summary";
table.validateWrite();
table.insert(); // this is where the error strikes

The error I get is this:

SQL error description: [Microsoft][SQL Server Native Client 11.0]Invalid precision value

Any idea what else could be wrong?

*This post is locked for comments

I have the same question (0)
  • Martin Dráb Profile Picture
    237,807 Most Valuable Professional on at

    Does it depend on some particular field? Play with it a little bit, it might reveal something useful.

    It's off-topic and I understand it's a just sample code, nevertheless calling validateWrite() and ignoring its return value is an anti-pattern. If it returns false, either skip insert() or throw an exception.

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

    Just a wild guess, but can't Str4000 be the culprit? What if you use a shorter string?

  • psined Profile Picture
    on at

    Yes, the "detail" column appears to be the culprit. It was actually created in the table via drag-dropping a custom string EDT with length 4000 onto the table.. I can certainly try a narrower field, but in my case the detail may exceed that length, so I need a larger buffer. Sounds like AX only gives choice for either 1000 chars max or Memo type on a field. How would one go about adding an EDT for a Memo datatype? Is it at all possible?

  • Verified answer
    Martin Dráb Profile Picture
    237,807 Most Valuable Professional on at

    Actually, there is a suspiciously close limit in SQL Server: nvarchar [ ( n | max ) ] - Variable-length Unicode string data. n defines the string length and can be a value from 1 through 4,000.

    Yes, you can create your own memo EDTs. Create a string EDT and set StringSize = Memo from the drop-down (if I remember it correctly). Or just use or copy and existing type, such as Notes.

  • psined Profile Picture
    on at

    Hi Martin, thanks for your help. Setting the custom EDT length from 4000 to "Memo" has fixed the problem.

    Surprisingly, while adding a string column to a table with length above 1000 chars results in an "Illegal property value" error, AX is perfectly happy when I define a string EDT with 4000 and then drag-drop it on to a table - during synchronization AX even creates a proper NVARCHAR(4000) data type in SQL.

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
Martin Dráb Profile Picture

Martin Dráb 4 Most Valuable Professional

#1
Priya_K Profile Picture

Priya_K 4

#3
MyDynamicsNAV Profile Picture

MyDynamicsNAV 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans