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

Can someone test something in AA for MS SQL?

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

    Can someone test something in AA for MS SQL?

    I recently upgraded from a Win 7 machine to Win 10, upgraded from an older version of AA to the current version and upgraded from an old SQL ODBC driver to a new one. Many changes and thus many variables.

    After all of the above I have a few things that no longer work and I am stumped as to why and am looking for someone with a MS SQL server backend to test something.

    I have many passive link tables that use a custom query to retrieve data. These will refresh but will not allow you to successfully edit the data source as it will give me various error messages that rang from :"not connected to data source" or "invalid syntax". Once again, I can right click and refresh without issue.

    The test:

    1. Create a passive table with a simple select statement like below using native syntax for MS SQL server. I just need to group by something and sum a number. This works for me.

    select item,
    sum(qty_shipped) as total_qty
    from sales_table
    group by item


    2. Modify the passive table above to the below. This does not work in the Edit Data Source but works every where else I test it in AA like the SQL command window and every other place I can run a query. Apparently AA does not like the embedded case statement.

    select item,
    sum(case when qty_shipped<100 then qty_shipped else 0 end) as total_qty_lt_100,
    sum(case when qty_shipped>=100 then qty_shipped else 0 end) as total_qty_ge_100,
    from sales_table
    group by item

    Interestingly enough i found this command a5_passiveLinkTableDefine() and i can create the above but it will not let me edit it. The problem with that is it will not let you run a5_passiveLinkTableDefine() using the same table name as it knows the table already exists so you have to delete the table to make change which means you loose any operation, report, etc that you created using the original table you created.

    Thanks in advance.

    #2
    Create a set with only the passive linked table. Put any objects - queries, reports, operations in the set.

    That's been SOP/best practice for a long time.
    Al Buchholz
    Bookwood Systems, LTD
    Weekly QReportBuilder Webinars Thursday 1 pm CST

    Occam's Razor - KISS
    Normalize till it hurts - De-normalize till it works.
    Advice offered and questions asked in the spirit of learning how to fish is better than someone giving you a fish.
    When we triage a problem it is much easier to read sample systems than to read a mind.
    "Make it as simple as possible, but not simpler."
    Albert Einstein

    http://www.iadn.com/images/media/iadn_member.png

    Comment


      #3
      Suggest you submit a bug report.
      Also, when I had a big M/s update today, I was locked IN to a running app which Icouldn't close.
      You could always try duplicating the table and all the attachments and fiddle with that as you will still have the original.
      See our Hybrid Option here;
      https://hybridapps.example-software.com/


      Apologies to anyone I haven't managed to upset yet.
      You are held in a queue and I will get to you soon.

      Comment


        #4
        @Al.
        Does that apply to Active Link tables too?
        See our Hybrid Option here;
        https://hybridapps.example-software.com/


        Apologies to anyone I haven't managed to upset yet.
        You are held in a queue and I will get to you soon.

        Comment


          #5
          i submitted a bug report. the query I am asking someone to test works everywhere except in the create/edit passive table. I can can even preview the result set after I edit but it will not allow me to save it after i previewed. This used to work without an issue and have done it many times and have tables that i copied from my old laptop that have this logic in and I can refresh them i just can't save them after I edit them.

          Comment


            #6
            Look at the documentation about Passive Link Tables. There are options there for editing the scrips.
            See our Hybrid Option here;
            https://hybridapps.example-software.com/


            Apologies to anyone I haven't managed to upset yet.
            You are held in a queue and I will get to you soon.

            Comment


              #7
              I can't find anything. If I could find an Alpha command that would allow you to edit an existing passive table via Xbasic I would be OK. I found how to create one but it does not allow you to edit an existing one.

              Comment


                #8
                I build most passive linked tables with an import operation using AlphaDAO.

                Then you can modify the operation or create xbasic to use in a script or User Defined Function.

                Gives me a lot more options of how to modify what is happening.
                Al Buchholz
                Bookwood Systems, LTD
                Weekly QReportBuilder Webinars Thursday 1 pm CST

                Occam's Razor - KISS
                Normalize till it hurts - De-normalize till it works.
                Advice offered and questions asked in the spirit of learning how to fish is better than someone giving you a fish.
                When we triage a problem it is much easier to read sample systems than to read a mind.
                "Make it as simple as possible, but not simpler."
                Albert Einstein

                http://www.iadn.com/images/media/iadn_member.png

                Comment


                  #9
                  Can you try to build and edit one with a case statement like I mentioned above? It doesn't like the embedded case statement now for some reason.

                  How long does it usually take to get a reply on a bug report?

                  Comment


                    #10
                    AlphaDAO import does the same thing.

                    When I paste the below query in the select records I can preview records and it works but when I click OK I get the error.

                    select item_num,
                    sum(case when qty_shipped<100 then Qty_Shipped else 0 end) as total_qty_lt_100,
                    sum(case when qty_shipped>=100 then Qty_Shipped else 0 end) as total_qty_ge_100
                    from Sales_Transaction_Fact
                    where item_num in ('primpof111','primpof4612') and Invoice_Date_Key between 20200101 and 20200131
                    group by Item_Num

                    sql_preview.pngsql_error.png
                    Attached Files

                    Comment


                      #11
                      Now that we can see the error being supplied by sql server, it would help to see the actual sql code.
                      Gregg
                      https://paiza.io is a great site to test and share sql code

                      Comment


                        #12
                        Hmmmm, I think I have found a work around using AlphaDAO import. I build most of the import using the genie, dump it out as Xbasic, paste my query in the SQLSelect statement, run the script once to create passive table. You can right click to refresh. You can edit the SQLSelect in the script and rerun the script to alter the passive table. Once the table matches the SQLSelect then just right click to refresh or refresh via Xbasic. In a way a pain but in another way better because the SQL is easier to read in script than in the Source Editor. I'm going to tinker with it a little more but I think it's usable.

                        Comment


                          #13
                          Below is the script that works. SQL is in it.

                          dim connectionString as c
                          connectionString = "::Name::dwp"

                          delete options
                          dim options as p
                          options.ConsolidateArguments= .t.
                          options.AddTablesToDatabase= .t.
                          options.ShowProgress= .t.
                          options.AllowCancel= .t.


                          delete a_import
                          dim a_import[0] as p


                          a_import[].ObjectName = "<Custom SQL Query>"
                          a_import[..].SQLSelectStatement = <<%sql%
                          SELECT
                          stf.Source_Id,
                          stf.Company_Num,
                          stf.Customer_Num,
                          cx.Customer_Name,
                          cx.Credit_hold_flag,
                          cx.Sales_Person_1_Key,
                          spd.Sales_Person_Name,
                          stf.Ship_To_Address_Key,
                          cad.address_type,
                          cad.Ship_To_Name,
                          cad.Ship_To_Num,
                          cad.Address_1,
                          cad.Address_2,
                          cad.Address_3,
                          cad.City,
                          cad.State,
                          cad.Zip,
                          Min(stf.Invoice_Date_Key) AS dt_first_sale,
                          Max(stf.Invoice_Date_Key) AS dt_last_sale,
                          Sum(case when dd.year_num=2018 then stf.Extended_Price else 0 end) AS sales_2018,
                          Sum(case when dd.year_num=2018 then (stf.Extended_Price - stf.Extended_Cost)else 0 end) AS gp_2018,
                          Sum(case when dd.year_num=2019 then stf.Extended_Price else 0 end) AS sales_2019,
                          Sum(case when dd.year_num=2019 then (stf.Extended_Price - stf.Extended_Cost)else 0 end) AS gp_2019,
                          Sum(case when dd.year_num=2020 then stf.Extended_Price else 0 end) AS sales_2020,
                          Sum(case when dd.year_num=2020 then (stf.Extended_Price - stf.Extended_Cost)else 0 end) AS gp_2020
                          FROM Sales_Transaction_Fact as stf
                          LEFT OUTER JOIN Customer_Xref as cx
                          on stf.source_id=cx.source_id and stf.company_num=cx.company_num and stf.customer_num=cx.customer_num
                          LEFT OUTER JOIN Sales_Person_Dim as spd
                          ON cx.Sales_Person_1_Key = spd.Sales_Person_Key
                          LEFT OUTER JOIN Customer_Address_Dim as cad
                          ON stf.Ship_To_Address_Key = cad.Customer_Address_Key
                          LEFT OUTER JOIN Company_Dim as cd
                          ON stf.Company_Key = cd.Company_Key
                          INNER JOIN Date_Dim as dd
                          ON stf.Invoice_Date_Key = dd.Date_Key
                          where stf.Source_Id='aplus'
                          GROUP BY
                          stf.Source_Id,
                          stf.Company_Num,
                          stf.Customer_Num,
                          cx.Customer_Name,
                          cx.Credit_hold_flag,
                          cx.Sales_Person_1_Key,
                          spd.Sales_Person_Name,
                          stf.Ship_To_Address_Key,
                          cad.address_type,
                          cad.Ship_To_Name,
                          cad.Ship_To_Num,
                          cad.Address_1,
                          cad.Address_2,
                          cad.Address_3,
                          cad.City,
                          cad.State,
                          cad.Zip
                          %sql%
                          a_import[..].SQLType = "Native"
                          a_import[..].Arguments = ""
                          a_import[..].ImportType = "Create passive-link table"
                          a_import[..].LocalTableName = a5.get_path() + chr(92) + "sql_test_4"+".dbf"
                          a_import[..].LocalTableFieldDef = ""
                          a_import[..].OverwriteOption = "Overwrite without prompting"


                          dim flagSilent as l
                          delete args
                          dim args as sql::arguments
                          flagSilent = .f.
                          delete p
                          dim p as p

                          p = a5_AlphaDAO_Import(connectionString,a_import,options,flagSilent,args)
                          'p has an .hasError and .errorText property
                          'a_import[] has the following properties for each item: .countRecordsImported, .hasError, .errorText, .userCancelled


                          Comment


                            #14
                            I am pretty sure that message is not valid because i execute the query in a number of places, SSMS for sure, and MS SQL executes it without hesitation. I am 99.9% sure the query or the server are not the problem.

                            Thanks!!

                            Comment


                              #15
                              Sorry about that...I was hoping to see the code under the error.
                              With that said, are there any rows with null values in the column(s) you're using in the statement.
                              I can experiment, but it would really be helpful to have your data, and preferably the create table
                              definition for the table involved.
                              Gregg
                              https://paiza.io is a great site to test and share sql code

                              Comment

                              Working...
                              X