General ODBC Error - Why
10345 pts.
0
Q:
General ODBC Error - Why
I get an gernal ODBC
error when running the below code. It looks like the sqlt is too long,
but how can I get it to work as I need the query to be dynamic based on
date.



sqlt = "SELECT SCHED_TASK_EXEC.TASK_ID, SCHED_TASK_EXEC.TASK_TYPE,
SCHED_TASK_EXEC.EXEC_TIME, SCHED_TASK_EXEC.END_TIME,
SCHED_TASK_EXEC.EXEC_STATUS_B, SCHED_TASK.DESCRIPTION FROM
CPSLIVE.SCHED_TASK SCHED_TASK, CPSLIVE.SCHED_TASK_EXEC SCHED_TASK_EXEC
WHERE SCHED_TASK.TASK_ID = SCHED_TASK_EXEC.TASK_ID and
sched_task_exec.exec_time >=to_timestamp('" & yday & "') AND
sched_task_exec.exec_time <=to_timestamp('" & tday & "')
order by 1"



MsgBox (sqlt)







With ActiveSheet.QueryTables.Add(Connection:=Array(Array( _

"ODBC;DRIVER={Oracle in
OraClient10g_home2};SERVER=CPSLIVEB;UID=cpslive;;DBQ=CPSLIVEB;DBA=W;APA=T;EXC=F;XSM=Default;FEN=T;QTO=T;FRC=10"
_

), Array( _

";FDL=10;LOB=T;RST=T;BTD=F;BAM=IfAllSuccessful;NUM=NLS;DPM=F;MTS=T;MDI=Me;CSR=F;FWC=F;FBS=60000;TLO=O;" _

)), Destination:=Range("A1"), Sql:=sqlt)

.Name = "Query from CPSLIVEB"

.FieldNames = True

.RowNumbers = False

.FillAdjacentFormulas = False

.PreserveFormatting = True

.RefreshOnFileOpen = False

.BackgroundQuery = True

.RefreshStyle = xlInsertDeleteCells

.SavePassword = False

.SaveData = True

.AdjustColumnWidth = True

.RefreshPeriod = 0

.PreserveColumnInfo = True

.Refresh BackgroundQuery:=False

End With
ASKED: Sep 30 2009  4:54 PM GMT
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
0
10345 pts.
0
A:
 RATE THIS ANSWER
0
Click to Vote:
  •   0
  •  0
  • AddThis Social Bookmark Button
Last Answered: Sep 30 2009  4:54 PM GMT by ITKE   10345 pts.
0
0
Discuss This Answer:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

Meandyou   1840 pts.  |   Sep 30 2009  7:00PM GMT

While this is not an direct answer to the question, I will point out that I recently encountered a general (or generic) ODBC error from MS Access trying to query a DB2 for z/OS table. It turned out to be that MS Access could not handle a table with a data type of ROWID. I mention this only to point out that ODBC errors are not always what they appear to be.

Steve

 

Carlosdl   29770 pts.  |   Sep 30 2009  11:35PM GMT

Are you able to successfully execute other SQL commands ?

I don’t think the command is too long, but if it was, you could use shorter table aliases and use those aliases to qualify columns, to shorten it a little.

Also, have you tried the same command, but using fixed values instead of the tday and yday variables ?

 
0