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

Help on sql statement

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

    Help on sql statement

    I have a script on a form that runs an SQL statements to ZOOM in to detailed data for a summary record, but I need the WHERE statements to be filtered out to fields that show on the record displayed(summary record) ,
    Do I have to set variables to hold the contents of the fields on the current displayed record ? or is there a more direct way,
    Could the argument be a field name for example ?

    #2
    Re: Help on sql statement

    I am not totally clear on what you are doing, but if I understand properly, you can built a statement that is built on two tables while only selecting fields from one. Then you would be able to use the other table's fields in the WHERE statement.

    If you give us an example of the SQL statement you are trying to create, maybe we can give you more helpful suggestions.

    Howard
    Howard G. Cornett, Independent Consultant

    Comment


      #3
      Re: Help on sql statement

      I need the where statements on an sql statements to use the contents of a field on the form.
      For example if I have a form that is displaying the account number 12345
      I need the sql statements to say "where account = '12345'

      If the record changes on the form and I play the script, the where changes to the new record displayed.

      Comment


        #4
        Re: Help on sql statement

        Please post your script so I can see the context for the SQL statement. Then I should be able to help you further.

        Howard
        Howard G. Cornett, Independent Consultant

        Comment


          #5
          Re: Help on sql statement

          Here's an example that might help. In this case I've simply dimmed the variable in the script, but in your case it already exists for you to reference. I think the main question you have is how to reference the variable value within the SELECT statement.

          Code:
          dim MyFieldVar as c = "Nugget"
          
          sqlStatement = <<%sql%
          SELECT *  FROM pet  WHERE (name = '%sql%
          
          sqlStatement = sqlStatement + MyFieldVar + "')"
          
          flagResult = cn.Execute(sqlStatement)
          -Steve
          sigpic

          Comment


            #6
            Re: Help on sql statement

            Steve;

            How do I reference the variable as the contents of specific field showing in that speceific record.

            I mean for account = 12345 which is displayed as the current record, if I go to record 2 I need that to change to the new content in the where statement.

            A sample data base is attached, the "click for details" button should use the content of the filed Pty_Accnt in the where statement.

            Comment


              #7
              Re: Help on sql statement

              Originally posted by Anis View Post
              I have a script on a form that runs an SQL statements to ZOOM in to detailed data for a summary record, but I need the WHERE statements to be filtered out to fields that show on the record displayed(summary record) ,
              Do I have to set variables to hold the contents of the fields on the current displayed record ? or is there a more direct way,
              Could the argument be a field name for example ?
              you should not have to write any sql.

              consider first the case where your application was based on native a5 tables. the xbasic that you would use to zoom in on a particular record would be something like

              form.viewqueried("formaname","filterexpression")

              where filterexpression is an xbasic filter expression.

              now assume that 'formname' is based on an active link table.

              nothing changes.

              you still use this command to open the 'zoomed' view of a particular record:

              form.viewqueried("formaname","filterexpression")


              filterexpression is still an xbasic filter expression.

              a5 automatically converts 'filterexpression' to a sql filter expression and opens the target form showing the record that you want.

              in other words, you don't have to write any sql yourself.

              Comment


                #8
                Re: Help on sql statement

                Selwyn;

                The form is based on GROUPED records from the original SQL database,
                The detailed button should go back and get the detailed records, that's why I think I need to write the SQL statement.

                The method you suggested brings up the grouped (summary) records for the account.

                Comment


                  #9
                  Re: Help on sql statement

                  I have a 1,000,000 record table and its too slow when I go into the screen based upon a activeSQL table.
                  Is there a trick to opening a screen based upon a large table and not wait forever before I can hit the next record button?
                  greg

                  Comment


                    #10
                    Re: Help on sql statement

                    Originally posted by Anis View Post
                    Selwyn;

                    The form is based on GROUPED records from the original SQL database,
                    The detailed button should go back and get the detailed records, that's why I think I need to write the SQL statement.

                    The method you suggested brings up the grouped (summary) records for the account.
                    i don't have enough details to give you a complete answer, but based on the limited knowledge I have, I assume that you have a form or browse open that is on a record that has a value in some primary key field.

                    you want to then open another form that is filtered on that primary key value.


                    you could define an active link table that uses an argument. for example:


                    select * from mytable where primarykey = :whatkeyvalue


                    next define a form that is based on that active link table.


                    if you try to open that form from the control panel, you will notice that every time you try to open it, you are prompted for the value of whatkey.

                    when you zoom to the detail record, you want to open this form, and pass in the value of the current record primary key value so that there is no prompt.

                    this is done like this:


                    dim args as sql::arguments
                    args.add("whatkeyvalue",---read the value from the current record and set it here---)

                    f = form.view("formaname","","","","",args)

                    Comment


                      #11
                      Re: Help on sql statement

                      Originally posted by gregz View Post
                      I have a 1,000,000 record table and its too slow when I go into the screen based upon a activeSQL table.
                      Is there a trick to opening a screen based upon a large table and not wait forever before I can hit the next record button?
                      greg
                      put an argument in the select statement for the activelink table.
                      then when you open the active-link table, supply the argument value. that will filter the data on the server before any data is transferred to the client.

                      Comment


                        #12
                        Re: Help on sql statement

                        That's exactly what I'm trying to do, now I don't know how to do this part:
                        args.add("whatkeyvalue",---read the value from the current record and set it here---)

                        How do I make the argument a primary key field content ? and how to bypass the prompt on the argument so once you click the script button it excutes the script.

                        Comment


                          #13
                          Re: Help on sql statement

                          Thanks everyone I got it to work.

                          I mapped 5 arguments to field names thru action scripting and I created an active link with detail view.
                          I created a browse on the detail table.
                          I put the script on the summary form, once clicked it opens the detailed browse for the primary keys dispalyed.

                          Comment


                            #14
                            Re: Help on sql statement

                            The problem is I don't know what record the users will want to look for. How can I filter it when the users will perform a search on a field value?
                            The field vaule can not be a primary key due to duplicate entries.
                            Greg

                            Comment


                              #15
                              Re: Help on sql statement

                              Originally posted by gregz View Post
                              The problem is I don't know what record the users will want to look for. How can I filter it when the users will perform a search on a field value?
                              The field vaule can not be a primary key due to duplicate entries.
                              Greg

                              you don't have to know it in advance. at runtime, the user selects something, or presses a button, etc. to open a form or browse that is based on the 1,000,000 row active-link table.

                              at that time, you set the argument value and then open the form or browse, and pass in the argument.

                              you will notice that the form.view() and browse.view() commands now take an optional argument of 'arguments' which allows you to pass in arguments.

                              for example,
                              1. your active link table has this sql statement
                              select * from orders where customerid = :whatcustomer


                              2. in the above sql, 'whatcustomer' is an argument.

                              3. you create a form called "showOrders" that is based on this active link table.

                              4. you have another form that shows a list of customers. this form has a button that opens the "showOrders" form. the control on this form that shows the customerId is called 'objCustId'.

                              5. the code in the button's onPush event is

                              dim custId as c
                              custId = objCustId.text
                              dim args as sql::arguments
                              args.add("whatcustomer",custId)
                              f = form.view("showOrders","","","","",args)


                              (in this example, I have assumed that the customerId field is a character value. It does not have to be. You would need to set the argument value with the correct data type. if it was numeric, for example, you would do this:

                              args.add("whatcustomer", convert_type(custId,"N") )

                              Comment

                              Working...
                              X