hello everyone i ve read the topic RENAMEing a bunch of records (solved!!!) i had the same problem i have to modify or rename a field which is in the primary key of the table the problem is : unlike the TOPIC RENAME… i don’t have only 3 fields in my table the field that i want to rename is after after lots of field in the table definition (it’s the 12th field in the table) so my problem is that when using rename i have to write all the field of the table before my specific field and there’s too much i also try modify & modifyall but it gives me error “Problem with the field and the primary key…” If anyone got an idea (or have questions for more info …) thanks a lot
Can you please post the primary key of the table and the name of the field which you wish to change? That should help us get an idea of what is going on.
In order to rename a record, you first have to retrieve it, either by doing a GET or a FIND. Whichever method you use, you already have all the field values of that record. So theoretically, all you need to do is change the 12th field value and do RENAME. MODIFY and MODIFYALL will not work if you try to change a field that is part of the primary key of the table, the DBMS will just not allow you to do that.
Hi, This could be an option if you want to rename too many records in different tables. 1. Add a dummy integer field in the respective table. 2. Run a small report to assign consecutive numbers in the new field. 3. Change the primary key to be the new Integer field. 4. modify your actual prmiary key value fields accordingly since now you are saving on the new primary key. 5. change the Prmiary key back to your old key description. anyway this was an immediate thought while going through the topic, still other forum members would have alternatives. Cheers Sreekanth
first thanks for all response (so quick ;-)) i m going to try it Other Informations : i use navision 2.6 (french version) i have a table for the article price (Prix Article) because some of our clients (eg Big distributor ) have special price so there’s a table which store the article number, the reseller code and other fields. Among them my problematic field : unity code (code unité) this field is retrieve from the table Unity (store the packaging of a product : PIECE P3 P10 P20 …) TABLE unity → 2 fields : a code & a designation so the table Prix Article Field No. Field Name 1 N° article 2 Code tarif 3 Code devise 4 Date début 5 Prix unitaire 7 Prix TTC 8 Remise quantité autorisée 9 Remise clients/art. autorisée 10 Remise facture autorisée 11 Gpe compta. marché TVA (prix) 5400 Code unité the field i want to rename 70000 Réf. article client 70001 Date fin 70002 Désignation 70003 Code marque 70004 Code famille 70005 Code sous-famille 70006 Conditionnement spécial The primary key is composed of N° Article, Code Tarif, Code Unité, Date debut, Date Fin thanks
The field’s position in the table doesn’t really matter. The important part is the field’s position in the primary key. If, for example, you need to rename all Prix Article records where Code unité is P3 so that Code unité will become P10 in all of these records, you can use the following code:
PrixArticle.RESET; PrixArticle.SETRANGE("Code unité",'P3'); IF PrixArticle.FIND('-') THEN REPEAT PrixArticle2 := PrixArticle; PrixArticle2.RENAME( PrixArticle."Nº Article", PrixArticle."Code Tarif", 'P10', PrixArticle."Date debut", PrixArticle."Date fin"); UNTIL PrixArticle.NEXT = 0;
it’s ok thank you so much nelson it’s exactly what i want thanks