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

Question RE: LQO in Script

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

    Question RE: LQO in Script

    Currently my employees run the script below to find cancellations from our clients. In the Query Filter, the first 2 conditions are using LQO. The last condition does not. All fields referenced in the Filter are also indexed fields. I believe the last part of the Query goes thru all of the records because of the "OR" conditions. Unfortunately all of those "OR's" are necessary to run the Query correctly. What I am asking is there any other way I might be able to reference all of those conditions and have A5 use LQO for the entire Query Filter? If not, we will live with it but since there are approximately 82,000 records and growing daily, it would be great if we could cut the time it takes to run the query. It is especially slow over the network of course. I have commented out the Export portion while I have been working on this. Thanks for looking....

    dim tbl as P

    tstr1 = ui_get_text("Client Name","Please Enter Client")
    if tstr1=""then
    end
    end if
    user1=(tstr1)

    dstr = ui_get_date("Date Received","Please Enter Date In")
    if dstr=""then
    end
    end if
    user2=ctod(dstr)

    tbl=table.open("ameregl3")


    query.description = ""
    query.order = ""
    query.filter = "AMEREGL3->ATTORNEY="+quote(user1)+".AND.AMEREGL3->DATE_COMP={"+dtoc(user2)+"}.AND.(AMEREGL3->CODE=\"adne\".OR.ameregl3->code=\"cd\".OR.ameregl3->code=\"can\".OR.ameregl3->code=\"c2\".OR.ameregl3->code=\"cnc\".OR.ameregl3->code=\"pb2\".OR.ameregl3->code=\"cnp\".OR.ameregl3->code=\"cnc2\".OR.ameregl3->code=\"cc2\".OR.ameregl3->code=\"ia\".OR.ameregl3->code=\"isp\".OR.ameregl3->code=\"isn\".OR.ameregl3->code=\"ita\".OR.ameregl3->code=\"nan\".OR.ameregl3->code=\"npa\".OR.ameregl3->code=\"nun\".OR.ameregl3->code=\"nsa\".OR.ameregl3->code=\"nss\".OR.ameregl3->code=\"non\".OR.ameregl3->code=\"ncz\".OR.ameregl3->code=\"pba\".OR.ameregl3->code=\"pv\".OR.ameregl3->code=\"sdne\".OR.ameregl3->code=\"ssw\".OR.ameregl3->code=\"cmra\")"
    query.options = "I"
    tbl.query_create()
    'export.type = 4
    'export.names = .F.
    'export.file = "\\Docserver\inetpub\EXCEL PROGRAMS\CANCELLATIONS\Cancellations.xls"
    'export.options = ""
    'export.field_sep = ""
    'export.record_sep = ""
    'export.fields = 9
    'export.field1 = "ameregl3->attorney"
    'export.field2 = "ameregl3->Person"
    'export.field3 = "ameregl3->ref___"
    'export.field4 = "ameregl3->date_in"
    'export.field5 = "ameregl3->address"
    'export.field6 = "ameregl3->poe_address"
    'export.field7 = "ameregl3->code"
    'export.field8 = "ameregl3->job"
    'export.field9 = "ameregl3->comments"
    'tbl.export()

    tbl = table.close()

    END

    #2
    Re: Question RE: LQO in Script

    You can try
    Code:
    query.filter = "ATTORNEY="+quote(user1)+" .AND. DATE_COMP={"+dtoc(user2)+"}.AND.(at(ut(CODE),\"ADNE-CD-CAN-C2-CNC-PB2-CNP-CNC2-CC2-IA-ISP-ISN-ITA-NAN-NPA-NUN-NSA-NSS-NON-NCZ-PBA-PV-SDNE-SSW-CMRA\")>0)"
    This won't use LQO either i think but may speed up the query by not doing multiple compares for the same field.

    Also in this case, the use of the table name within the filter string is not necessary as the filter is applied to the tbl pointer where you have already specified the table. It is not detrimental to include the name but is less typing and a bit easier to read.

    Edit: after seeing Stan's post I changed the upper() function to the ut() function to trim the field value.
    Last edited by Tim Kiebert; 01-12-2015, 09:34 PM.
    Tim Kiebert
    Eagle Creek Citrus
    A complex system that does not work is invariably found to have evolved from a simpler system that worked just fine.

    Comment


      #3
      Re: Question RE: LQO in Script

      The entire test of ameregl3->code = can be replaced.

      Build a list like (shortened sample version).

      codes_list = "adne,cd,can,c2,cnc" 'comma list of all codes
      codes_list = strtran(codes_list,",",crlf()) 'convert comma list to crlf list

      Then the filter is
      query.filter = "AMEREGL3->ATTORNEY="+quote(user1)+".AND.AMEREGL3->DATE_COMP={"+dtoc(user2)+"} .AND. is_one_of(alltrim(ameregl3->code),"+quote(codes_list)+")"

      If that doesn't speed it up we can try other methods.
      There can be only one.

      Comment


        #4
        Re: Question RE: LQO in Script

        Hi Stan,
        Did ver 5 use crlf() lists?
        Robin

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

        Comment


          #5
          Re: Question RE: LQO in Script

          I don't think it's a question of a particular version using lists, rather whether a specific function is supported in a specific version

          Is_one_of(), per the docs, is available in v5.
          Comma_to_crlf() says v6 or later so I suggested strtran() instead.

          All three "use lists".
          There can be only one.

          Comment


            #6
            Re: Question RE: LQO in Script

            Gentlemen, Thanks for the replies. I've finally gotten into work and will try these. Will update you on progress. I've never had the occasion to need a "list" before, until, now. I will certainly read up on them now. I wasn't aware that you could actually call out a list. Thanks again.

            Scott

            Comment


              #7
              Re: Question RE: LQO in Script

              *****UPDATE*****
              Ok, so I tried both methods and still goes through all 82,000 records on the last part of the filter, although the script is much neater now.

              Comment


                #8
                Re: Question RE: LQO in Script

                You do have an index on the code field? I'm not clear how is_one_of() works with LQO since functions aren't mentioned in the docs other than smatch() and between().

                The .OR. shouldn't cause problem since it is an allowed operator for LQO.

                Collections are faster than using is_one_of(). Docs say v5 supports collections.

                Try this attack

                Code:
                codes_list= "adne;adne,cd;cd,can;can,c2;c2,cnc;cnc,pb2;pb2,cnp;cnp,cnc2;cnc2,cc2;cc2,ia;ia,sp;sp,isn;isn,ita;ita,nan;nan,npa;npa,nun;nun,nsa;nsa,nss;nss,non;non,ncz;ncz,pba;pbh,pv;pv,sdne;sdne,ssw;ssw,cmra;cmra"
                codes_list  = strtran(codes_list,",",crlf())
                
                dim global cds as U 'must be global so the query.filter expression will "see" it, in my experience
                cds.initialize("1;2","1","2",codes_list)
                tbl=table.open("ameregl3")
                query.description = ""
                query.order = ""
                query.filter = "ATTORNEY="+quote(user1)+".AND.DATE_COMP={"+dtoc(user2)+"} .AND. cds.exist(alltrim(CODE))"
                
                'rest of script
                Another thought. You have a pretty long list of codes you are including in the filter. Is the list of codes to be excluded shorter? Might be able to filter exclude a shorter list.
                Last edited by Stan Mathews; 01-13-2015, 04:52 PM.
                There can be only one.

                Comment


                  #9
                  Re: Question RE: LQO in Script

                  Thanks for the suggestion Stan. Yes, "Code" is one of the indexes as are "Attorney" and "Date_comp". I'll give this a try and see what happens. I also noticed that ".OR." is included in LQO. I assumed the length of time is due to so many ".OR." conditions and the time involved is due to comparing all of them for each record. I was hoping that the "comparison" would only be for the records called out by the "Attorney" field and the "Date_comp" field and not all records.

                  Comment


                    #10
                    Re: Question RE: LQO in Script

                    Hi Stan. Tried it and I still get the same thing. It's still going through all records. It could be "it is what it is". I thought maybe I could break up the query into 2 Queries, one for the "Attorney" and "Date_comp" and then query those records for the "Code" conditions, but I'm pretty sure it will be the same result and a lot more typing and needless code. Could be I may have to live with it the way it is.

                    Comment


                      #11
                      Re: Question RE: LQO in Script

                      I assumed the length of time is due to so many ".OR." conditions and the time involved is due to comparing all of them for each record.
                      Agreed. The is_one_of() filter expression variation should have been faster then the multiple .or. filter, just won't use LQO. The collection version should be faster still.
                      There can be only one.

                      Comment


                        #12
                        Re: Question RE: LQO in Script

                        Thanks Stan for your time and trouble in helping me with this. The good thing I can take from this is I learned about Collections and some new functions. Always good to be able to add to your own knowledge base for the future. Unfortunately, being 60 years old I'll have to hope I can recall it in the future...lol.

                        Comment


                          #13
                          Re: Question RE: LQO in Script

                          Scratch this idea. We'd have to filter the index for only the codes used in the filter. Otherwise all records would fit the query.filter expression. Not a fan of filtered indexes. Brain freeze led to that.

                          Since we're this deep, try creating an index with the expression

                          attorney+cdate(date_comp)+code

                          index tag name "composite"

                          then

                          query.filter = "key_exist(\"composite\",attorney+cdate(date_comp)+code)"

                          Again, just looking for speed. LQO is not going to be possible with your list of codes to check.
                          Last edited by Stan Mathews; 01-13-2015, 05:33 PM.
                          There can be only one.

                          Comment


                            #14
                            Re: Question RE: LQO in Script

                            Ok. I'll give it a try. I never thought of creating a different type of index specific to this.

                            Comment


                              #15
                              Re: Question RE: LQO in Script

                              When I tried to create the index, after inserting the expression, it gives an error message "Expression does not evaluate to a logical value", and won't let me save it.

                              Comment

                              Working...
                              X