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

query problem

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

    query problem

    Hi,
    I am trying to run this query and it won't work. The interesting thing is that the first time I ran it, it worked fine, but now it won't work at all.
    I took the code to a different machine and the same thing happened. It worked the first time but won't work any more.

    Any thoughts?

    dim newcode as c
    dim tbl as P
    dim qry as P
    dim nrecs as N

    newcode = "con"
    tbl = table.open("mgmt_co")
    indx = tbl.index_record_get()
    indx2 = tbl.index_primary_put(indx)
    query.description = "Management Company"
    query.order = "mgmt_co"
    query.filter = "*leading(Mgmt_Co,newcode)"
    query.options = ""
    qry = tbl.query_create()
    nrecs = qry.records_get()
    ?nrecs
    = 0

    There are 27 records in the table that meet the filter.

    Any ideas why this doesn't work?

    thanks,
    mike
    Mike Reed
    Phoenix, AZ

    #2
    Re: query problem

    I think this will help, but it would easy to test if you supplied sample data.

    Note this is not a complete script, I've just showing the parts I'd work on.

    Code:
    newcode = "con"
    tbl = table.open("mgmt_co")
    [COLOR="Red"]' indx = tbl.index_record_get()   <-- not needed
    ' indx2 = tbl.index_primary_put(indx) <--- not needed[/COLOR]
    query.description = "Management Company"
    query.order = "mgmt_co"
    query.filter = "*leading(Mgmt_Co,[COLOR="Red"]quote(newcode))[/COLOR]"

    Comment


      #3
      Re: query problem

      Hi Tom,
      Thanks for the hint.
      I tried with the additional quote() option. Still doesn't work.

      I agree that the 2 references for indexing are not needed. I added those in a desperate attempt to try something to get it to work.

      Have you tried this on any database?
      Mike Reed
      Phoenix, AZ

      Comment


        #4
        Re: query problem

        Mike

        This may be a dumb question, but is the Mgmt_co in the query.filter a field in your table?

        The only reason I ask is that it is the same name of the table that you are opening.

        Tom Baker

        Comment


          #5
          Re: query problem

          Yes it is. The odd thing is that this function will work sporadically using the query by expression with the table in browse. Even then, it doesn't function consistently.

          mike
          Mike Reed
          Phoenix, AZ

          Comment


            #6
            Re: query problem

            Close the table at the end of the script.
            tbl.close()

            Comment


              #7
              Re: query problem

              Mike

              Let me make a suggestion. I am lazy when it comes to setting up a query.filter. A lot of times I go to the operations tab on the control panel - new operation - create query - use the table that I am querying and then use the genie.

              I then save the operation. Right click on it in the control panel and click on show xbasic. That shows me the query.filter that works. I then use that as my basis for the query filter in my xbasic.

              The reason I do this, is there are times when I write the query myself and it looks okay - but it doesn't work. I then copy the query.filter from the operation and it works. Sometimes it is a space or something else that causes my first attempt to fail.

              Just a thought, that might help.

              Tom Baker

              Comment


                #8
                Re: query problem

                Tried that too....still no dice.

                Attached is a zip file of the database slimmed down to 2 fields. It has a script and a query operation. Can anyone get it work consistently?

                thanks,
                mike
                Mike Reed
                Phoenix, AZ

                Comment


                  #9
                  Re: query problem

                  Fixed.
                  I also did minor change in your field rules (had no impact on the issue at hand).
                  The question I wonder:
                  since company name is unique: you couldn't possibly expect more than a count of 1 at the most, which means, you could simplify your script using something like exists(). Yu merely want to know if it exists or not, but not necessarily interested in the count.
                  Last edited by G Gabriel; 04-10-2008, 07:14 PM.

                  Comment


                    #10
                    Re: query problem

                    Here is another way, using your function *leading
                    May not be what you want.
                    FWIW

                    Tom Baker
                    Last edited by Tbaker; 04-10-2008, 07:00 PM. Reason: Wrong zip sent

                    Comment


                      #11
                      Re: query problem

                      Thanks for your help! I now have a way to find the info I needed. We are trying to stop a duplicate entry.

                      It is clear the *leading() doesn't work so now I have a work around. I'm thinking I'll send this in as a bug. I also tried *any() and *first() with the same results.

                      With the company name, it won't always be unique. The reason is that this customer has offices in 6 cities and they do work for apartment complexes. A management company may have offices in each of those cities as well. Some management companies want billing sent to their local offices and some to a central office. Since all the data being billed comes from my customer's main office, they need to have a unique, but discernable mgmt code assigned to the complex. Each satellite offices FTP's their work orders to the main office where pay and billing is done.

                      Thanks again!
                      mike

                      BTW, what was the minor change to the field rules?
                      Mike Reed
                      Phoenix, AZ

                      Comment


                        #12
                        Re: query problem

                        It is clear the *leading() doesn't work so now I have a work around. I'm thinking I'll send this in as a bug. I also tried *any() and *first() with the same results.
                        They both work fine, but they are case sensitive:
                        dim a as c
                        Code:
                        a="Alpha software inc"
                        ?*leading(a,"alp")
                        = .F.
                        ?*leading(a,"Alp")
                        = .T.
                        ?*leading(a,"Alpha s")
                        = .T.
                        ?*first(a,"alp")
                        = .F.
                        ?*first(a,"Alp")
                        = .T.
                        ?*first(a,"Alpha s")
                        = .T.
                        In the field rules, you were using remspecial() twice. I just simplified the expression with one remspecial().

                        Comment


                          #13
                          Re: query problem

                          Mike, I'm pleased solutions were found. Notice that they appeared shortly after you posted sample data. It's no coincidence.

                          Comment

                          Working...
                          X