|
View:
New views
14 Messages
—
Rating Filter:
Alert me
|
|
|
Change field type with method in v11In v11.4, is there a way to change the type of a field programatically, e.g.
Alpha to Text. (Actually a lot of fields, otherwise I would use the structure editor.) I was thinking of using BEGIN SQL...ALTER TABLE...END SQL, but as far as I can tell you can add or delete a field that way but not modify it. Thanks, David ********************************************************************** Get the speed and power of 4D v11 SQL before upgrade prices increase - http://www.4d.com 4D Internet Users Group (4D iNUG) FAQ: http://lists.4d.com/faqnug.html Archive: http://lists.4D.com/archives.html Options: https://lists.4d.com/mailman/options/4d_tech Unsub: mailto:4D_Tech-Unsubscribe@... ********************************************************************** |
|
|
RE: Change field type with method in v11Hi David, You can DROP TABLE to. I believe that could do the trick. Good luck. Garri > From: david_lieb@... > Date: Fri, 6 Nov 2009 07:41:37 -0500 > To: 4d_tech@... > CC: > Subject: Change field type with method in v11 > > In v11.4, is there a way to change the type of a field programatically, e.g. > Alpha to Text. (Actually a lot of fields, otherwise I would use the > structure editor.) > > I was thinking of using BEGIN SQL...ALTER TABLE...END SQL, but as far as I > can tell you can add or delete a field that way but not modify it. > > Thanks, > > David > ********************************************************************** > Get the speed and power of 4D v11 SQL > before upgrade prices increase - http://www.4d.com > > > 4D Internet Users Group (4D iNUG) > FAQ: http://lists.4d.com/faqnug.html > Archive: http://lists.4D.com/archives.html > Options: https://lists.4d.com/mailman/options/4d_tech > Unsub: mailto:4D_Tech-Unsubscribe@... > ********************************************************************** _________________________________________________________________ Windows 7: Unclutter your desktop. http://go.microsoft.com/?linkid=9690331&ocid=PID24727::T:WLMTAGL:ON:WL:en-US:WWL_WIN_evergreen:112009********************************************************************** Get the speed and power of 4D v11 SQL before upgrade prices increase - http://www.4d.com 4D Internet Users Group (4D iNUG) FAQ: http://lists.4d.com/faqnug.html Archive: http://lists.4D.com/archives.html Options: https://lists.4d.com/mailman/options/4d_tech Unsub: mailto:4D_Tech-Unsubscribe@... ********************************************************************** |
|
|
|
|
|
Re: Change field type with method in v11Hi David,
You can try to export the structure to a XML file. Alpha fields and Text fields are from type 10. You need to delete only the length of the alpha field and it become a text field. Then create a new structure from the xml source. On Nov 6, 2009, at 4:41 AM, David Lieb wrote: > In v11.4, is there a way to change the type of a field > programatically, e.g. > Alpha to Text. (Actually a lot of fields, otherwise I would use the > structure editor.) > > I was thinking of using BEGIN SQL...ALTER TABLE...END SQL, but as > far as I > can tell you can add or delete a field that way but not modify it. > Atanas Atanassov Technical Support Team Member 4D, Inc. ----------------------------------------------------------------- Upgrade to 4D v11 SQL before 4D 2004 license and upgrade prices increase - http://www.4d.com ----------------------------------------------------------------- ********************************************************************** Get the speed and power of 4D v11 SQL before upgrade prices increase - http://www.4d.com 4D Internet Users Group (4D iNUG) FAQ: http://lists.4d.com/faqnug.html Archive: http://lists.4D.com/archives.html Options: https://lists.4d.com/mailman/options/4d_tech Unsub: mailto:4D_Tech-Unsubscribe@... ********************************************************************** |
|
|
|
|
|
|
|
|
RE: Change field type with method in v11Hi David, It sounded like you needed to export the data, drop the table, recreate the table with whatever field types you want now and then import. That was just an idea since Alter table wouldn't work for you. I'm doing something like this for my v11 application. Changing all the field types from Alpha to text and all my variable declarations from string to text. Well good luck with whichever way you decide to go. Garri > From: david_lieb@... > Date: Fri, 6 Nov 2009 12:17:04 -0500 > To: 4d_tech@... > CC: > Subject: RE: Change field type with method in v11 > > Hi Garri, > > I don't follow? How would DROP TABLE help to change the type of a field? > > I should also add that I don't want to lose the field data, otherwise I > would could delete a field and add one with a different type. > > Thanks, > > David > > On Fri, Nov 6, 2009 at 11:46 AM, Garri Ogata wrote: > > > Hi David, > > You can DROP TABLE to. I believe that could do the trick. > > Good luck. > > Garri > > > > > From: david_lieb@... > > > Date: Fri, 6 Nov 2009 07:41:37 -0500 > > > To: 4d_tech@... > > > CC: > > > Subject: Change field type with method in v11 > > > > > > In v11.4, is there a way to change the type of a field programatically, > > e.g. > > > Alpha to Text. (Actually a lot of fields, otherwise I would use the > > > structure editor.) > > > > > > I was thinking of using BEGIN SQL...ALTER TABLE...END SQL, but as far as > > I > > > can tell you can add or delete a field that way but not modify it. > > > ********************************************************************** > Get the speed and power of 4D v11 SQL > before upgrade prices increase - http://www.4d.com > > > 4D Internet Users Group (4D iNUG) > FAQ: http://lists.4d.com/faqnug.html > Archive: http://lists.4D.com/archives.html > Options: https://lists.4d.com/mailman/options/4d_tech > Unsub: mailto:4D_Tech-Unsubscribe@... > ********************************************************************** _________________________________________________________________ Bing brings you maps, menus, and reviews organized in one place. http://www.bing.com/search?q=restaurants&form=MFESRP&publ=WLHMTAG&crea=TEXT_MFESRP_Local_MapsMenu_Resturants_1x1********************************************************************** Get the speed and power of 4D v11 SQL before upgrade prices increase - http://www.4d.com 4D Internet Users Group (4D iNUG) FAQ: http://lists.4d.com/faqnug.html Archive: http://lists.4D.com/archives.html Options: https://lists.4d.com/mailman/options/4d_tech Unsub: mailto:4D_Tech-Unsubscribe@... ********************************************************************** |
|
|
|
|
|
|
|
|
|
|
|
Re: Change field type with method in v11Hi Tim,
Thanks for the idea and the code! A couple thoughts: 1. Other than changing Alpha to Text or vice-versa, after dropping and adding the field, it might be good to use Josh Fletcher's suggestion to copy the data, in this case from the field to itself. 2. I'll probably extract the 4D to SQL field type part into a separate method that might be useful in other contexts. Thanks again! David On Sat, Nov 7, 2009 at 3:00 AM, Tim Nevels wrote: > On Nov 6, 2009, at 10:46 AM, David Lieb wrote: > > > In v11.4, is there a way to change the type of a field > > programatically, e.g. > > Alpha to Text. (Actually a lot of fields, otherwise I would use the > > structure editor.) > > > > I was thinking of using BEGIN SQL...ALTER TABLE...END SQL, but as > > far as I > > can tell you can add or delete a field that way but not modify it. > > Hi David, > > I think that is exactly the way to do it -- with ALTER TABLE. I did a > little testing and found a very interesting behavior with 4D v11. > > 4D v11 allows us to delete a field -- ALTER TABLE DROP. And we can > also add a field -- ALTER TABLE ADD. And when adding a field, 4D v11 > will reuse any previously deleted fields. So if you DROP a field and > then immediately ADD a field, the resulting field will have the same > field number as the deleted field. So you have in effect changed the > field type. Remember that you lose all field properties likes choice > lists and other checkboxes in the field properties window. You can > reset some of the properties with SQL commands, but not all of them. > So be aware of this limitation. > > Here is a ChangeFieldType method I wrote that was inspired by your > post. You sometimes need to close and then reopen the structure > window to see the field type change if you run the method from the > Design environment. I did not test this with indexed fields -- so I do > not know if there is any issues with indexes. > Get the speed and power of 4D v11 SQL before upgrade prices increase - http://www.4d.com 4D Internet Users Group (4D iNUG) FAQ: http://lists.4d.com/faqnug.html Archive: http://lists.4D.com/archives.html Options: https://lists.4d.com/mailman/options/4d_tech Unsub: mailto:4D_Tech-Unsubscribe@... ********************************************************************** |
|
|
|
|
|
|
|
|
|
| Free embeddable forum powered by Nabble | Forum Help |