Method Community

 

Truncate Table

Last post 05-05-2010 10:01 AM by BrianPoole. 6 replies.
Page 1 of 1 (7 items)
Sort Posts: Previous Next
  • 04-22-2010 1:04 PM

    Truncate Table

    Hello

    Is it possible to truncate a table using the API?

    I can get the data into a table, but I want to clear it first.

     

    Thanks,

    -Brian

  • 04-22-2010 1:36 PM In reply to

    Re: Truncate Table

    Brian,

    There is no clear or purge function (scary to have such a thing!).  But there is MethodAPIDeleteV2.  This lets you delete one record at a time.  You need to know the RecordID of the records you want to delete first though. So you would have to retreive those using MethodAPISelect_XMLV2 or MethodAPISelect_DatasetV2.

    Paul

  • 04-22-2010 1:38 PM In reply to

    Re: Truncate Table

     By the way - if you are looking to import data into Method, you might want to take a look at the new Import / Export tool we just launched into beta yesterday.  It's pretty awesome. See http://www.methodintegration.com/cs/forums/t/721.aspx.

  • 04-22-2010 2:04 PM In reply to

    Re: Truncate Table

     Hi Paul,

    I was taking your advice from this post
    http://www.methodintegration.com/cs/forums/t/670.aspx

    I found a way to do it by using Method actions--

    Start Loop Through Grid
       Delete Record From Table -- Record ID equal to Value From Row RecordID
    Start Loop Through Grid

    Seems to work...

    I like the batch import idea, is there a way to do that through the API?
    Right now I'm importing one record at a time. Not a big deal, but I could imagine the performance increase...

     

    Brian

  • 04-22-2010 4:29 PM In reply to

    Re: Truncate Table

    Brian - even with the import / export tool it is still importing one record at a time and validating as it goes. 

    In terms of performance increases, you are right that a DELETE * FROM TableName would be the most efficient SQL to run against it. Since Method, in general, is made for non-programmers, this is something we are staying away from.

    Paul

  • 04-27-2010 9:27 AM In reply to

    • Matt
    • Top 10 Contributor
    • Joined on 11-04-2008
    • Posts 877

    Re: Truncate Table

    Brian,

    I made a utility for my own use to erase all the records in any given table. It isn't pretty looking and given it's destructive potential I don't think I'd want to give/sell it to anyone, but if you have a few tables that you would like erased one time, you can contact me at matt@TechInTheField.com and I should be able to take care of that for you.


    Matt Raiser

    Founder,



    www.techinthefield.com

    matt@techinthefield.com

    219-221-9500



    ~ Method user / partner since 2008

    ~ Over 15 years field service experience

    ~ 2013 Method Partner of the Year

    ~ Degree in Computer Science





    Creator of:


        


  • 05-05-2010 10:01 AM In reply to

    Re: Truncate Table

    Matt,

    I appreciate it, but this is a temporary table I'm working with. I fill in the data remotely with a webservice and I want to show the results to the end user. The grid loop seems to work fine for now.

Page 1 of 1 (7 items)