Re: [Haskell-cafe] Looking for Haskellers on Windows

Hi Kyra,
and again, thanks for taking the effort.
Kyra I've tried any sort of values to any sort of columns. I tried "insert
into somesinglecolumntable (someNumbercolumn) values (?)" [toSql 5] ...
and so on.
So I'm not certain at all the error message does actually give the right
clue.
It just blows no matter what.
What does work though is this:
run dbc "insert into sometable (someVarcharcolumn) values ('some string
value')" []
This would be a workaround for my app, but I hope I can do better.
Günther
Am 10.01.2009, 17:01 Uhr, schrieb kyra
Günther Schmidt wrote:
Hi Kyra, thanks for your reply. The problem I was facing is using an MS-Access backend with HDBC-ODBC. I try to export data to MS-Access and I can't get it to work. Otherwise HDBC works fine in other parts of my app but with MS-Access it blows up. I did of course post this on the haskell-cafe list first, but no response and the HDBC package maintainer himself was unable to help too since he's not using Windows.
I've looked at Your problem now. What is the type of that single field in 'mytable'? Google shows numerous similar cases, e.g. for date or memo fields, that Access don't accept varchars and require longvarchars for.
I'm in no way an Access expert.
Cheers, Kyra
-- Erstellt mit Operas revolutionärem E-Mail-Modul: http://www.opera.com/mail/

Günther Schmidt wrote:
Hi Kyra,
and again, thanks for taking the effort.
Kyra I've tried any sort of values to any sort of columns. I tried "insert into somesinglecolumntable (someNumbercolumn) values (?)" [toSql 5] ... and so on.
So I'm not certain at all the error message does actually give the right clue.
It just blows no matter what.
What does work though is this:
run dbc "insert into sometable (someVarcharcolumn) values ('some string value')" []
It is probably good to avoid this. HDBC does not provide SQL string escaping functions because it is designed around the model of the replacable parameters, which are more secure and more performant. You will have to be very careful to sanitize input if you do take this approach. As to the larger question, there are quite a few Windows Haskell users out there. Some well-known Haskell personalities work for a division of Microsoft, even. I am not sure that there are all that many people talking to Access databases via ODBC to start with, though, but of course if anybody has a patch to contribute, I'd be happy to apply it. -- John

Hi John,
thx for responding :)
I'm trying to analyze the HDBC code so that, maybe, I'm able to find the
spot that's causing me trouble.
Do you happen to have some documentation on how you desigend this?
Also while digging through the code I learned some stuff that I found
quite interessting. As an example I found the function "executeMany" to be
part of a data declaration, now that's certainly something I as a newbie
have never seen before, is there a special name for this technique?
Günther
Am 10.01.2009, 18:12 Uhr, schrieb John Goerzen
Günther Schmidt wrote:
Hi Kyra,
and again, thanks for taking the effort.
Kyra I've tried any sort of values to any sort of columns. I tried "insert into somesinglecolumntable (someNumbercolumn) values (?)" [toSql 5] ... and so on.
So I'm not certain at all the error message does actually give the right clue.
It just blows no matter what.
What does work though is this:
run dbc "insert into sometable (someVarcharcolumn) values ('some string value')" []
It is probably good to avoid this. HDBC does not provide SQL string escaping functions because it is designed around the model of the replacable parameters, which are more secure and more performant. You will have to be very careful to sanitize input if you do take this approach.
As to the larger question, there are quite a few Windows Haskell users out there. Some well-known Haskell personalities work for a division of Microsoft, even.
I am not sure that there are all that many people talking to Access databases via ODBC to start with, though, but of course if anybody has a patch to contribute, I'd be happy to apply it.
-- John
-- Erstellt mit Operas revolutionärem E-Mail-Modul: http://www.opera.com/mail/

John Goerzen wrote:
GЭnther Schmidt wrote:
Kyra I've tried any sort of values to any sort of columns. I tried "insert into somesinglecolumntable (someNumbercolumn) values (?)" [toSql 5] ... and so on.
So I'm not certain at all the error message does actually give the right clue.
It just blows no matter what.
It seems, I've managed to track down the issue. Access ODBC driver doesn't support sqlDescribeParam. bindCol (Database/HDBC/ODBC/Statement.hsc) contains the following stub for this: do poke pdtype #{const SQL_CHAR} poke pcolsize 0 poke pdecdigits 0 This does not work. I've made an experiment replacing 'poke pcolsize 0' with 'poke pcolsize 255'. Now all integer or varchar bindings work! It seems simpleSqlColumns or something similar must be used. Cheers, Kyra

Kyra,
that is fantastic new!
Victory is near, I can smell it hahahahahahahaha ...
Um, sry for that, I'm just really really happy and glad I made that post
today. I've been trying to get this issue resolved for more than 14 days
now and if now solution had shown up on the horizon I would have been
forced to dump Haskell and do it all over again in Smalltalk and really
quick on top of it because the final deadline is Jan 19.
The app is 95 % finished and really all that is missing is the bloody
export to Access.
Thank you very very much.
Günther
Am 10.01.2009, 19:48 Uhr, schrieb kyra
John Goerzen wrote:
GЭnther Schmidt wrote:
Kyra I've tried any sort of values to any sort of columns. I tried "insert into somesinglecolumntable (someNumbercolumn) values (?)" [toSql 5] ... and so on.
So I'm not certain at all the error message does actually give the right clue.
It just blows no matter what.
It seems, I've managed to track down the issue.
Access ODBC driver doesn't support sqlDescribeParam.
bindCol (Database/HDBC/ODBC/Statement.hsc) contains the following stub for this:
do poke pdtype #{const SQL_CHAR} poke pcolsize 0 poke pdecdigits 0
This does not work.
I've made an experiment replacing 'poke pcolsize 0' with 'poke pcolsize 255'. Now all integer or varchar bindings work!
It seems simpleSqlColumns or something similar must be used.
Cheers, Kyra
-- Erstellt mit Operas revolutionärem E-Mail-Modul: http://www.opera.com/mail/

Hi Kyra, IT WORKS! Thank you very much, my application is now almost finished. It was a whole lot of fun writing this in Haskell, but the last 2 weeks where frustrating, until today. I am amazed at the possibilities Haskell gives me in wiring code together and I would not want to miss it by having to go back and do the whole app again in Smalltalk. Günther

Thank you for the hint. Please try this patch: http://git.complete.org/hdbc-odbc?a=commitdiff_plain;h=55af38aac8df9f9449868... and let me know if it fixes the issue for you. -- John kyra wrote:
John Goerzen wrote:
GЭnther Schmidt wrote:
Kyra I've tried any sort of values to any sort of columns. I tried "insert into somesinglecolumntable (someNumbercolumn) values (?)" [toSql 5] ... and so on.
So I'm not certain at all the error message does actually give the right clue.
It just blows no matter what.
It seems, I've managed to track down the issue.
Access ODBC driver doesn't support sqlDescribeParam.
bindCol (Database/HDBC/ODBC/Statement.hsc) contains the following stub for this:
do poke pdtype #{const SQL_CHAR} poke pcolsize 0 poke pdecdigits 0
This does not work.
I've made an experiment replacing 'poke pcolsize 0' with 'poke pcolsize 255'. Now all integer or varchar bindings work!
It seems simpleSqlColumns or something similar must be used.
Cheers, Kyra
participants (3)
-
Günther Schmidt
-
John Goerzen
-
kyra