Am 21.03.20 um 17:48 schrieb Artur Tarassow:
Am 21.03.20 um 17:07 schrieb Allin Cottrell:
> On Fri, 20 Mar 2020, Artur Tarassow wrote:
>
>> I had again a look at this issue. So the connection is there and the
>> correct data gets fetched. However, the resulting series "klima" has
>> only zeros. The error message is "Error executing script: halting".
>> The terminal output is:
>>
>> <Terminal>
>> SQL query: 'SELECT KLIMA FROM OV_AS_LAB_LUMEN.IFO_DATA LIMIT 5'
>> Number of columns = 1
>> col 1 (KLIMA): data_type SQL_DECIMAL, size 4, digits 1, nullable 2
>> Number of Rows (from SQLRowCount) = 5
>> Fetch, row 0: col 0: data value 102.2
>> Fetch, row 1: col 0: data value 102.5
>> Fetch, row 2: col 0: data value 99.7
>> Fetch, row 3: col 0: data value 102.6
>> Fetch, row 4: col 0: data value 101.5
>> SQLFreeHandle(SQL_HANDLE_STMT): SQL_SUCCESS
>> SQLDisconnect: SQL_SUCCESS
>> SQLFreeHandle(SQL_HANDLE_DBC): SQL_SUCCESS
>> SQLFreeHandle(SQL_HANDLE_ENV): SQL_SUCCESS
>> </Terminal>
>>
>> I know that it worked before latest feature implementing fetching
>> string-valued series.
>
> I'm not able to replicate the proble (yet).
>
> To make debugging of ODBC a bit easier I've added an ODBC-specific
> --verbose option to the "data" command. Use that option and you'll get
> debugging spew in the regular gretl output (not stderr any more). I've
> also added a little more detail.
>
> I'm attaching a little tar.gz file with kit to try out my attempted
> replication of the problem. (For me the example works OK.) There's a
> README in the package, but here's the gist: create a tiny database
> that mimics the data Artur showed, then read from it using gretl.
Thanks for your effort, Allin. I think I have it now. The issue is that
I have initialized a dataset (via the nulldata command) of length 10 but
the returned series has only length 5. When bot the length of the
existing data set and the fetched one coincide, all works well.
I am pretty sure that up to a month ago or so, it worked well in case
the length of the existing data set was larger than that of the newly
fetched one. Usually I don't know exactly how long the returned series
will be. So I initialize a large data set, fetch data and restrict the
data set to valid observations only. _This_ does not seem to work any
more and causes trouble.
To summarize:
1) In case no data set is open, <data ...--odbc> returns just "Error
executing script" -- not very informative I guess ;-)
2) In case the length of the current data set is longer than the fetched
one, all values of newly attached data are zero as explained before.
3) In case the length of the current data set is smaller than of the
fetched one, the error message "Error executing script" occurs.
Sorry, but I've explored some further issues:
1) "DATUM" is a date string in the format YYYY-MM-DD. This format seems
to cause trouble as an error occurs for the query:
QUERY: "SELECT DATUM FROM OV_AS_LAB_LUMEN.IFO_DATA LIMIT 10"
<output>
SQL query: 'SELECT DATUM FROM OV_AS_LAB_LUMEN.IFO_DATA LIMIT 10'
SQLConnect(dbc,...): SQL_SUCCESS
Number of columns = 1
col 1 (DATUM): data_type invalid, size 10, digits 0, invalid 'nullable'
value!
Number of rows (from SQLRowCount): 10
SQLFreeHandle(SQL_HANDLE_STMT): SQL_SUCCESS
SQLDisconnect: SQL_SUCCESS
SQLFreeHandle(SQL_HANDLE_DBC): SQL_SUCCESS
SQLFreeHandle(SQL_HANDLE_ENV): SQL_SUCCESS
</output>
2) This workaround casting the string value to ISO8601 date format helps
though:
QUERY: "SELECT TO_CHAR(TO_DATE(DATUM), 'yyyyMMdd') DATUM FROM
OV_AS_LAB_LUMEN.IFO_DATA LIMIT 10"
<output>
SQL query: 'SELECT TO_CHAR(TO_DATE(DATUM), 'yyyyMMdd') DATUM FROM
OV_AS_LAB_LUMEN.IFO_DATA LIMIT 10'
SQLConnect(dbc,...): SQL_SUCCESS
Number of columns = 1
col 1 (DATUM): data_type SQL_VARCHAR, size 8, digits 0, invalid
'nullable' value!
binding data col 1 to strvals[0] (len = 8)
Number of rows (from SQLRowCount): 10
Fetch, row 0: col 0: string data value '20180706' -> 1
Fetch, row 1: col 0: string data value '20190319' -> 2
Fetch, row 2: col 0: string data value '20151021' -> 3
Fetch, row 3: col 0: string data value '20150406' -> 4
Fetch, row 4: col 0: string data value '20170302' -> 5
Fetch, row 5: col 0: string data value '20191027' -> 6
Fetch, row 6: col 0: string data value '20190711' -> 7
Fetch, row 7: col 0: string data value '20190712' -> 8
Fetch, row 8: col 0: string data value '20150207' -> 9
Fetch, row 9: col 0: string data value '20160411' -> 10
SQLFreeHandle(SQL_HANDLE_STMT): SQL_SUCCESS
SQLDisconnect: SQL_SUCCESS
SQLFreeHandle(SQL_HANDLE_DBC): SQL_SUCCESS
SQLFreeHandle(SQL_HANDLE_ENV): SQL_SUCCESS
</output>
3) For "simple" string valued series such as “sektor” everything works fine:
QUERY: "SELECT sektor, klima FROM OV_AS_LAB_LUMEN.IFO_DATA LIMIT 10"
4) A very weired case: Even though I cast the date string to ISO8601
format, the following query -- a combination of all 3 series -- fails:
QUERY: "SELECT TO_CHAR(TO_DATE(DATUM), 'yyyyMMdd') AS DATUM, sektor,
klima FROM OV_AS_LAB_LUMEN.IFO_DATA LIMIT 10"
<output>
SQL query: 'SELECT TO_CHAR(TO_DATE(DATUM), 'yyyyMMdd') AS DATUM, sektor,
klima FROM OV_AS_LAB_LUMEN.IFO_DATA LIMIT 10'
SQLConnect(dbc,...): SQL_SUCCESS
Number of columns = 3
col 1 (DATUM): data_type SQL_VARCHAR, size 8, digits 0, invalid
'nullable' value!
binding data col 1 to strvals[0] (len = 8)
col 2 (SEKTOR): data_type SQL_VARCHAR, size 20, digits 0, invalid
'nullable' value!
binding data col 2 to strvals[1] (len = 20)
col 3 (KLIMA): data_type SQL_DECIMAL, size 4, digits 1, invalid
'nullable' value!
Number of rows (from SQLRowCount): 10
Fetch, row 0: col 0: string data value '20180706' -> 1; col 1: string
data value 'gesamt' -> 1; col 2: data value 102.2
Fetch, row 1: col 0: string data value '20170428' -> 2; col 1: string
data value 'gesamt' -> 1; col 2: data value 102.5
Fetch, row 2: col 0: string data value '20151021' -> 3; col 1: string
data value 'gesamt' -> 1; col 2: data value 100.7
Fetch, row 3: col 0: string data value '20170518' -> 4; col 1: string
data value 'gesamt' -> 1; col 2: data value 102.6
.
.
.
Fetch, row 9: col 0: string data value '20170325' -> 10; col 1: string
data value 'gesamt' -> 1; col 2: data value 101.5
SQLFreeHandle(SQL_HANDLE_STMT): SQL_SUCCESS
SQLDisconnect: SQL_SUCCESS
SQLFreeHandle(SQL_HANDLE_DBC): SQL_SUCCESS
SQLFreeHandle(SQL_HANDLE_ENV): SQL_SUCCESS
</output>
The data set imported to gretl shows that column "klima" consists of NAs
only, no string values are returned for "sektor" but a constant instead;
and "datum" has as its first entry the string value "gesamt" which
actually belongs to series "sektor".
<print_dataset>
index datum sektor klima
1 1 gesamt 1
2 2 1
3 3 1
4 4 1
5 5 1
6 6 1
7 7 1
8 8 1
9 9 1
10 10 1
</print_dataset>
Best,
Artur