?
Solved

VB6 - Query from Oracle in apprilication issue

Posted on 2014-02-16
3
Medium Priority
?
334 Views
Last Modified: 2014-02-16
HI all

I have this below SQL that work great in Oracle.

But when i want pull the extract from my VB6 app and get the result inside my MSHFlexgrid2, i have a Compile error, syntax error.

Would you know why?

Thanks again for your help

SQL in app:
Dim oconn As New ADODB.Connection
    Dim rs As New ADODB.Recordset
    Dim strSQL As String

    strSQL = "SELECT DC, STORE_NUM, PICK_DC, RECEIVE_DC, LANE_NUM, RTRIM( " & _
             "EXTRACT( XMLAGG( XMLELEMENT( "x", RELEASE_DAY || ',' || ARRIVE_DAY " & _
             "|| ',' || RECEIVE_ARRIVE_OPEN || ',' || RECEIVE_ARRIVE_CLOSE || ',' ) " & _
             "ORDER BY RELEASE_DAY, ARRIVE_DAY, RECEIVE_ARRIVE_OPEN, RECEIVE_ARRIVE_CLOSE ), '/x/text()' ).GETSTRINGVAL(), " & _
             "','  ) X FROM (SELECT A.PICK_DC AS DC, A.STORE_NUM, C.PICK_DC, C.RECEIVE_DC, C.SHIP_DAY AS RELEASE_DAY, C.ARRIVE_DAY, " & _
             "C.RECEIVE_ARRIVE_OPEN, C.RECEIVE_ARRIVE_CLOSE, C.LANE_NUM FROM LCLRPT.DC_STORE_SETTINGS A, LCLRPT.LCL_STORE_LANE_REF B, LCLRPT.XD_LANES C " & _
             "WHERE A.DC_STORE_SETTINGS_SEQ_NUM= B.DC_STORE_SETTINGS_SEQ_NUM AND B.LANE_NUM= C.LANE_NUM AND B.LANE_GROUP=0) GROUP BY DC, " & _
             "STORE_NUM, PICK_DC, RECEIVE_DC, LANE_NUM"

    Set oconn = New ADODB.Connection
    oconn.Open "Provider=OraOLEDB.Oracle.1;Data Source=xxxxx;User Id=xxxxx;Password=xxxxx;"
    rs.CursorType = adOpenStatic
    rs.CursorLocation = adUseClient
    rs.LockType = adLockOptimistic
    rs.Open strSQL, oconn, adCmdText
    Set MSHFlexGrid2.DataSource = rs

    rs.Close
    oconn.Close
    Set rs = Nothing
    Set oconn = Nothing

Open in new window


SQL that works in Oracle Dev.
SELECT DC,
         STORE_NUM,
         PICK_DC,
         RECEIVE_DC,
         LANE_NUM,
         RTRIM(
             EXTRACT(
                 XMLAGG(
                     XMLELEMENT(
                         "x",
                            RELEASE_DAY
                         || ','
                         || ARRIVE_DAY
                         || ','
                         || RECEIVE_ARRIVE_OPEN
                         || ','
                         || RECEIVE_ARRIVE_CLOSE
                         || ','   
                     )
                     ORDER BY
                         RELEASE_DAY,
                         ARRIVE_DAY,
                         RECEIVE_ARRIVE_OPEN,
                         RECEIVE_ARRIVE_CLOSE
                 ),
                 '/x/text()'
             ).GETSTRINGVAL(),
             ','    
         )
             X
    FROM (SELECT
    A.PICK_DC AS DC,
    A.STORE_NUM,
    C.PICK_DC,
    C.RECEIVE_DC,
    C.SHIP_DAY AS RELEASE_DAY,
    C.ARRIVE_DAY,
    C.RECEIVE_ARRIVE_OPEN,
    C.RECEIVE_ARRIVE_CLOSE,
    C.LANE_NUM
FROM
    LCLRPT.DC_STORE_SETTINGS A, LCLRPT.LCL_STORE_LANE_REF B, LCLRPT.XD_LANES C
WHERE
    A.DC_STORE_SETTINGS_SEQ_NUM= B.DC_STORE_SETTINGS_SEQ_NUM
    AND B.LANE_NUM= C.LANE_NUM
    AND B.LANE_GROUP=0)
GROUP BY DC,
         STORE_NUM,
         PICK_DC,
         RECEIVE_DC,
         LANE_NUM;

Open in new window

0
Comment
Question by:Wilder1626
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 143

Expert Comment

by:Guy Hengel [angelIII / a3]
ID: 39863051
first some tip: as the query has no parameters, I usually would put the query into a view (in oracle), and your application will then only have to do:
SELECT * FROM VIEW_NAME

this will solve a couple of issues, the main one being to remove all the (complex) sql stuff from the actual application code. others are that you will give the power to the dba to eventually optimize the sql (view) without having the application to be recompiled and redistributed.

let me check what the error could be, meanwhile
0
 
LVL 143

Accepted Solution

by:
Guy Hengel [angelIII / a3] earned 2000 total points
ID: 39863056
now, I see the issue:

... XMLELEMENT( "x", ...

inside your string declaration would need to be:
XMLELEMENT( ""x"",

as the " is already the string delimiter (in vb), to use the " inside the string, you need to duplicate it.
0
 
LVL 11

Author Closing Comment

by:Wilder1626
ID: 39863100
You are right.

Thanks a lot. It's working now.
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Occasionally there is a need to clean table columns, especially if you have inherited legacy data. There are obviously many ways to accomplish that, including elaborate UPDATE queries with anywhere from one to numerous REPLACE functions (even within…
In part one, we reviewed the prerequisites required for installing SQL Server vNext. In this part we will explore how to install Microsoft's SQL Server on Ubuntu 16.04.
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Suggested Courses

650 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question