Alpha Software Mobile Development Tools:   Alpha Anywhere    |   Alpha TransForm subscribe to our YouTube Channel  Follow Us on LinkedIn  Follow Us on Twitter  Follow Us on Facebook

Announcement

Collapse

The Alpha Software Forum Participation Guidelines

The Alpha Software Forum is a free forum created for Alpha Software Developer Community to ask for help, exchange ideas, and share solutions. Alpha Software strives to create an environment where all members of the community can feel safe to participate. In order to ensure the Alpha Software Forum is a place where all feel welcome, forum participants are expected to behave as follows:
  • Be professional in your conduct
  • Be kind to others
  • Be constructive when giving feedback
  • Be open to new ideas and suggestions
  • Stay on topic


Be sure all comments and threads you post are respectful. Posts that contain any of the following content will be considered a violation of your agreement as a member of the Alpha Software Forum Community and will be moderated:
  • Spam.
  • Vulgar language.
  • Quotes from private conversations without permission, including pricing and other sales related discussions.
  • Personal attacks, insults, or subtle put-downs.
  • Harassment, bullying, threatening, mocking, shaming, or deriding anyone.
  • Sexist, racist, homophobic, transphobic, ableist, or otherwise discriminatory jokes and language.
  • Sexually explicit or violent material, links, or language.
  • Pirated, hacked, or copyright-infringing material.
  • Encouraging of others to engage in the above behaviors.


If a thread or post is found to contain any of the content outlined above, a moderator may choose to take one of the following actions:
  • Remove the Post or Thread - the content is removed from the forum.
  • Place the User in Moderation - all posts and new threads must be approved by a moderator before they are posted.
  • Temporarily Ban the User - user is banned from forum for a period of time.
  • Permanently Ban the User - user is permanently banned from the forum.


Moderators may also rename posts and threads if they are too generic or do not property reflect the content.

Moderators may move threads if they have been posted in the incorrect forum.

Threads/Posts questioning specific moderator decisions or actions (such as "why was a user banned?") are not allowed and will be removed.

The owners of Alpha Software Corporation (Forum Owner) reserve the right to remove, edit, move, or close any thread for any reason; or ban any forum member without notice, reason, or explanation.

Community members are encouraged to click the "Report Post" icon in the lower left of a given post if they feel the post is in violation of the rules. This will alert the Moderators to take a look.

Alpha Software Corporation may amend the guidelines from time to time and may also vary the procedures it sets out where appropriate in a particular case. Your agreement to comply with the guidelines will be deemed agreement to any changes to it.



Bonus TIPS for Successful Posting

Try a Search First
It is highly recommended that a Search be done on your topic before posting, as many questions have been answered in prior posts. As with any search engine, the shorter the search term, the more "hits" will be returned, but the more specific the search term is, the greater the relevance of those "hits". Searching for "table" might well return every message on the board while "tablesum" would greatly restrict the number of messages returned.

When you do post
First, make sure you are posting your question in the correct forum. For example, if you post an issue regarding Desktop applications on the Mobile & Browser Applications board , not only will your question not be seen by the appropriate audience, it may also be removed or relocated.

The more detail you provide about your problem or question, the more likely someone is to understand your request and be able to help. A sample database with a minimum of records (and its support files, zipped together) will make it much easier to diagnose issues with your application. Screen shots of error messages are especially helpful.

When explaining how to reproduce your problem, please be as detailed as possible. Describe every step, click-by-click and keypress-by-keypress. Otherwise when others try to duplicate your problem, they may do something slightly different and end up with different results.

A note about attachments
You may only attach one file to each message. Attachment file size is limited to 2MB. If you need to include several files, you may do so by zipping them into a single archive.

If you forgot to attach your files to your post, please do NOT create a new thread. Instead, reply to your original message and attach the file there.

When attaching screen shots, it is best to attach an image file (.BMP, .JPG, .GIF, .PNG, etc.) or a zip file of several images, as opposed to a Word document containing the screen shots. Because Word documents are prone to viruses, many message board users will not open your Word file, therefore limiting their ability to help you.

