다음 VBA 서브 루틴은 대부분의 쿼리를 올바르게 실행합니다. (즉 : SELECT * FROM DUAL
) 나는 아래의 쿼리를 실행할 때VBA/ADODB 런타임 오류 : 3704
Sub DisplayQuery(QueryString As String)
Dim rs As New ADODB.Recordset
Dim connStr As String
connStr = _
"Provider=MSDAORA.1;" _
& "User ID=abc;Password=123;" _
& "Data Source=xxx/xxx;"
out QueryString
rs.Open QueryString, connStr, adOpenStatic, adLockOptimistic
Range("DataTable").Clear
Cells(1, 1).CopyFromRecordset rs
End Sub
그러나, 다음과 같은 오류 메시지가 즉시 팝업 : Run-time error '3704':Operation is not allowed when the object is closed.
with all_hours as
(select to_date('2009-11-03 05:00 PM','yyyy-mm-dd hh:mi PM') + numtodsinterval(level-1,'hour') hour
from dual
connect by level <= 4 /*hours*/
)
select h.hour
, count(case when h.hour = trunc(s.sampled_on,'hh24') then 1 end) sampled
, count(case when h.hour = trunc(s.received_on,'hh24') then 1 end) received
, count(case when h.hour = trunc(s.completed_on,'hh24') then 1 end) completed
, count(case when h.hour = trunc(s.authorized_on,'hh24') then 1 end) authorized
from all_hours h cross join sample s
group by h.hour
이유는 무엇입니까? 내가 올바르게 기억
오라클 데이터베이스는 메모리 관리/연결 풀링 등을 통해 영리한 작업을 수행합니다. 쿼리 실행이 대기열에 있으면 연결 개체가 닫힌 것처럼 보일 수 있습니다. 주변에는 (a) 쿼리 최적화 및 (b) 통과 쿼리가 있습니다. – heferav
h.hour에 null 값이 있습니까? – dendarii
또는 샘플 테이블의 필드? – dendarii