G
Greg Strong
Hello All,
What is the maximum length of an ODBC pass through query?
Things work fine with the code except when I try to create a view which
is pretty complex in Oracle. I'm using a DSN provided with the Oracle
Express Edition and using Access 2k2 as the front-end. When I debug
print the SQL and paste it into SQLplus it works fine. The length of
the debug print that works is 1988 characters. Since the exact same
code works with shorter SQL I'm guessing there is a max length to the
string that can be passed which is why I asked the question. Error
reads:
,----- [ Error on PTQ ]
| Run-time error '3146'
| ODBC-call failed.
`-----
The code is included below. Any ideals. Thanks!
=====================>Begin Code>===================================>
Sub Create_vw_tblOrdersCurYr_rev2()
Dim wsCur As DAO.Workspace
Dim dbCur As DAO.Database
Dim qdfPassThrew As DAO.QueryDef
Dim strSQL As String
Set wsCur = DBEngine.Workspaces(0)
Set dbCur = wsCur.Databases(0)
Call SetConStr
strSQL = "CREATE OR REPLACE VIEW sc.vw_tblOrdersCurYr_rev2 AS " & _
"SELECT OrderNo, PdNewOrder, EstRev, EstCGS, " & _
"case when (substr(BusCode,-3) between 100 and 199) then " &
Chr(39) & "BU" & Chr(39) & "||" & Chr(39) & "1" & Chr(39) & " when
(substr(BusCode,-3) between 200 and 299) then " & Chr(39) & "BU" &
Chr(39) & "||" & Chr(39) & "2" & Chr(39) & " when (substr(BusCode,-3)
between 300 and 399) then " & Chr(39) & "BU" & Chr(39) & "||" & Chr(39)
& "3" & Chr(39) & " end as BusUnit, " & _
"case when Length(MktCode) = 4 then case when
(substr(MktCode,-2) between 10 and 19) then " & Chr(39) & "VM" & Chr(39)
& "||" & Chr(39) & "1" & Chr(39) & " when (substr(MktCode,-2) between 20
and 29) then " & Chr(39) & "VM" & Chr(39) & "||" & Chr(39) & "2" &
Chr(39) & " when (substr(MktCode,-2) between 30 and 39) then " & Chr(39)
& "VM" & Chr(39) & "||" & Chr(39) & "3" & Chr(39) & " when
(substr(MktCode,-2) between 40 and 49) then " & Chr(39) & "VM" & Chr(39)
& "||" & Chr(39) & "4" & Chr(39) & " when (substr(MktCode,-2) between 50
and 59) then " & Chr(39) & "VM" & Chr(39) & "||" & Chr(39) & "5" &
Chr(39) & " when (substr(MktCode,-2) between 60 and 69) then " & Chr(39)
& "VM" & Chr(39) & "||" & Chr(39) & "6" & Chr(39) & " when
(substr(MktCode,-2) between 70 and 79) then " & Chr(39) & "VM" & Chr(39)
& "||" & Chr(39) & "7" & Chr(39) & " when (substr(MktCode,-2) between 80
and 89) then " & Chr(39) & "VM" & Chr(39) & "||" & Chr(39) & "8" &
Chr(39) & " when (substr(MktCode,-2) between 90 and 99) then " _
& Chr(39) & "VM" & Chr(39) & "||" & Chr(39) & "9" & Chr(39) & "
when (substr(MktCode,-2) between 100 and 109) then " & Chr(39) & "VM" &
Chr(39) & "||" & Chr(39) & "10" & Chr(39) & " end when Length(MktCode) =
5 then " & Chr(39) & "VM" & Chr(39) & "||" & Chr(39) & "10" & Chr(39) &
" end as VertMkt, " & _
"case when (substr(BrchNo,-4) between 1500 and 1550) then " &
Chr(39) & "Rgn" & Chr(39) & "||" & Chr(39) & "1" & Chr(39) & " when
(substr(BrchNo,-4) between 2500 and 2550) then " & Chr(39) & "Rgn" &
Chr(39) & "||" & Chr(39) & "2" & Chr(39) & " when (substr(BrchNo,-4)
between 3500 and 3550) then " & Chr(39) & "Rgn" & Chr(39) & "||" &
Chr(39) & "3" & Chr(39) & " when (substr(BrchNo,-4) between 4500 and
4550) then " & Chr(39) & "Rgn" & Chr(39) & "||" & Chr(39) & "4" &
Chr(39) & " when (substr(BrchNo,-4) between 5500 and 5500) then " &
Chr(39) & "Rgn" & Chr(39) & "||" & Chr(39) & "5" & Chr(39) & " when
(substr(BrchNo,-4) between 6500 and 6550) then " & Chr(39) & "Rgn" &
Chr(39) & "||" & Chr(39) & "6" & Chr(39) & " when (substr(BrchNo,-4)
between 7500 and 7550) then " & Chr(39) & "Rgn" & Chr(39) & "||" &
Chr(39) & "7" & Chr(39) & " end as Rgn, " & _
"case when (substr(ProdNo,-3) between 100 and 199) then " &
Chr(39) & "LOB" & Chr(39) & "||" & Chr(39) & "1" & Chr(39) & " when
(substr(ProdNo,-3) between 200 and 299) then " & Chr(39) & "LOB" &
Chr(39) & "||" & Chr(39) & "2" & Chr(39) & " when (substr(ProdNo,-3)
between 300 and 399) then " & Chr(39) & "LOB" & Chr(39) & "||" & Chr(39)
& "3" & Chr(39) & " when (substr(ProdNo,-3) between 400 and 499) then "
& Chr(39) & "LOB" & Chr(39) & "||" & Chr(39) & "4" & Chr(39) & " when
(substr(ProdNo,-3) between 500 and 599) then " & Chr(39) & "LOB" &
Chr(39) & "||" & Chr(39) & "5" & Chr(39) & " when (substr(ProdNo,-3)
between 600 and 699) then " & Chr(39) & "LOB" & Chr(39) & "||" & Chr(39)
& "6" & Chr(39) & " when (substr(ProdNo,-3) between 700 and 799) then "
& Chr(39) & "LOB" & Chr(39) & "||" & Chr(39) & "7" & Chr(39) & " when
(substr(ProdNo,-3) between 800 and 899) then " & Chr(39) & "LOB" &
Chr(39) & "||" & Chr(39) & "8" & Chr(39) & " end as LineOfBus " & _
"from sc.tblOrdersCurYr;"
Debug.Print strSQL
'create query
Set qdfPassThrew = dbCur.CreateQueryDef("")
qdfPassThrew.Connect = "ODBC;" & strCnn
qdfPassThrew.SQL = strSQL
qdfPassThrew.ReturnsRecords = False
wsCur.BeginTrans
qdfPassThrew.Execute
wsCur.CommitTrans
wsCur.Close
Set qdfPassThrew = Nothing
Set dbCur = Nothing
Set wsCur = Nothing
End Sub
=====================<End Code<=====================================<
What can I say? I'm just experimenting a little with Access 2k2 and
Oracle 10g Express Edition. Thanks!
What is the maximum length of an ODBC pass through query?
Things work fine with the code except when I try to create a view which
is pretty complex in Oracle. I'm using a DSN provided with the Oracle
Express Edition and using Access 2k2 as the front-end. When I debug
print the SQL and paste it into SQLplus it works fine. The length of
the debug print that works is 1988 characters. Since the exact same
code works with shorter SQL I'm guessing there is a max length to the
string that can be passed which is why I asked the question. Error
reads:
,----- [ Error on PTQ ]
| Run-time error '3146'
| ODBC-call failed.
`-----
The code is included below. Any ideals. Thanks!
=====================>Begin Code>===================================>
Sub Create_vw_tblOrdersCurYr_rev2()
Dim wsCur As DAO.Workspace
Dim dbCur As DAO.Database
Dim qdfPassThrew As DAO.QueryDef
Dim strSQL As String
Set wsCur = DBEngine.Workspaces(0)
Set dbCur = wsCur.Databases(0)
Call SetConStr
strSQL = "CREATE OR REPLACE VIEW sc.vw_tblOrdersCurYr_rev2 AS " & _
"SELECT OrderNo, PdNewOrder, EstRev, EstCGS, " & _
"case when (substr(BusCode,-3) between 100 and 199) then " &
Chr(39) & "BU" & Chr(39) & "||" & Chr(39) & "1" & Chr(39) & " when
(substr(BusCode,-3) between 200 and 299) then " & Chr(39) & "BU" &
Chr(39) & "||" & Chr(39) & "2" & Chr(39) & " when (substr(BusCode,-3)
between 300 and 399) then " & Chr(39) & "BU" & Chr(39) & "||" & Chr(39)
& "3" & Chr(39) & " end as BusUnit, " & _
"case when Length(MktCode) = 4 then case when
(substr(MktCode,-2) between 10 and 19) then " & Chr(39) & "VM" & Chr(39)
& "||" & Chr(39) & "1" & Chr(39) & " when (substr(MktCode,-2) between 20
and 29) then " & Chr(39) & "VM" & Chr(39) & "||" & Chr(39) & "2" &
Chr(39) & " when (substr(MktCode,-2) between 30 and 39) then " & Chr(39)
& "VM" & Chr(39) & "||" & Chr(39) & "3" & Chr(39) & " when
(substr(MktCode,-2) between 40 and 49) then " & Chr(39) & "VM" & Chr(39)
& "||" & Chr(39) & "4" & Chr(39) & " when (substr(MktCode,-2) between 50
and 59) then " & Chr(39) & "VM" & Chr(39) & "||" & Chr(39) & "5" &
Chr(39) & " when (substr(MktCode,-2) between 60 and 69) then " & Chr(39)
& "VM" & Chr(39) & "||" & Chr(39) & "6" & Chr(39) & " when
(substr(MktCode,-2) between 70 and 79) then " & Chr(39) & "VM" & Chr(39)
& "||" & Chr(39) & "7" & Chr(39) & " when (substr(MktCode,-2) between 80
and 89) then " & Chr(39) & "VM" & Chr(39) & "||" & Chr(39) & "8" &
Chr(39) & " when (substr(MktCode,-2) between 90 and 99) then " _
& Chr(39) & "VM" & Chr(39) & "||" & Chr(39) & "9" & Chr(39) & "
when (substr(MktCode,-2) between 100 and 109) then " & Chr(39) & "VM" &
Chr(39) & "||" & Chr(39) & "10" & Chr(39) & " end when Length(MktCode) =
5 then " & Chr(39) & "VM" & Chr(39) & "||" & Chr(39) & "10" & Chr(39) &
" end as VertMkt, " & _
"case when (substr(BrchNo,-4) between 1500 and 1550) then " &
Chr(39) & "Rgn" & Chr(39) & "||" & Chr(39) & "1" & Chr(39) & " when
(substr(BrchNo,-4) between 2500 and 2550) then " & Chr(39) & "Rgn" &
Chr(39) & "||" & Chr(39) & "2" & Chr(39) & " when (substr(BrchNo,-4)
between 3500 and 3550) then " & Chr(39) & "Rgn" & Chr(39) & "||" &
Chr(39) & "3" & Chr(39) & " when (substr(BrchNo,-4) between 4500 and
4550) then " & Chr(39) & "Rgn" & Chr(39) & "||" & Chr(39) & "4" &
Chr(39) & " when (substr(BrchNo,-4) between 5500 and 5500) then " &
Chr(39) & "Rgn" & Chr(39) & "||" & Chr(39) & "5" & Chr(39) & " when
(substr(BrchNo,-4) between 6500 and 6550) then " & Chr(39) & "Rgn" &
Chr(39) & "||" & Chr(39) & "6" & Chr(39) & " when (substr(BrchNo,-4)
between 7500 and 7550) then " & Chr(39) & "Rgn" & Chr(39) & "||" &
Chr(39) & "7" & Chr(39) & " end as Rgn, " & _
"case when (substr(ProdNo,-3) between 100 and 199) then " &
Chr(39) & "LOB" & Chr(39) & "||" & Chr(39) & "1" & Chr(39) & " when
(substr(ProdNo,-3) between 200 and 299) then " & Chr(39) & "LOB" &
Chr(39) & "||" & Chr(39) & "2" & Chr(39) & " when (substr(ProdNo,-3)
between 300 and 399) then " & Chr(39) & "LOB" & Chr(39) & "||" & Chr(39)
& "3" & Chr(39) & " when (substr(ProdNo,-3) between 400 and 499) then "
& Chr(39) & "LOB" & Chr(39) & "||" & Chr(39) & "4" & Chr(39) & " when
(substr(ProdNo,-3) between 500 and 599) then " & Chr(39) & "LOB" &
Chr(39) & "||" & Chr(39) & "5" & Chr(39) & " when (substr(ProdNo,-3)
between 600 and 699) then " & Chr(39) & "LOB" & Chr(39) & "||" & Chr(39)
& "6" & Chr(39) & " when (substr(ProdNo,-3) between 700 and 799) then "
& Chr(39) & "LOB" & Chr(39) & "||" & Chr(39) & "7" & Chr(39) & " when
(substr(ProdNo,-3) between 800 and 899) then " & Chr(39) & "LOB" &
Chr(39) & "||" & Chr(39) & "8" & Chr(39) & " end as LineOfBus " & _
"from sc.tblOrdersCurYr;"
Debug.Print strSQL
'create query
Set qdfPassThrew = dbCur.CreateQueryDef("")
qdfPassThrew.Connect = "ODBC;" & strCnn
qdfPassThrew.SQL = strSQL
qdfPassThrew.ReturnsRecords = False
wsCur.BeginTrans
qdfPassThrew.Execute
wsCur.CommitTrans
wsCur.Close
Set qdfPassThrew = Nothing
Set dbCur = Nothing
Set wsCur = Nothing
End Sub
=====================<End Code<=====================================<
What can I say? I'm just experimenting a little with Access 2k2 and
Oracle 10g Express Edition. Thanks!