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

Turning off Auto Increment during append

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

    Turning off Auto Increment during append

    I have 2 tables test1 and test2
    Test has a field rule for autoincrement
    When I use a batch append form Test2 to Test1, I do not want the autoincrement field to work.
    I tried using the tbl.enter_begin(.F.). But it still "honors" the filed rules.
    I could manually delete tha rules then add it back, but that's a pain.
    I read many of the posts here as to which rules are honored etc. But none answer my question.
    Any help would be appreciated.

    #2
    Re: Turning off Auto Increment during append

    For a table named test with an autoincrement field named id I did this in the interactive editor.

    Code:
    tbl = table.open("test")
    rul = tbl.rules_get()
    
    ? rul.id.data_type
    = "AutoInc"
    ? rul.id.Default.Default
    = "00001"
    ? rul.id.Default.Type
    = "Simple"
    
    tbl.close()
    Which means you could

    Code:
    tbl = table.open("test")
    rul = tbl.rules_get()
    rul.change_begin()
    rul.id.data_type = "User"
    rul.id.Default.Default = ""
    rul.id.Default.Type = "None"
    rul.change_end(.t.)
    tbl.close()
    before the operation and


    Code:
    tbl = table.open("test")
    rul = tbl.rules_get()
    rul.change_begin()
    rul.id.data_type = "AutoInc"
    rul.id.Default.Default = "00001"
    rul.id.Default.Type = "Simple"
    rul.change_end(.t.)
    tbl.close()
    after it.
    There can be only one.

    Comment


      #3
      Re: Turning off Auto Increment during append

      If I understand this.
      This will allow me to append to Test1 with autoincrement turned off.
      Which means that the filed value in test2 would be appended with the original values intact?
      Correct?
      Thanks

      Comment


        #4
        Re: Turning off Auto Increment during append

        Hi Stan,
        Why change the default type and value at all? Wouldn't it be enough to just change the rul.id.data_type from Auto_Inc to User then back again?
        Robin

        Discernment is not needed in things that differ, but in those things that appear to be the same. - Miles Sanford

        Comment


          #5
          Re: Turning off Auto Increment during append

          Originally posted by Jeff Richards View Post
          If I understand this.
          This will allow me to append to Test1 with autoincrement turned off.
          Which means that the filed value in test2 would be appended with the original values intact?
          Correct?
          Thanks
          The indicated code removes the autoincrement field rule and then puts it back in place so you should be able to do what you want.
          There can be only one.

          Comment


            #6
            Re: Turning off Auto Increment during append

            Originally posted by MoGrace View Post
            Hi Stan,
            Why change the default type and value at all? Wouldn't it be enough to just change the rul.id.data_type from Auto_Inc to User then back again?
            I'm not sure what would happen if two parts of the auto increment process are left in place and one is removed. I don't use auto increment so I don't have the experience to rely on.
            There can be only one.

            Comment


              #7
              Re: Turning off Auto Increment during append

              Originally posted by Stan Mathews View Post
              I'm not sure what would happen if two parts of the auto increment process are left in place and one is removed. I don't use auto increment so I don't have the experience to rely on.
              When field rules are changed from Auto Incr to User the default doesn't change since it can be used for either setting. So it seemed like it wouldn't necessitate changing it to turn it off and on for an append operation.
              Robin

              Discernment is not needed in things that differ, but in those things that appear to be the same. - Miles Sanford

              Comment


                #8
                Re: Turning off Auto Increment during append

                Is this right?
                'Date Created: 24-Mar-2008 09:06:46 PM
                'Last Updated: 24-Mar-2008 09:06:46 PM
                'Created By :
                'Updated By :
                tbl = table.open("test")
                rul = tbl.rules_get()
                rul.change_begin()
                rul.id.data_type = "User"
                rul.id.Default.Default = ""
                rul.id.Default.Type = "None"
                rul.change_end(.t.)
                tbl.close()


                append.t_db = "test2"
                append.m_key = ""
                append.t_key = ""
                append.m_filter = ""
                append.t_filter = ""
                append.type = "All"
                append.m_count = 1
                append.m_field1 = "SYSID"
                append.m_exp1 = "@Test2->Sysid"
                append.t_count = 0
                tbl.enter_end(.T.)
                'Prompt for confirmation before running the Operation.......
                dim rec_count as n
                rec_count = a5_get_records_in_query("test2",append.t_filter)
                message_text = "A maximum of "+rec_count + " record(s) will be appended from 'test2', to 'test'. "+crlf(2)+ "OK to proceed?"
                operation_result=ui_msg_box("Append Operation",message_text,UI_OK_CANCEL+ UI_FIRST_BUTTON_DEFAULT+ UI_INFORMATION_SYMBOL)
                If operation_result <> ui_ok_selected then
                end
                end if


                tbl.append()


                'Display a dialog box showing the results of the Operation
                a5_append_op_result(a_records_processed,a_records_total,a_records_violated, "test")

                'If the Operation is run from within a Form or Browse, then refresh the window
                if is_object(topparent.this) then
                if topparent.Class() = "form" .or. topparent.class() = "browse" then
                topparent.Refresh_layout()
                end if
                end if
                tbl = table.open("test")
                rul = tbl.rules_get()
                rul.change_begin()
                rul.id.data_type = "AutoInc"
                rul.id.Default.Default = "00001"
                rul.id.Default.Type = "Simple"
                rul.change_end(.t.)
                tbl.close()

                Comment


                  #9
                  Re: Turning off Auto Increment during append

                  When field rules are changed from Auto Incr to User the default doesn't change since it can be used for either setting. So it seemed like it wouldn't necessitate changing it to turn it off and on for an append operation.
                  Easy enough to check out but know you are correct as I have had to do this manually before and all that was necessary was to turn the AutoInc to User and then back again. This is how I figure out how to do a lot of my scripting....do it manually and then mimic this with xBasic. With this approach it so far has made anything I have wanted to do very easy to implement in xbasic / Action Script. Just have to find the right functions to do it with (sounds sooooo easy doesn't it! :) ).
                  Mike
                  __________________________________________
                  It is only when we forget all our learning that we begin to know.
                  It's not what you look at that matters, it's what you see.
                  Henry David Thoreau
                  __________________________________________



                  Comment


                    #10
                    Re: Turning off Auto Increment during append

                    Hi Jeff,

                    Looks good on the surface...but I do not think there is a need to close the table "test" until the very end...IOW open the table, leave it open until the end of the script and then close it. Instead of opening it twice and closing it twice.
                    Mike
                    __________________________________________
                    It is only when we forget all our learning that we begin to know.
                    It's not what you look at that matters, it's what you see.
                    Henry David Thoreau
                    __________________________________________



                    Comment


                      #11
                      Re: Turning off Auto Increment during append

                      Originally posted by Jeff Richards View Post
                      Is this right?
                      'Date Created: 24-Mar-2008 09:06:46 PM
                      'Last Updated: 24-Mar-2008 09:06:46 PM
                      'Created By :
                      'Updated By :
                      tbl = table.open("test")
                      .............
                      The only field you seem to be appending is "sysid" so I guess that is the field you need turn off the autoinc for?

                      Code:
                      'Date Created: 24-Mar-2008 09:06:46 PM
                      'Last Updated: 24-Mar-2008 09:06:46 PM
                      'Created By : 
                      'Updated By : 
                      tbl = table.open("test")
                      rul = tbl.rules_get()
                      rul.change_begin()
                      rul.[COLOR="Red"]sysid[/COLOR].data_type = "User"
                      rul.[COLOR="red"]sysid[/COLOR].Default.Default = ""
                      rul.[COLOR="red"]sysid[/COLOR].Default.Type = "None"
                      rul.change_end(.t.)
                      '[COLOR="Blue"]tbl.close()[/COLOR] '[COLOR="blue"]<- don't do this since we're using the tbl pointer later[/COLOR]
                      
                      
                      append.t_db = "test2"
                      append.m_key = ""
                      append.t_key = ""
                      append.m_filter = ""
                      append.t_filter = ""
                      append.type = "All"
                      append.m_count = 1
                      append.m_field1 = "SYSID"
                      append.m_exp1 = "@Test2->Sysid"
                      append.t_count = 0
                      '[COLOR="blue"]tbl.enter_end(.T.)[/COLOR] [COLOR="blue"]'don't see where this is necessary and will cause an error[/COLOR]
                      [COLOR="blue"]'because an enter has not begun[/COLOR]
                      'Prompt for confirmation before running the Operation.......
                      dim rec_count as n 
                      rec_count = a5_get_records_in_query("test2",append.t_filter)
                      message_text = "A maximum of "+rec_count + " record(s) will be appended from 'test2', to 'test'. "+crlf(2)+ "OK to proceed?"
                      operation_result=ui_msg_box("Append Operation",message_text,UI_OK_CANCEL+ UI_FIRST_BUTTON_DEFAULT+ UI_INFORMATION_SYMBOL)
                      If operation_result <> ui_ok_selected then 
                      end 
                      end if 
                      
                      
                      tbl.append()
                      
                      
                      'Display a dialog box showing the results of the Operation
                      a5_append_op_result(a_records_processed,a_records_total,a_records_violated, "test")
                      
                      'If the Operation is run from within a Form or Browse, then refresh the window
                      if is_object(topparent.this) then 
                      if topparent.Class() = "form" .or. topparent.class() = "browse" then 
                      topparent.Refresh_layout()
                      end if 
                      end if 
                      tbl = table.open("test")
                      rul = tbl.rules_get()
                      rul.change_begin()
                      rul.[COLOR="red"]sysid[/COLOR].data_type = "AutoInc"
                      rul.[COLOR="red"]sysid[/COLOR].Default.Default = "00001" '[COLOR="Red"]<-change this to whatever your real default might be[/COLOR]
                      rul.[COLOR="red"]sysid[/COLOR].Default.Type = "Simple"
                      rul.change_end(.t.)
                      tbl.close()
                      There can be only one.

                      Comment


                        #12
                        Re: Turning off Auto Increment during append

                        It's amazing what I can learn form this board. I now understand it. And it works.
                        The only thing that doesn't happen is the field rules going back to "AutoInc"
                        The beginning of the script removes the field rule, then appends without the rules. However, it is not putting back the rules. Any suggestions?
                        Thanks again for the help.

                        Comment


                          #13
                          Re: Turning off Auto Increment during append

                          Hey Stan,
                          You may not need to close the table after the first change_end() but if you open the table again it will be pointing to an alias - which is perhaps why Jeff couldn't get the field rule to change back? Because another instance of the table was left open.
                          Robin

                          Discernment is not needed in things that differ, but in those things that appear to be the same. - Miles Sanford

                          Comment


                            #14
                            Re: Turning off Auto Increment during append

                            Probably. I didn't recognize that the last section didn't need the opening command.
                            Code:
                            [COLOR="Red"]'tbl = table.open("test")'<-don't do this again[/COLOR]
                            rul = tbl.rules_get()
                            rul.change_begin()
                            rul.sysid.data_type = "AutoInc"
                            rul.sysid.Default.Default = "00001" '<-change this to whatever your real default might be
                            rul.sysid.Default.Type = "Simple"
                            rul.change_end(.t.)
                            tbl.close()
                            There can be only one.

                            Comment


                              #15
                              Re: Turning off Auto Increment during append

                              Thanks for the help.
                              It still does not put back the rules.
                              Any solutions?
                              Thanks.

                              Comment

                              Working...
                              X