Re: are there limitations of SQL used in text driver via ADO
- From: KaptainKidd <KaptainKidd@xxxxxxxxxxxxxxxxxxxxxxxxx>
- Date: Mon, 3 Apr 2006 07:41:01 -0700
Thanks Dan.. do you know where I can get a list of commands which JET
supports?
"Daniel Crichton" wrote:
KaptainKidd wrote on 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'
From
filename.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
select.. case.. type query on a text file, I amI am using a
ADODB.connection but keep getting an error when I try to open theconnectingvia
recordset
Connection/Recordset code
any ideas
Post the error your getting and your
Stephen Howe
You are using Case statements with the Jet provider. Jet does not support
Case (or many other ANSI SQL constructs). You would use "Iif" with Jet, eg.
select
Portfolio,
Sum(Iif(scenario_Name =
'EB_-0.1',scenario_MV-Scenario_Stressed_Value,null)) as 'Equity-10',
....
Iif takes 3 values - the first is the expression to be evaluated, the second
the returned value if the expression is True, the third is the returned
value if False.
Dan
- Follow-Ups:
- Re: are there limitations of SQL used in text driver via ADO
- From: Daniel Crichton
- Re: are there limitations of SQL used in text driver via ADO
- References:
- Re: are there limitations of SQL used in text driver via ADO
- From: Daniel Crichton
- Re: are there limitations of SQL used in text driver via ADO
- Prev by Date: Re: fill method
- Next by Date: Re: are there limitations of SQL used in text driver via ADO
- Previous by thread: Re: are there limitations of SQL used in text driver via ADO
- Next by thread: Re: are there limitations of SQL used in text driver via ADO
- Index(es):
Relevant Pages
|
|