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

UNION QUERY not acting same in Alpha as in SQLServer

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

    UNION QUERY not acting same in Alpha as in SQLServer

    I have a UNION query that runs just fine in SQLServer query window, but when I run it in alpha at the SQL Command window or in XBasic with and execute, it only does the second part (after the UNION). It does not give an error of any kind, it just does not return the data from the first part of the query (part before UNION).

    SELECT h.TBL_ID, h.TRIBE_NUM as Tribe, h.DEALER_LICENSE_ID as Dealer, d.SPECIES_CODE as Species, d.CATCH_AREA_CODE as Catch_Area, SUM(RPTD_CNT) as Units, SUM(RPTD_LBS_QTY) as Pounds, COUNT(DISTINCT FISH_TICKET_NUM) as Ticket_Count, Count(Distinct INDIAN_ID) as Effort_Fisherman FROM TICKET_MASTER_VIEW h LEFT JOIN TICKET_DETAIL_VIEW d ON h.FISH_TICKET_ID = d.FISH_TICKET_ID WHERE h.fisher_type_code in ('1','2','5') AND d.SPECIES_CODE in ('001','002','003','004','005','006') AND h.TRIBE_NUM in ('28','29','31') AND h.FISHER_TYPE_CODE = '2' AND h.tribe_num IN (SELECT tribe_code FROM tocas_dba.user_tribe WHERE username = 'dholmgren') GROUP BY h.TBL_ID,h.TRIBE_NUM,h.DEALER_LICENSE_ID,d.SPECIES_CODE,d.CATCH_AREA_CODE
    UNION
    SELECT h.TBL_ID, h.TRIBE_NUM as Tribe, h.DEALER_LICENSE_ID as Dealer, d.SPECIES_CODE as Species, d.CATCH_AREA_CODE as Catch_Area, SUM(RPTD_CNT) as Units, SUM(RPTD_LBS_QTY) as Pounds, COUNT(DISTINCT FISH_TICKET_NUM) as Ticket_Count, Count(Distinct INDIAN_ID) as Effort_Fisherman FROM TICKET_MASTER_VIEW h LEFT JOIN TICKET_DETAIL_VIEW d ON h.FISH_TICKET_ID = d.FISH_TICKET_ID WHERE h.fisher_type_code in ('1','2','5') AND d.SPECIES_CODE in ('001','002','003','004','005','006') AND h.TRIBE_NUM in ('28','29','31') AND h.FISHER_TYPE_CODE = '2' AND h.tribe_num NOT IN (SELECT tribe_code FROM tocas_dba.user_tribe WHERE username = 'dholmgren') GROUP BY h.TBL_ID,h.TRIBE_NUM,h.DEALER_LICENSE_ID,d.SPECIES_CODE,d.CATCH_AREA_CODE ORDER BY h.TRIBE_NUM,h.DEALER_LICENSE_ID,d.SPECIES_CODE,d.CATCH_AREA_CODE;

    Any ideas? Has anybody else run into this?

    #2
    Re: UNION QUERY not acting same in Alpha as in SQLServer

    Try turning off portable SQL... I believe this has worked for me in the past...

    Code:
    cn.PortableSQLEnabled = .f.

    Comment


      #3
      Re: UNION QUERY not acting same in Alpha as in SQLServer

      Tried that - did not work.

      Comment


        #4
        Re: UNION QUERY not acting same in Alpha as in SQLServer

        Solved the problem in XBasic by breaking into two querys and running them separately. Am still curious as to why, even in the SQL Command window, it ignores/mis-runs UNIONs. Can't put them in grids either - tried that too.

        Comment


          #5
          Re: UNION QUERY not acting same in Alpha as in SQLServer

          I run a SQL Statement with 2 Unions... had the same issue as you until I turned off portable sql. It ran fine under MySQL, but not Alpha. I figured I'd have to do the same... split it into 3 statements... which would have been ok... but didn't need to.

          Comment


            #6
            Re: UNION QUERY not acting same in Alpha as in SQLServer

            Why don't you just create a sql view using the query then using that view for your data source.
            Win 10 64 Development, Win 7 64 WAS 11-1, 2, Win 10 64 AA-1,2, MySql, dbForge Studio The Best MySQL GUI Tool IMHO. http://www.devart.com/dbforge/mysql/studio/

            Comment


              #7
              Re: UNION QUERY not acting same in Alpha as in SQLServer

              Frank,
              Because user is building the query by selecting fields and where criteria and then the program adds part of the where clause and a union or not union based on who logged in. Some users are allowed only data for certain criteria (not their tribe) and all data for other criteria (their tribe). Other users are allowed all data (don't need union).

              Comment


                #8
                Re: UNION QUERY not acting same in Alpha as in SQLServer

                I tried a MySQL View, 3 Selects with 2 Unions. Ran fine under Navicat, but not as the source for a List. Part of the challenge is parameters for the view.

                Comment


                  #9
                  Re: UNION QUERY not acting same in Alpha as in SQLServer

                  I have several grids with the data source from MySql views using unions and they run fine. I can't see why it would be a problem for lists, I have not tried it myself.
                  Win 10 64 Development, Win 7 64 WAS 11-1, 2, Win 10 64 AA-1,2, MySql, dbForge Studio The Best MySQL GUI Tool IMHO. http://www.devart.com/dbforge/mysql/studio/

                  Comment


                    #10
                    Re: UNION QUERY not acting same in Alpha as in SQLServer

                    My View has 3 Selects with a WHERE clause per select. Part of the WHERE clause is static... e.g. WHERE flag <> 0. But a 2nd part of the WHERE clause is variable based on a Login UserId. When I take the variable part of the Select out of the View and use a Filter in the List then I do not get all the records I should be getting. If I leave the UserId WHERE clause in the View and assign a static value to it, and remove the Filter from the List, the View does return all records. To work around this I use a Custom XBasic function to feed the List.

                    Comment


                      #11
                      Re: UNION QUERY not acting same in Alpha as in SQLServer

                      David couldn't you return all the records in the view and then filter it in the list or grid as in my case. This works for me.
                      Win 10 64 Development, Win 7 64 WAS 11-1, 2, Win 10 64 AA-1,2, MySql, dbForge Studio The Best MySQL GUI Tool IMHO. http://www.devart.com/dbforge/mysql/studio/

                      Comment


                        #12
                        Re: UNION QUERY not acting same in Alpha as in SQLServer

                        Too many records to return. Even with a reduced test database there are 788 records in total, which get filtered down to about between 2 and 5 records I need to display. No reason to return hundreds of records. If I had no other choice then I'd have to live with it. But using a Custom data source for the List allows me to build a filtered Select with Unions and returns the few records I want.

                        Comment


                          #13
                          Re: UNION QUERY not acting same in Alpha as in SQLServer

                          My view if looked at through dbForge Studio may have thousands of records. In my grid query if I use (select blah from view where blahblah = useid) I only get the records that meet the where clause thousands are not sent to the grid. Lightning fast. MySql is handling much of the load in the background.
                          Win 10 64 Development, Win 7 64 WAS 11-1, 2, Win 10 64 AA-1,2, MySql, dbForge Studio The Best MySQL GUI Tool IMHO. http://www.devart.com/dbforge/mysql/studio/

                          Comment


                            #14
                            Re: UNION QUERY not acting same in Alpha as in SQLServer

                            Sorry... I thought you were suggesting returning all records in the view and doing a filter at the client side. I understand now that you meant passing the filter, via Alpha, in the server side and having the view return filtered data, not all data. That's what I'd originally tried, but not all relevant records were returned.

                            Here's a pseudo example of my view...

                            Select fields from from table1
                            LEFT OUTER JOIN table2 on table1_field = table2_field
                            WHERE loginId = "myLogin"

                            UNION ALL

                            Select fields from from table3
                            LEFT OUTER JOIN table4 on table3_field = table4_field
                            LEFT OUTER JOIN table5 on table3_field = table5_field
                            WHERE loginId = "myLogin" AND otherfield = 0

                            UNION ALL

                            Select fields from from table6
                            LEFT OUTER JOIN table7 on table6_field = table7_field
                            LEFT OUTER JOIN table8 on table6_field = table8_field AND table8_field = table6_field
                            WHERE loginId = "myLogin" AND otherfield <> 0

                            Under Navicat this produces, for example, 5 records

                            With the WHERE loginId = "myLogin" statements removed from the View, and then a filter used in the List control, the View returns 2 records.

                            I haven't looked yet to see the statement produced by Alpha but I believe the WHERE clause is being applied globally to the View. This makes sense... how would Alpha know to apply the filter any other way.

                            I wanted to use parameters with the View but they're too tough to work with... not worth the effort since the List can take a Custom XBasic function as it's source.

                            Comment


                              #15
                              Re: UNION QUERY not acting same in Alpha as in SQLServer

                              David, I can't imagine why your getting that result. I have not tried union views with a list yet. My lists using non union views including updatable seem to work well.

                              Consider this view

                              Table_1 Table_2 Table_3
                              Name ID Name ID Name ID
                              Joe 1 Tom 1 Sue 2
                              Bob 2 Dave 3 Diane 3
                              Bill 3 Steve 1 Fran 3
                              Jane 4

                              view_1 code;
                              Select name, id From table_1
                              union
                              select name, id from table_2
                              union
                              select name id from table_3

                              would yield

                              view_1 data;
                              name id
                              Joe 1
                              Bob 2
                              Bill 3
                              Jane 4
                              Tom 1
                              Dave 3
                              Steve 1
                              Sue 2
                              Diane 3
                              Fran 3

                              In a grid
                              select name, id from view_1 where id = 3 as the datasource would yield
                              name id
                              Bill 3
                              Dave 3
                              Diane 3
                              Fran 3
                              Win 10 64 Development, Win 7 64 WAS 11-1, 2, Win 10 64 AA-1,2, MySql, dbForge Studio The Best MySQL GUI Tool IMHO. http://www.devart.com/dbforge/mysql/studio/

                              Comment

                              Working...
                              X