Re: are there limitations of SQL used in text driver via ADO
- From: KaptainKidd <KaptainKidd@xxxxxxxxxxxxxxxxxxxxxxxxx>
- Date: Wed, 29 Mar 2006 23:57:02 -0800
I have the following SQL query which I run from excel vba using ADO
SQL Query
select
Portfolio,
Sum(case when scenario_Name = 'EB_-0.1' then
scenario_MV-Scenario_Stressed_Value else null end) as 'Equity-10',
Sum(case when scenario_Name = 'EB_0.1' then
scenario_MV-Scenario_Stressed_Value else null end) as 'Equity+10',
Sum(case when scenario_Name = 'VB_-0.1' then
scenario_MV-Scenario_Stressed_Value else null end) as 'Vol-10',
Sum(case when scenario_Name = 'VB_-0.05' then
scenario_MV-Scenario_Stressed_Value else null end) as 'Vol-5',
Sum(case when scenario_Name = 'VB_0.05' then
scenario_MV-Scenario_Stressed_Value else null end) as 'Vol+5',
Sum(case when scenario_Name = 'VB_0.1' then
scenario_MV-Scenario_Stressed_Value else null end) as 'Vol+10'
Fromfilename.csv
Group By
Portfolio
VBA Code
Set cnx = New ADODB.Connection
Set rs = New ADODB.Recordset
cnx.CursorLocation = adUseClient
cnx.Open "DSN=ReechRisk"
'cnx.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & RiskFileloc
& _
";Extended Properties='text;HDR=YES;FMT=Delimited'"
' Load up sql from file
Open filename.csv For Input As #1
Do Until EOF(1)
strSQL = strSQL & Input(1, #1)
Loop
Close #1
rs.Open strSQL, cnx, adOpenDynamic, adLockBatchOptimistic, adCmdText
If I remove the case statements in the sql and just have a simple select
query then it seems to work. I have other pieces of code which are similar to
this and it works just fine, so I am not sure if the sql used in odbc Text
driver is not compatable..
The error I get when I run this is
Run time error '-2147217900 (80040e14)':
[Microsoft][ODBC Text Driver] Syntax error (missing operator) in query
expression
'Sum(case when scenario_name = 'EB_-0.1' then
scenario_mv-Scenario_stressed_Value else null end)'
"Stephen Howe" wrote:
.
"KaptainKidd" <KaptainKidd@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:1B708828-31A0-4562-A38E-60BAE5863FAF@xxxxxxxxxxxxxxxx
I am using a select.. case.. type query on a text file, I am connectingvia
ADODB.connection but keep getting an error when I try to open therecordset
any ideas
Post the error your getting and your Connection/Recordset code
Stephen Howe
- References:
- Re: are there limitations of SQL used in text driver via ADO
- From: Stephen Howe
- Re: are there limitations of SQL used in text driver via ADO
- Prev by Date: recordset connection network failure
- Next by Date: Limit data amount in response to SELECT query
- Previous by thread: Re: are there limitations of SQL used in text driver via ADO
- Next by thread: Re: Large Number Of Inserts
- Index(es):
Relevant Pages
|
|