Changing the field TYPE in SL
Posted 29 June 2006 - 07:03 AM
Can you please help me in solving an issue. I created a file in SL and by mistake created a field it with a wrong datatype . Now that i want to change the datatype of that particular field from alphanumeric to numeric. I cannot change the data dictiontionary as i do not have the priviliedges. How do i go abt solving this problem ...
Thanks in advance..
Posted 29 June 2006 - 07:45 AM
you have not specified if you are using pro-isam, ORACLE, etc.,
this soultion should work regardless of the data files that you are using.
Will refer to your file as FILE-A
Make a copy of the file definition FILE-A and remove the offending field, creating file definition FILE-B.
FILE-B should now be same as your original file definition before your latest changes, the addition of the incorrect data-type field.
On your FILE-A with the mis-type field, do you wish to retain the value that is currently in the incorrect field?
If so add a field (different name) to FILE-B with the correct data-type.
Create a physical file for FILE-B.
Write a function that reads FILE-A (containing the incorrect field and data-type) and writes FILE-B.
(If retaining the value in the incorrect field you can then convert the field from FILE-A to correct type on FILE-B, numeric-field = conv(alpha-field).)
At this point you should have the contents of FILE-A now present in FILE-B.
Now fix file definition FILE-A, create FILE-A.
Write a function that reads FILE-B and writes FILE-A.
Maybe there are simpler ways, it depends on the DB that you are using.
Check with your DBA the solution above.
Posted 29 June 2006 - 10:37 AM
But i was looking for a different Solution. I have a FILE-A , which has a field "XYYYYZ" , whose data type needs to be changed from ALphanumeric to Numeric . I tried deleting the file and creating it again , but then i encountered a problem , i had to create the file with the same name FILE-A , and so the types , display code , checks were all picked up from the data dictionary.
Now i tried changing the data dictionary as well, to delete the fileds. But then , i do not have the priviledges .
There is no data in the field .
It is a PRO ISM file.
Can you help
Posted 29 June 2006 - 12:53 PM
Once you add a field to a file-def it is put in the Glolal Dictionary - this can be maintained using function @FVAR - if you dont have access to this then someone else in your DEV team should - The Global Dictionay values are stored in the fvardef.pro file.
Posted 03 July 2006 - 07:10 AM
Although i can access @FVAR , and I am able to delete fields from there , i am still unable t change the existing field. For Example i have a field 'XXXXXXXX' which has data type 'A' , and i want to change it to 'N' .
I deleted the field from the table , i even deleted it from @FVAR, but then when i try to add that again with other data type it says , it already exists in the data dictionary .I tried deleting the field from the data dictionary but then it says "VARIABLE USED IN CONTROLLED FILES" , so what do i do now .. is there any way i can change the data type of a field without changing the field itself...
Posted 03 July 2006 - 08:51 AM
1) I have no recollection of seeing this latest problem you are having.
What is the name of the variable that you are trying to change.
I assuem the variable that you added was a new unique field to the Global Dictionary otherwise you should not be changing the type (any attributes) if its an existing field.
2) you started off by adding a field and gave it a wrong type and now you cannot change the type, problem above, perhaps stop chasing this line of problem.
Remove the offending field from the file definition and add the field again, but, using a different variable name with the correct attributes. Before adding this new variable check first that the variable does not already exist in the Global Dictionary. This should achieve your initial goal of creating a file and adding fields etc.,
Reply to this topic
0 user(s) are reading this topic
0 members, 0 guests, 0 anonymous users