Page 1 of 3 123 LastLast
Results 1 to 10 of 22

Thread: SQLExecutor Problem

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Mar 2009
    Location
    Cumming, Georgia USA
    Posts
    1,876

    Default SQLExecutor Problem

    Testing the new SQLExecutor with MYSQL Database. I have this in an text file with "Include_Text" as a Constant:

    SELECT Name, M_Addr, M_City, M_St, M_Zipcode
    FROM BillInfo WHERE M_City = ${City} AND M_St = ${State}

    It works fine in the Studio with the "Prepare" and "Execute" in the SQLTester. However, when I run it in my program is does not work. Here is the code in my "wo":

    WebGet psValue of oCitySel to sCity
    WebGet psValue of oStateSel to sState

    Send SQLPrepare of ghoSQLExecutor C_SQLBillInfoList
    Send SQLSetParameter of ghoSQLExecutor "City" sCity
    Send SQLSetParameter of ghoSQLExecutor "State" sState
    Get SQLExecute of ghoSQLExecutor to aTheRows

    I get no Rows! What is my problem?

  2. #2
    Join Date
    Feb 2009
    Location
    Brazil
    Posts
    5,280

    Default Re: SQLExecutor Problem

    you get no errors ? please check the err global variable after each of those 4 commands..

    In my opinion the single quotes ' ' , surrounding each parameter is missing..

    Code:
    WHERE M_City = '${City}' AND M_St = '${State}'
    


    Now, how does it work when running from SQLTester, I don't know, as it should also fail.., unless you are providing them with the value when running with the Sqltester, and missing the quotes when running from your code.
    Samuel Pizarro

  3. #3
    Join Date
    Mar 2009
    Location
    Cumming, Georgia USA
    Posts
    1,876

    Default Re: SQLExecutor Problem

    No Errors! It works fine as I said in the SQLExecutor in the Studio. I had already tried putting the quotes around the variables with no success.

  4. #4
    Join Date
    Feb 2009
    Location
    Adelaide, South Australia
    Posts
    2,812

    Default Re: SQLExecutor Problem

    Should you specify the schema/owner?
    Perhaps you use a different user between your studio and your app?
    Marco Kuipers
    DataFlex Consultant
    28 IT Pty Ltd - DataFlex Specialist Consultancy
    DataFlex Channel Partner for Australia and Pacific region
    Adelaide, South Australia
    www.28it.com.au

  5. #5
    Join Date
    Mar 2009
    Location
    Cumming, Georgia USA
    Posts
    1,876

    Default Re: SQLExecutor Problem

    No, my application works fine other than this view.

    This code works only when both parameters are blank! (It does work in the Studio!!)

    Code:
    SELECT Name, M_Addr, M_City, M_St, M_Zipcode
    FROM BillInfo
    WHERE CASE
       WHEN ${State} <> '' AND ${City} <> '' THEN M_City = ${City} AND M_St = ${State}
       WHEN ${State} <> '' AND ${City} = '' THEN M_St = ${State}
       WHEN ${State} = '' AND ${City} <> '' THEN M_City = ${City}
       ELSE M_City > '' AND M_St > ''
    END
    ORDER BY CASE
       WHEN ${State} = '' THEN M_St
       ELSE Name
    END, Name

  6. #6
    Join Date
    Feb 2009
    Location
    Florida, USA
    Posts
    637

    Default Re: SQLExecutor Problem

    Hi Sam,

    What version of MySQL/ODBC Connector are you using? If you can, attach a simplified version of your WO that shows the problem so we can see what else your wo is doing. For example, in your code, are you setting the connection to the correct database? Also, have you tried including the query directly in your code instead of using include_text?
    Regards,

    Marcia Booth (DAW)

  7. #7
    Join Date
    Mar 2009
    Location
    Cumming, Georgia USA
    Posts
    1,876

    Default Re: SQLExecutor Problem

    There is only one database in the SQL Server, ODBC 8.0.
    The "CASE" statement appears to be the problem. Works in the SQLTester, not in program as a string or constant in a text file.

    In WebApp.src:

    Object oSQLExecutor is a cSQLExecutor
    Move Self to ghoSQLExecutor

    Set psConnectionId to "MrLoadID"
    End_Object


    In the view:

    Include_Text BillInfoList.sql as C_SQLBillInfoList

    BillInfoList.sql contains:

    SELECT Name, M_Addr, M_City, M_St, M_Zipcode
    FROM BillInfo
    WHERE M_City = ${City} AND M_St = ${State}
    ORDER BY M_St, M_City

    This works as a string and in the text file:

    Send SQLPrepare of ghoSQLExecutor C_SQLBillInfoList (or sQuery when testing as a string)
    Send SQLSetParameter of ghoSQLExecutor "City" sCity
    Send SQLSetParameter of ghoSQLExecutor "State" sState
    Get SQLExecute of ghoSQLExecutor to aTheRows


    This works in the SQLTester but not in the program as a string or from the text file:

    SELECT Name, M_Addr, M_City, M_St, M_Zipcode
    FROM BillInfo
    WHERE CASE
    WHEN ${State} <> '' THEN M_City = ${City} AND M_St = ${State}
    END
    ORDER BY M_St, M_City

  8. #8
    Join Date
    Feb 2009
    Location
    Stuart, FL
    Posts
    5,291

    Default Re: SQLExecutor Problem

    how about using the query analyzer to see what the query actually looks like
    Michael Salzlechner
    StarZen Technologies, Inc
    http.://www.starzen.com

    IT Director at Balloons Everywhere

    Development Blog
    http://www.salzlechner.com/dev

    DataFlex Package Manager (aka Nuget for DataFlex)
    http://windowsdeveloper.com/dfPackage

  9. #9
    Join Date
    Mar 2009
    Location
    Cumming, Georgia USA
    Posts
    1,876

    Default Re: SQLExecutor Problem

    Using MySQL, each time I try to "Prepare" with the following Query in the Query Tester the Studio closes!! I think there is a big problem with Case statements!

    SELECT Name, M_Addr, M_City, M_St, M_Zipcode
    FROM BillInfo
    WHERE 1 = (CASE WHEN ${State} <> '' AND M_St = ${State} THEN 1 WHEN ${State} = '' THEN 1 End) AND
    1 = (CASE WHEN ${City} <> '' AND M_City = ${City} THEN 1 WHEN ${City} = '' THEN 1 End)

  10. #10
    Join Date
    Mar 2009
    Location
    Cumming, Georgia USA
    Posts
    1,876

    Default Re: SQLExecutor Problem

    This works:

    Move (SFormat("SELECT Name, M_Addr, M_City, M_St, M_Zipcode from BillInfo WHERE 1 = (Case WHEN '%1' <> '' and M_St = '%1' THEN 1 WHEN '%1' = '' THEN 1 End) and",sState,sCity)) to sQuery
    Move (Append(sQuery, SFormat(" 1 = (CASE WHEN '%2' <> '' AND M_City = '%2' THEN 1 WHEN '%2'= '' THEN 1 End) ORDER BY CASE WHEN '%1' = '' THEN M_St ELSE Name End, Name", sState, sCity))) to sQuery

    Get SQLExecDirect of ghoSQLExecutor sQuery to aTheRows

Page 1 of 3 123 LastLast

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •