Results 1 to 3 of 3

Thread: SQL query on Oracle DB

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Sep 2004
    Posts
    16

    SQL query on Oracle DB

    Hi!

    I have some problems with running an SQL-query on an Oracle db in VB
    I've run the following query in Oracle SQL*Plus, which went just fine.

    SQL> SELECT Min(pt.A_DATE)
    FROM APP.PROJECT_TRANSACTION pt,APP.ACT a, APP.PROJ p
    WHERE pt.ACT_SEQ = a.ACT_SEQ
    AND pt.PROJ_ID = a.PROJ_ID
    AND pt.SUB_ID = a.SUB_ID
    AND pt.ACT_NO = a.ACT_NO
    AND pt.PROJ_ID = p.PROJ_ID

    ----------
    2003-08-04


    I'm trying to run the same query in VBA, where I get the error message: Invalid Character.
    There's nothing wrong with the connection to the oracle DB, cos I can run the query if I only use the first 2 rows.
    But when I add the where-statement I get the error-message. Have I missed something in the syntax, I'm just trying to connect a couple of tables.


    connection1 = "Provider=MSDAORA.1;" & _
    "Data Source=A;" & _
    "User Id=AB;" & _
    "Password=AB"

    Set oCn1 = New ADODB.Connection
    oCn1.Open connection1

    szSQL = "SELECT Min(pt.A_DATE)" & _
    "FROM APP.PROJECT_TRANSACTION pt,APP.ACT a, APP.PROJ p" & _
    "WHERE pt.ACT_SEQ = a.ACT_SEQ" & _
    "AND pt.PROJ_ID = a.PROJ_ID" & _
    "AND pt.SUB_ID = a.SUB_ID" & _
    "AND pt.ACT_NO = a.ACT_NO" & _
    "AND pt.PROJ_ID = p.PROJ_ID;"


    Set oRs1 = New ADODB.Recordset
    oRs1.Open szSQL, oCn1, adOpenForwardOnly, adLockReadOnly, adCmdText


    /Bjso

  2. #2
    Hyperactive Member
    Join Date
    Aug 2004
    Location
    Bloomingdale, IL USA
    Posts
    284
    Just a guess, but it looks like you don't have any spaces separating the lines. Try this.


    szSQL = "SELECT Min(pt.A_DATE)" & _
    " FROM APP.PROJECT_TRANSACTION pt,APP.ACT a, APP.PROJ p" & _
    " WHERE pt.ACT_SEQ = a.ACT_SEQ" & _
    " AND pt.PROJ_ID = a.PROJ_ID" & _
    " AND pt.SUB_ID = a.SUB_ID" & _
    " AND pt.ACT_NO = a.ACT_NO" & _
    " AND pt.PROJ_ID = p.PROJ_ID;"

  3. #3

    Thread Starter
    Junior Member
    Join Date
    Sep 2004
    Posts
    16
    Thanks, that was it.

    bjso

Posting Permissions

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



Click Here to Expand Forum to Full Width