Similarly, if you are uploading a zipped archive, you should simply create a .ZIP file and not a self-extracting .EXE as many users will not run your EXE file.
See more
See less

Extreme problem adding fields to a table.

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    #16
    Re: Extreme problem adding fields to a table.

    Dave's right. a5_add_fields_to_table( ) works great.

    Without a posted sample, we cannot help much.

    Comment


      #17
      Re: Extreme problem adding fields to a table.

      Originally posted by preston2 View Post
      In the beginning of this thread I was also looking for a way to either write the tables field list to a file or even print it out so I could post it here but have yet to find anything to do that either.
      Wasn't paying attention, sorry.

      Code:
      ? table.external_field_name_get("awgmd","n,t,W,D")
      = storenum,C,9,0
      startdate,C,17,0
      enddate,C,17,0
      vendor,C,7,0
      upc,C,14,0
      dept,N,5,0
      descriptio,C,51,0
      regretail,N,9,2
      activereta,N,11,2
      qty,N,4,0
      sales,N,9,2
      salesatreg,N,19,2
      admarkdown,N,12,2
      There can be only one.

      Comment


        #18
        Re: Extreme problem adding fields to a table.

        Oldie but goodie.

        Code:
        fil = file.create("c:\tbllist.txt",FILE_RW_EXCLUSIVE)
        grnd_max_len = 0
        table_name = :a5.table_enum("")
        IF table_name <> "" THEN
        	'While the table_enum method returns nonblank names, get next name
        	WHILE table_name <> ""
        		:Statusbar.Set_Text("Building format specifications.")
        		t = table.open(table_name)
        		flds = t.fields_get()
        		FOR x = 1 TO flds
        			fldlnchk = t.field_get(x)
        			if len(fldlnchk.name_get()) > grnd_max_len
        				grnd_max_len = len(fldlnchk.name_get())
        			end if
        		next x
        		t.close()
        		table_name = :A5.table_enum(table_name)
        	END WHILE
        END IF
        
        table_name = :a5.table_enum("")
        IF table_name <> "" THEN
        	'While the table_enum method returns nonblank names, get next name
        	WHILE table_name <> ""
        		:Statusbar.Set_Text("Building list for: " + table_name)
        		t = table.open(table_name)
        		flds = t.fields_get()
        		FOR a = 1 TO flds
        			fldptr = t.field_get(a)
        			if a = 1
        				fil.write_line("TABLE: "+F_upper(table_name))
        				fil.write_line("")
        				fil.write_line(padr("Fieldname",max(grnd_max_len+3,11)," ")+"Type " + "Width "+"Decimals")
        			end if
        '			fil.write_line(padr(f_upper(lower(fldptr.name_get())),max(fld_max_len+3,11)," ")+" "+f_upper(lower(fldptr.type_get()))+" "+fldptr.width_get()+" "+fldptr.dec_get())
        			fil.write_line(padr(f_upper(lower(fldptr.name_get())),max(grnd_max_len+3,11)," ")+" "+f_upper(lower(fldptr.type_get()))+" "+padl(alltrim(str(fldptr.width_get())),7," ")+" "+padl(alltrim(str(fldptr.dec_get())),8," "))
        		NEXT a
        		
        		t.close()
        		fil.write_line("")
        		fil.write_line("")
        		table_name = :A5.table_enum(table_name)
        	END WHILE
        END IF
        fil.flush()
        fil.close()
        :Statusbar.Set_Text("Done!!")
        There can be only one.

        Comment


          #19
          Re: Extreme problem adding fields to a table.

          Originally posted by CraigSchumacker View Post
          Dave's right. a5_add_fields_to_table( ) works great.

          Without a posted sample, we cannot help much.
          Like I said in the first post and showed in the example code, I have always used a5_add_fields_to_table( ) in a function and it has worked flawlessly until now.

          The funny thing is I am also adding a field to another table using the same a5_add_fields_to_table( ) code like I showed in the first post. It works.

          I have come to the conclusion that during a previous update Alpha did something funny to the table that can now not be detected or fixed using any of the utilities within Alpha.

          So it looks like I will either need to add a child table and re-write all my code and redo two forms or manually preform the table update to add the fields for all my customers. I think I will try adding the child table as that will be less work.


          OK.... It is definitely something Alpha screwed up on the table during one of the last updates.

          I used an operation to copy wo_header.dbf to wo_header2.dbf and then added the fields to the wo_header2.dbf using the function I have always used and it worked.

          So now the question is, if I copy thier existing wo_header.dbf to a new wo_header2.dbf, how do then replace wo_header.dbf with the new wo_header2.dbf?

          Comment


            #20
            Re: Extreme problem adding fields to a table.

            tbl.rename() will do the dbf and all support files.

            Comment


              #21
              Re: Extreme problem adding fields to a table.

              Originally posted by CraigSchumacker View Post
              tbl.rename() will do the dbf and all support files.
              Ok, the wo_header.dbf is the parent in a set. Without testing it first I assume that the tbl.rename() will not rename to an existing table name without first deleting the existing table or renaming it. If the later then would that also change the set structure to using the name you gave the old table to get it out of the way thus making all of this pointless or am I over thinking this.

              Comment


                #22
                Re: Extreme problem adding fields to a table.

                Does this table have indices?
                Have you tried to compact the DB before running this function?
                What's the big picture? Why running such a procedure on a routine basis?

                Comment


                  #23
                  Re: Extreme problem adding fields to a table.

                  You will need to test that out, but as long as the set is not open when you replace the file, the set should remane unaffected provided there are no changes to the fields you are linking on...

                  What you are doing relates to what I will need to do soon. Until now, when a client asks for updates, I manually apply them. Slow and tedious.

                  Now that I am seeking hundreds of clients, that is no longer time effective.

                  Comment


                    #24
                    Re: Extreme problem adding fields to a table.

                    Originally posted by G Gabriel View Post
                    Does this table have indices?
                    Have you tried to compact the DB before running this function?
                    What's the big picture? Why running such a procedure on a routine basis?
                    Yes to the indices.
                    I learned long ago to never compact the DB as it can blow the DB up and destroy any memo fields. I do however check and update indexes if needed and also pack the tables.

                    This is not a routine basis.

                    I sell an app. When I do updates, I release an update installer. They are automatically notified when they start the app that there is an update available. When they download and run the update installer it updates their install. Then when they restart the app it runs a function that first checks to see if a table in question has the new fields in it. If so nothing happens. If not then the function adds the fields to the table.

                    Comment


                      #25
                      Re: Extreme problem adding fields to a table.

                      Originally posted by CraigSchumacker View Post
                      You will need to test that out, but as long as the set is not open when you replace the file, the set should remane unaffected provided there are no changes to the fields you are linking on...

                      What you are doing relates to what I will need to do soon. Until now, when a client asks for updates, I manually apply them. Slow and tedious.

                      Now that I am seeking hundreds of clients, that is no longer time effective.
                      I am going to create a test app and try. No indexes are being added or changed.

                      I have hundreds of customers and is why I do this normally simple automatic update thing. I could not handle updating each customer manually.

                      Comment


                        #26
                        Re: Extreme problem adding fields to a table.

                        Originally posted by preston2 View Post
                        I learned long ago to never compact the DB as it can blow the DB up and destroy any memo fields.
                        Please, UN-learn that..

                        Comment


                          #27
                          Re: Extreme problem adding fields to a table.

                          Originally posted by G Gabriel View Post
                          Please, UN-learn that..
                          Nope. I have had it destroy many different apps in the past. I will never compact a DB again.

                          Comment


                            #28
                            Re: Extreme problem adding fields to a table.

                            Yes, I agree. Not compacting might well be what caused your issue with the table.

                            I've compacted, like, a million times never having an issue but resolving many issues. Thousands of tables accross the scope, mind you. They include some memo fields, but granted not many.

                            You should backup first, and you can always revert if there is a problem. Or as a last resort, drop a concerning table while you compact, and then re-add it

                            Comment


                              #29
                              Re: Extreme problem adding fields to a table.

                              Maybe so, I have just had very bad results compacting a db. I am the guy that if it can happen to only one person on the planet, it will happen to me.

                              Problem is I would be afraid to add script to the autoexec that would compact the db as with my luck it would blow up hundreds of customers databases. My update installer always backs up the db before installing any updates so it will be safe but I do not need all the phone calls.

                              But I will test a DB compact just to see.

                              Anyway. This works.

                              Code:
                              'Date Created: 04-Sep-2015 09:21:30 AM
                              'Last Updated: 04-Sep-2015 09:53:25 AM
                              'Created By  : ShopCal
                              'Updated By  : ShopCal
                              copy_db_name = filename_decode("[PathAlias.ADB_Path]\test_header2.dbf")
                              
                              a_tbl = table.open("test_header")
                              ON ERROR GOTO ERROR0409201509105705
                              
                              
                              DIM a5_operation_order as C
                              a5_operation_order = ""
                              query.order = a5_operation_order
                              DIM a5_operation_filter as C
                              a5_operation_filter = ".T."
                              query.filter = a5_operation_filter
                              query.options = "I"
                              query.description = "Temporary Query"
                              i_indx = a_tbl.query_create()
                              
                              copy.set = ""
                              copy.db = copy_db_name
                              copy.dd = .T.
                              copy.delete_o_dd = .T.
                              copy.records = .T.
                              copy.fields = 3
                              copy.field1 = "Inv_Id"
                              copy.field2 = "Johnny"
                              copy.field3 = "Billy"
                              
                              a_tbl.copy()
                              
                              
                              GOTO CONTINUE0409201509105705
                              ERROR0409201509105705:
                              ON ERROR GOTO 0
                              ui_msg_box("Error","Error running Copy Operation"+crlf()+error_text_get())
                              END
                              CONTINUE0409201509105705:
                              a_tbl.close()
                              'Add the table just created by the Copy operation to the Database..
                              file_add_to_db(copy_db_name)
                              
                              'You can only run the change table name once in a session as Alpha locks the newname
                              dim filename as c
                              dim newname as c
                              filename ="test_header" 'Must rename it so you can rename the copied table to this name
                              newname ="test_hold"
                              
                              tbl = table.open(filename, FILE_RW_EXCLUSIVE)
                              tbl.rename(newname)
                              tbl.close()
                              
                              filename ="test_header2" 'Now rename the copied table
                              newname ="test_header"
                              
                              tbl = table.open(filename, FILE_RW_EXCLUSIVE)
                              tbl.rename(newname)
                              tbl.close()
                              
                              add_fields() 'Call the function shown below
                              'FUNCTION add_fields AS L ( ) "this is the code in the function called above"
                              '                               
                              'fld_list = a5_get_fieldnames( "test_header.dbf" )
                              'IF "IS_Exported"$fld_list '2013-12-13
                              '    GOTO Updates_done
                              'END if
                              'fld_list = a5_get_fieldnames( "test_header.dbf" )
                              'IF .not. ("Is_Exported"$fld_list)
                              '    fields = <<%list%
                              'Is_Exported,L,1
                              'event_id,N,16,0
                              'Details,C,72
                              'tmstart,T,17
                              'tmend,T,17
                              'Alarm,C,20
                              'How,C,20
                              'Equip,C,20
                              'Export_It,L,1
                              'Add_Date,D,8
                              'Sch_Notes,C,240
                              'Priority,N,4,0
                              'Class_type,C,16
                              'Rev_Date,D,8
                              'Sch_datec,C,16
                              'Sch_Date,D,8
                              'Cust_email,C,60
                              '%list%
                              'a5_add_fields_to_table("test_header.dbf",fields )
                              '    end if
                              'Updates_done:
                              '
                              'END FUNCTION

                              Comment


                                #30
                                Re: Extreme problem adding fields to a table.

                                Preston,

                                In my own work I compact my development copy of the application frequently. This "cleans" up the design elements of the application prior to release.

                                I never release an app that routinely compacts the database on the client's machines. I don't think anyone here is recommending that you do so, either.

                                Comment

                                Working...
                                X