ASCII CHECK - change value in primary key
 
            
                
                    boompump                
                
                    Member Posts: 3                
            
                        
            
                    Hi,
I've some trouble in checking ASCII with 10 or 13 in database.
When I find out there are data with ASCII 13 or 10, i will detele it then replace back to original data.
it seems work in regular fields except primary key fields.
My thought was delete the field value before I insert new value into it.
I can't use RENAME, it will occur another modify problem.
Then here's the problem that I met, not sure if my code are correct or not, need your help.When the Fields are Key Column, I will DELETE it first then INSERT the new value to Field
but it shows me a massage like (I've searched the table 'Item') : The Item does not exist,
Identification fields and values: No.='A-I000001'
But If I didn't delete it first , it will show me : the Item already exists.
What should I do to change the primary key value?
Really need your help.
                I've some trouble in checking ASCII with 10 or 13 in database.
When I find out there are data with ASCII 13 or 10, i will detele it then replace back to original data.
it seems work in regular fields except primary key fields.
My thought was delete the field value before I insert new value into it.
I can't use RENAME, it will occur another modify problem.
Then here's the problem that I met, not sure if my code are correct or not, need your help.When the Fields are Key Column, I will DELETE it first then INSERT the new value to Field
but it shows me a massage like (I've searched the table 'Item') : The Item does not exist,
Identification fields and values: No.='A-I000001'
But If I didn't delete it first , it will show me : the Item already exists.
What should I do to change the primary key value?
Really need your help.
Windows.OPEN(Text000+
             Text001+
             Text002);
IF g_intTableNo >0 THEN
  g_recField.SETRANGE(TableNo,g_intTableNo);
IF g_recField.FIND('-') THEN
  IF g_recField.Enabled = TRUE THEN
  REPEAT
    CLEAR(g_rrfRecordRef);
    CLEAR(g_krfKeyRecordRef);
    g_rrfRecordRef.OPEN(g_recField.TableNo);
    g_krfKeyRecordRef.OPEN(g_recField.TableNo);
    Windows.UPDATE(1,g_recField.TableName);  //
    g_krfKeyRef := g_rrfRecordRef.KEYINDEX(1);
    g_intKeyCount := g_krfKeyRef.FIELDCOUNT;
    FOR i:= 1 TO g_intKeyCount DO BEGIN
      g_frfFieldIndex[i] := g_krfKeyRef.FIELDINDEX(i);
    END;
    IF g_rrfRecordRef.FIND('-') THEN BEGIN
      g_frfFieldRef := g_rrfRecordRef.FIELD(g_recField."No.");
      Windows.UPDATE(2,g_recField.FieldName);                     //
      IF (g_recField.Type = g_recField.Type::Code) OR
         (g_recField.Type = g_recField.Type::Text) THEN
        REPEAT
          CLEAR(l_txtNewValue);
          CLEAR(l_txtOldValue);
          CLEAR(l_txtKeyValue);
          CLEAR(l_booKeyColumn);
          l_txtOldValue := g_frfFieldRef.VALUE;
          Windows.UPDATE(3,l_txtOldValue); //
          FOR i:= 1 TO STRLEN(l_txtOldValue) DO BEGIN
            cSTR := l_txtOldValue[i];
            IF (cSTR <> 13) AND (cSTR <> 10) THEN
              l_txtNewValue += FORMAT(l_txtOldValue[i]);
          END;
          g_txtNewValue := l_txtNewValue;
          FOR i:= 1 TO g_intKeyCount DO BEGIN
            IF g_frfFieldRef.NAME = g_frfFieldIndex[i].NAME THEN BEGIN
              l_intKeyIndex := i;
              l_booKeyColumn := TRUE;
              g_frfFieldIndex[i].VALUE := l_txtNewValue
            END;
            IF l_booKeyColumn THEN BEGIN
              //f_booRenameKeyField(g_intKeyCount);
              f_inserKeyField(g_intKeyCount);
            END ELSE BEGIN
              g_frfFieldRef.VALUE := l_txtNewValue;
                //IF NOT g_rrfRecordRef.MODIFY THEN
               // ERROR('Modify failure Column: %1 Value: %2',g_frfFieldRef.NAME,l_txtNewValue);
            END;
           END;
        UNTIL g_rrfRecordRef.NEXT = 0;
      g_rrfRecordRef.CLOSE;
    END;
  UNTIL g_recField.NEXT = 0;
MESSAGE('Finished!');
Windows.CLOSE;
---------------------------------------------------
[Function:f_booRenameKeyField(p_intKeyCount : Integer)]
CASE p_intKeyCount OF
  1: 
   BEGIN
      g_rrfRecordRef.DELETE;
      g_frfFieldRef.VALUE := g_frfFieldIndex[1].VALUE;
      g_rrfRecordRef.INSERT;
   END;
END;
                0                
            Comments
- 
            You might try this:
 http://www.mibuso.com/dlinfo.asp?FileID=1149
 It's "Remove TAB CR and LF from Text Fields" option will do what you want.
 If the item without the CRLF already exists in the database it'll fail to rename the item, but that's okay because all the postings attached to the item will be renamed. So you can delete it.Robert de Bath
 TVision Technology Ltd0
- 
            rdebath wrote:You might try this:
 http://www.mibuso.com/dlinfo.asp?FileID=1149
 It's "Remove TAB CR and LF from Text Fields" option will do what you want.
 If the item without the CRLF already exists in the database it'll fail to rename the item, but that's okay because all the postings attached to the item will be renamed. So you can delete it.
 OOHHH~~thank you so very much.
 its really help me a lot.
 i'm will go research the code.
 really a big help
 Thank you.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
- 323 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
