SQL problem

iqbalmad
Member Posts: 180
Hi guys,
am using the latest version of SQL.
I have written some codes in which i am inserting records in the table Change Log Entry.
On the form i have given insert permissions.
But i get a message like:
1088,"42000", [Licrosoft][ODBC SQL Server Driver][SQL Server] Object XXX.dbo.Cronus$Change Log Entry" cannot be found, as it doesn't exist or u do not have sufficient permissions .
SQL:
SET IDENTITY_INSERT "XXX.dbo.Cronus$Change Log Entry" ON
The same codes work fine in standard nav.
Can you pls help.
am using the latest version of SQL.
I have written some codes in which i am inserting records in the table Change Log Entry.
On the form i have given insert permissions.
But i get a message like:
1088,"42000", [Licrosoft][ODBC SQL Server Driver][SQL Server] Object XXX.dbo.Cronus$Change Log Entry" cannot be found, as it doesn't exist or u do not have sufficient permissions .
SQL:
SET IDENTITY_INSERT "XXX.dbo.Cronus$Change Log Entry" ON
The same codes work fine in standard nav.
Can you pls help.
0
Comments
-
This error occurs if you are giving "Entry No." value other than 0 in your code, since this field has property AutoIncrement set as Yes.
See http://www.mibuso.com/forum/viewtopic.php?f=23&t=18411&hilit=SET+IDENTITY
Also have a look at codeunit 423 "Change Log Management", function InsertLogEntry to see how Navision does this.0 -
What should i change to make these codes work for sql??
IF NOT CONFIRM(Text001,FALSE,"Statement No.") THEN
EXIT
ELSE
BEGIN
IF ChangeLogEntry.FINDLAST THEN
LastEntryNum := ChangeLogEntry."Entry No.";
BankAccLedEntry.SETRANGE("Statement No.","Statement No.");
IF BankAccLedEntry.FINDSET(TRUE,TRUE) THEN
REPEAT
BankAccLedEntry.Open := TRUE;
BankAccLedEntry.MODIFY;
ChangeLogEntry.INIT;
ChangeLogEntry."Entry No." := LastEntryNum + 1;
ChangeLogEntry."Date and Time" := CURRENTDATETIME;
ChangeLogEntry."User ID" := USERID;
ChangeLogEntry.Time:=TIME;
ChangeLogEntry."Table No." := 271;
ChangeLogEntry."Primary Key" := 'N° de séquence:'+ FORMAT(BankAccLedEntry."Entry No.");
ChangeLogEntry."Field No.":= 36;
ChangeLogEntry."Type of Change" := ChangeLogEntry."Type of Change"::Modification;
ChangeLogEntry."Old Value" := 'N° de séquence:'+ FORMAT(BankAccLedEntry."Entry No.") + ' ' + 'False';
ChangeLogEntry."New Value" := 'N° de séquence:'+ FORMAT(BankAccLedEntry."Entry No.") + ' ' + 'True';
ChangeLogEntry.INSERT;
LastEntryNum += 1;
UNTIL BankAccLedEntry.NEXT = 0;
MESSAGE(Text002);
END;0 -
iqbalmad wrote:What should i change to make these codes work for sql??This error occurs if you are giving "Entry No." value other than 0 in your code, since this field has property AutoIncrement set as Yes.
ChangeLogEntry."Entry No." := LastEntryNum + 1;
No support using PM or e-mail - Please use this forum. BC TechDays 2024: 13 & 14 June 2024, Antwerp (Belgium)0 -
i did that Luc. But i was getting another error message that line already exists.0
-
Probably because the Insert-trigger is not executed.
But you better use the existing functions in the ChangeLog codeunit to update that table, instead of inserting the records yourself. Have a look at Change Log for records modified with a codeunit how it's done.No support using PM or e-mail - Please use this forum. BC TechDays 2024: 13 & 14 June 2024, Antwerp (Belgium)0 -
iqbalmad wrote:i did that Luc. But i was getting another error message that line already exists.
.INIT is not clearing primary key. You need to assign 0 to the field (it means not remove the line but change it toChangeLogEntry."Entry No." := 0;
but you already knows that if you have used the search functionality... ;-)0 -
kine wrote:iqbalmad wrote:i did that Luc. But i was getting another error message that line already exists.
.INIT is not clearing primary key. You need to assign 0 to the field (it means not remove the line but change it toChangeLogEntry."Entry No." := 0;
Better use CLEAR(ChangeLogEntry);
It cleans a lot better. (BTW : http://www.mibuso.com/howtoinfo.asp?FileID=22 )Regards,Alain Krikilion
No PM,please use the forum. || May the <SOLVED>-attribute be in your title!0 -
Yes, but sometime it have side-effect of clearing the variables inside the "object"... ;-0
-
kine wrote:Yes, but sometime it have side-effect of clearing the variables inside the "object"... ;-Regards,Alain Krikilion
No PM,please use the forum. || May the <SOLVED>-attribute be in your title!0
Categories
- All Categories
- 73 General
- 73 Announcements
- 66.6K Microsoft Dynamics NAV
- 18.7K NAV Three Tier
- 38.4K NAV/Navision Classic Client
- 3.6K Navision Attain
- 2.4K Navision Financials
- 116 Navision DOS
- 851 Navision e-Commerce
- 1K NAV Tips & Tricks
- 772 NAV Dutch speaking only
- 617 NAV Courses, Exams & Certification
- 2K Microsoft Dynamics-Other
- 1.5K Dynamics AX
- 320 Dynamics CRM
- 111 Dynamics GP
- 10 Dynamics SL
- 1.5K Other
- 990 SQL General
- 383 SQL Performance
- 34 SQL Tips & Tricks
- 35 Design Patterns (General & Best Practices)
- 1 Architectural Patterns
- 10 Design Patterns
- 5 Implementation Patterns
- 53 3rd Party Products, Services & Events
- 1.6K General
- 1.1K General Chat
- 1.6K Website
- 83 Testing
- 1.2K Download section
- 23 How Tos section
- 252 Feedback
- 12 NAV TechDays 2013 Sessions
- 13 NAV TechDays 2012 Sessions