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

<tb>.query_create()

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

    <tb>.query_create()

    Just noticed this for the first time and it makes no sense:
    This a bread & butter script:
    open a table with table.open()
    run a query using .query_create()
    got to first record, using .fetch_first()

    If the query is empty, i.e. no records in the query, fetch_first() goes to the first record in the table !

    That's not good. It shouldn't.

    Why?

    What happened if you run a QBF and the query is empty? it does not go to the first record, does it?

    The reason I didn't notice this before is because I always count the number of records in the query and if it is zero, move on to something else, otherwise continue to work on the table. This time I forgot to add this line to count the records and saw this untoward outcome.

    Bug?
    I think so.

    Word of caution:
    Always count the number of records in the query before going any further.

    Caveat:
    Someone please test in v9. The above is based on v8.

    #2
    Re: &lt;tb&gt;.query_create()

    G., I'll check it in v 9.

    In the meantime, what behavior do you think would be "correct" in this situation?

    Later...

    It seems to run the same way in vers 9. However, it seems to me that this is reasonable behavior. The record pointer in the newly opened table is not moved when the query is empty. The call to fetch the first record doesn't do anything since the record pointer is on the first record when the table opens.

    Makes sense to me.

    Code:
    t = table.open("customer")
    
    ?t.LASTNAME
    = "Graham              "
    
    query.options = "NT"
    query.order = "Lastname"
    query.filter = "Lastname = 'Abraham'"
    
    qry = t.query_create()
    
    ?qry.records_get()
    = 0
    
    ?t.LASTNAME
    = "Graham              "
    
    t.fetch_first()
    ?t.LASTNAME
    = "Graham              "
    
    qry.drop()
    
    t.close()
    This sequence should not be compared to the QBF results since the table is already open in QBF, with record pointer positioned by the user, not necessarily on the first record in the table. table.open() opens a new instance of the table, not the instance supporting the current form.

    -- tom
    Last edited by Tom Cone Jr; 09-21-2008, 05:24 PM.

    Comment


      #3
      Re: &lt;tb&gt;.query_create()

      Originally posted by Tom Cone Jr View Post
      table.open() opens a new instance of the table, not the instance supporting the current form.
      That's my point.

      table.open() opens a new instant of the table (independant of the currently open one).

      If the query is empty, then the newly opened instance is empty.
      Why does it then go to the first record?
      I expect to get a message: no records in this query.

      Thanks for checking.
      Last edited by G Gabriel; 09-21-2008, 05:46 PM.

      Comment


        #4
        Re: &lt;tb&gt;.query_create()

        I disagree but don't want to be disagreeable. To me this is a problem that occurs sometimes between the keyboard and my chair. The tbl.fetch_first() statement doesn't know or care that I've run a query. The opened instance of the table is not empty, the query failed. If Alpha treated broken or failed queries as you wish, the table would immediately be placed in ENTER mode, since your idea would cause Alpha to think there are no records in the table. Not good.

        Comment


          #5
          Re: &lt;tb&gt;.query_create()

          The tbl.fetch_first() statement doesn't know or care that I've run a query.
          The opened instance of the table is not empty,
          What you are saying would be true if fetch_first() is fetching whatever table that happens to be open. Not so. It fetchs where the pointer is and the pointer is at the new instance.

          It is not fetch_first()
          It's tbl.fetch_first()

          The pointer is at tbl i.e. at the newly opened instance of the table, NOT the currently opened one.
          It should care where the pointer is and it does, but in the end it misbehaves by going to the first record of the table since the new instance does not have a first record, it has no records at all.

          OK.. let me make my point simpler and more clear:
          Run the same script from your Code tab without any opened instances of the table.

          Now what happens?
          You still get the first record! even though the query is empty and no other instances of the table is open.
          How so?
          Last edited by G Gabriel; 09-21-2008, 06:28 PM.

          Comment


            #6
            Re: &lt;tb&gt;.query_create()

            Nope. Your logic makes sense only if the failed query is actually treated as having been run successfully leaving an "empty" instance of the table. Where you see a successful query and a failed fetch, I see a failed query and a successful fetch. You say tomato I say tomato. -- tom

            Comment


              #7
              Re: &lt;tb&gt;.query_create()

              Your logic makes sense only if the failed query is actually treated as having been run successfully leaving an "empty" instance of the table
              Of course it does, evident by counting the number of the records in the query and getting zero. It ran and produced zero records. It does not "fail". If by "fail" you mean it never ran, I think we will never come to an agreement on this as it will be a chicken-egg scenario. How does it know that there are zero records meeting the filter if it never ran?
              I will leave it there as I exhausted every possible logic I have.
              Incidentally, it's not hard to find out if it does or does not run (fail), debug the script.
              Last edited by G Gabriel; 09-21-2008, 06:59 PM.

              Comment


                #8
                Re: &lt;tb&gt;.query_create()

                I'm ready to quit, too. Of course the query ran, but it "failed" to find any matching records. That's the whole point, right? Bye. -- tom

                Comment


                  #9
                  Re: &lt;tb&gt;.query_create()

                  OK..back where we started.
                  The script opened a new instance of the table.
                  The query ran.
                  It "failed", i.e. found zero records. 'let's leave these symantics for now.

                  The new instance of the table, after the query ran, has zero records, yet the pointer goes to the first record!
                  How?

                  To further illustrate my point:
                  Run the script from the code tab without any instances of the table being open.
                  Close the code tab.
                  Open the table.
                  When you open the table, it should open empty with no records whatsover.
                  Again, how did the pointer go to the first record when the table is empty?

                  I am sorry, it's a bug. Will report it as such.
                  Last edited by G Gabriel; 09-21-2008, 07:53 PM.

                  Comment


                    #10
                    Re: &lt;tb&gt;.query_create()

                    Ok. Let us know what you find out. -- tom

                    Comment


                      #11
                      Re: &lt;tb&gt;.query_create()

                      Gabe,

                      I hope they don't fix it because we would then have another alpha box showing up when there are no records.

                      I will have to rewrite a few of my queries. All the rest already count.

                      But no, the one record should not show up if it does not belong.

                      .
                      Dave Mason
                      [email protected]
                      Skype is dave.mason46

                      Comment


                        #12
                        Re: &lt;tb&gt;.query_create()

                        Dave:
                        Not exactly.
                        It's more like if you attempt to use an array's subelement and the array is empty, alpha gives you an error message.
                        Here if you are not paying attention, you could use values from the wrong record, the first record of the un-filtered table when in reality you souldn't be able to use any values since the query is empty.
                        It should behave the same way an array does.
                        Don't see why you would have to re-write your scripts. I am suggesting that alpha gives you that message when you are writing the code, not when the code is run.
                        Last edited by G Gabriel; 09-21-2008, 08:45 PM.

                        Comment

                        Working...
                        X