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

sql query

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

    sql query

    Has anyone figured out how to query an SQL database via ODBC with Alpha 5? Thanks in advance for any help or suggestions.

    #2
    RE: sql query

    We do copy from ODBC linked tables (Oracle), append from ditto, can browse an ODBC table and perform query by table, query genie works, etc.

    Not understanding "SQL Database". SQL Server is an ODBC driver. You need to know the native type of the tables to be accessed.

    Are you having trouble linking to the ODBC tables? Querying once linked?
    There can be only one.

    Comment


      #3
      RE: sql query

      Jeff and Stan,

      Stan, SQL database makes perfect sense (MS SQL I presume). But, Jeff, I tried and failed and gave up when I figured out (possibly erroneously) that it ain't possible. Maybe if Alpha supported SQL queries, but otherwise I don't think so. A5 ODBC with SQL just doesn't seem to give much in the way of power.

      But remember, I gave it up, so don't try to take this to the bank.

      Ray Lyons

      Comment


        #4
        RE: sql query

        If I understand what is "supposed" to happen, and that's not all that often anymore, it is that the .ini file you use to link to the ODBC table performs translations of Alpha query syntax into the appropriate SQL syntax.

        If you look at the mssqlsrv.ini you find:

        AppendAll = INSERT INTO %s ( %s ) %s SELECT %s FROM %s

        I'm no rocket scientist, not even much of a programmer, but the second part looks like SQL to me.

        So if you need to tinker with Alpha's capabilities, wouldn't you modify this .ini? The header for the .ini file calls it a generic driver, suggesting that it could be tailored to more specific needs.

        I know such modification is beyond me. Who's our SQL expert out there?
        There can be only one.

        Comment


          #5
          RE: sql query

          Ray and Stan -

          Thank you for your responses. Ray, you are correct, the SQL Database is MS SQL running on a Win 2000 Server. Our link thru ODBC "works". Here is the interesting thing. When I give a query a specific part # to find, the query works. When I give the query a variable, it does not. For example:

          Let's say I want to find our Product Code A111 from SQL table dbo_stone_product.

          This works:

          tbl = table.open("dbo_stone_product")
          query.description = "SQL Query"
          query.filter = "stone_id = 'A111'"
          query.options = ""
          indx = tbl.query_create()

          This fails:

          DIM SHARED prod AS C
          prod = "A111"
          tbl = table.open("dbo_stone_product")
          query.description = "SQL Query"
          query.filter = "stone_id = var->prod"
          query.options = ""
          indx = tbl.query_create()

          Variables seem to throw SQL into a tizzy and I have not been able to find a way around it. So how does one accept a product code from, say, a ui_get_text and find the product from the SQL database?

          Jeff

          Comment


            #6
            RE: sql query

            Stan -

            You are correct that the "AppendAll" is SQL syntax. I used SQL many years ago in a UNIX environment, so I'm going to have to dig out my old manuals and refresh my SQL knowledge. I'm also going to take a look at mssqlserv.ini, which I haven't done yet.

            Thanks for the pointer.

            Jeff

            Comment


              #7
              RE: sql query

              Jeff,

              You need to concatonate text strings to build your filter. Modifying your second example, it would be;


              DIM SHARED prod AS C
              prod = "A111"
              tbl = table.open("dbo_stone_product")
              query.description = "SQL Query"
              query.filter = "stone_id = '"+var->prod+"'"
              query.options = ""
              indx = tbl.query_create()

              The above yields a query.filter equal to

              "stone_id = 'A111'"

              Don't try to use Alpha constructs in SQL is the general suggestion. Instead convert them to something that SQL will accept.

              Regards,

              Ira J. Perlow
              Computert Systems Design & Associates
              [email protected]
              Regards,

              Ira J. Perlow
              Computer Systems Design


              CSDA A5 Products
              New - Free CSDA DiagInfo - v1.39, 30 Apr 2013
              CSDA Barcode Functions

              CSDA Code Utility
              CSDA Screen Capture


              Comment


                #8
                RE: sql query

                Thanks,

                I needed that!
                There can be only one.

                Comment


                  #9
                  RE: sql query

                  Actually I need more than that.

                  I use the following filter in a saved copy operation against an Oracle table. (manually editing the "Wk_num" each week.

                  Sku_Num0.or.Tot_Cst0.or.Tot_Qty0).and.(Yr=2001.and.between(Wk_Num,14,18))

                  I'd like to create global variables for the form containing the button used to run the operation, use the variables in the operation, but I get an Oracle, missing expression when I try...

                  Sku_Num0.or.Tot_Cst0.or.Tot_Qty0).and.(Yr=2001.and.between(Wk_Num,var->beg_wk,var->end_wk))

                  where beg_wk and end_wk are global form variables.

                  Any thoughts?

                  Thanks in advance.
                  There can be only one.

                  Comment


                    #10
                    RE: sql query

                    Ira -

                    Thank you, thank you, thank you. That did the trick!

                    Jeff

                    Comment


                      #11
                      RE: sql query

                      Stan Mathews wrote:

                      This isn't rocket science, but here it is,

                      query.filter="Sku_Num0.or.Tot_Cst0.or.Tot_Qty0).and.(Yr=2001.and.between(Wk_Num,"+LTRIM(STR(var->beg_wk))+","+LTRIM(STR(var->end_wk))+"))"

                      Basically, just concatonating strings that look like constants in the expression string. This is a really important concept that is used throughout A5, so try to understand what it is I'm doing.

                      Regards,

                      Ira J. Perlow
                      Computert Systems Design & Associates
                      [email protected]
                      Regards,

                      Ira J. Perlow
                      Computer Systems Design


                      CSDA A5 Products
                      New - Free CSDA DiagInfo - v1.39, 30 Apr 2013
                      CSDA Barcode Functions

                      CSDA Code Utility
                      CSDA Screen Capture


                      Comment


                        #12
                        RE: sql query

                        Ira,

                        As always I appreciate your help. I understand the concept in general. Applying it specifically is not always as clear.

                        Also I was trying to use an expression in the filter builder for a saved operation. This may or may not be possible. I've converted the saved operation to xbasic via the script recorder and it's runnning now -- no Oracle errors.

                        Now it has completed and the results are as desired...

                        Thanks again.

                        Stan
                        There can be only one.

                        Comment

                        Working...
                        X