Oracle DB에서 데이터를 수집하는 데 어려움을 겪고 있습니다. 연결이 끊어지기 때문에 문제는 쿼리 내에 있습니다. 현재 쿼리는 아무것도 반환하지 않으며 VBA도 그것에 대해 불평하지 않습니다. 여기 VBA - 여러 AND 문이 작동하지 않는 쿼리
코드입니다 :Sub Connect_XXXX()
Dim conn As ADODB.Connection
Set conn = New ADODB.Connection
Dim rs As New ADODB.Recordset
Set rs = New ADODB.Recordset
Dim myQuery As ADODB.Command
Set myQuery = New ADODB.Command
conn.Open "Provider=OraOLEDB.Oracle;" & _
"Data Source=XXXX;" & _
"User Id=YYYY;" & _
"Password=ZZZZ"
myQuery.ActiveConnection = conn
myQuery.CommandText = "SELECT sta.index_id, sta.index_action as Action, sta.ticker, sta.company, sta.announcement_date as A_Date, sta.announcement_time as A_Time, " & _
"sta.effective_date as E_Date, dyn.index_supply_demand as BS_Shares, dyn.net_index_supply_demand as Net_BS_Shares, dyn.est_funding_trade as BS_Value, " & _
"dyn.trade_adv_perc/100 as Days_to_Trade, dyn.pre_index_weight/100 as Wgt_Old, dyn.post_index_weight/100 as Wgt_New, dyn.net_index_weight/100 as Wgt_Chg, " & _
"dyn.pre_est_index_holdings as Index_Hldgs_Old, dyn.post_est_index_holdings as Index_Hldgs_New, dyn.net_est_index_holdings as Index_Hldgs_Chg, sta.index_action_details as Details " & _
"FROM index_analysis.eq_index_actions_dyn dyn, index_analysis.eq_index_actions_static sta " & _
"WHERE (sta.action_id = dyn.action_id) AND (sta.announcement_date=dyn.price_date) AND (sta.announcement_date >= '01-January-2015') AND (sta.announcement_date <= '30-January-2015') " & _
"ORDER by sta.index_id,sta.announcement_date"
Set rs = myQuery.Execute
Sheets("Sheet1").Range("A1").CopyFromRecordset rs
rs.Close
conn.Close
End Sub
내가 쿼리 많은 주위를 연주했습니다, 그리고 나는 WHERE 후와 문장의 일부를 제거하고 더 적은으로 시도하여 어떤 결과를 얻을 수있었습니다 필드는 SELECT 문에 있지만이 결과가 나에게 잘 작동하려면 모두 필요합니다. 이상한 점은 Oracle Sql Developer (DB에 연결 한 후)와 같은 문제에서 동일한 쿼리를 실행하면 원하는 결과가 표시된다는 것입니다. 정말 도움이 필요해, 고마워!