1. Matt's ODBC wrapper and Mysql
- Posted by George Walters <gwalters at sc.rr.com> Nov 01, 2004
- 678 views
Matt, I think there is a problem with error handeling in execDirect. Or I'm handeling it wrong (most likely). I had a syntax error in the SQL statement and odbcError reported an "invalid handle". Here's how I'm using it. The value returned for "a" was -29. On one of the SQL fields I had {48} instead of "0" which caused this error.
a = execDirectODBC(dbId, "replace " & openTbNames[t] & " values (" & packRecord( t, recordKey, recordDb) & ")") if atom(a) then odbcError(-a) a = message_box("Can't find record "&recordKey&" to update.","",0) abort(1) else
george
2. Re: Matt's ODBC wrapper and Mysql
- Posted by Matt Lewis <matthewwalkerlewis at yahoo.com> Nov 01, 2004
- 649 views
George Walters wrote: > > > Matt, I think there is a problem with error handeling in execDirect. Or > I'm handeling it wrong (most likely). I had a syntax error in the SQL > statement and odbcError reported an "invalid handle". Here's how I'm using > it. The value returned for "a" was -29. On one of the SQL fields I had {48} > instead of "0" which caused this error. > > }}} <eucode> > a = execDirectODBC(dbId, "replace " & openTbNames[t] & > " values (" & packRecord( t, recordKey, recordDb) & ")") > if atom(a) then > odbcError(-a) > a = message_box("Can't find record "&recordKey&" to update.","",0) > abort(1) > else > > </eucode> {{{ I'm not sure what the problem might be here. Are you saying that odbcError gives a message box saying the error is an invalid handle? Because that would mean the error is coming from MySQL. It seems like a strange error to return. I'd expect something about a bad datatype or something. Matt Lewis
3. Re: Matt's ODBC wrapper and Mysql
- Posted by George Walters <gwalters at sc.rr.com> Nov 01, 2004
- 625 views
Matt, You're right, the message box should have displayed a syntax error at some point on the line. It has done that in the past. The exact text was the same as in your odbcError routine, error #0: "invalid ODBC handle". The return code was -29. I printed the sql statment and saw there was an error, fixed it and the "invalid ODBC handle" message went away. george
4. Matt's ODBC wrapper and Mysql
- Posted by George Walters <gwalters at sc.rr.com> Nov 03, 2004
- 641 views
Matt, It seems that all syntax errors in an SQL statement are now being reported as invalid handle. I beleive this began when I upgraded MySql to their current version 4.015. At least this has been the case of the last 3 or 4 bugs of mine. On the older MySql it always seemed to report the position on the line and showed the text following that position. Have you found anything that might remedy this? I've also noticed from an executing program when I close the DB that my dos screen which is running MySql line interpreter usually loses it's connection to the data base.. any thoughts on this one? A command of "use DBname" reconnects. george
5. Re: Matt's ODBC wrapper and Mysql
- Posted by Matt Lewis <matthewwalkerlewis at yahoo.com> Nov 03, 2004
- 652 views
George Walters wrote: > > > Matt, It seems that all syntax errors in an SQL statement are now being > reported as invalid handle. I beleive this began when I upgraded MySql > to their current version 4.015. At least this has been the case of the > last 3 or 4 bugs of mine. On the older MySql it always seemed to report the > position on the line and showed the text following that position. Have you > found anything that might remedy this? I don't know. I have v4.0.21, and here's the error message I got from a bad query: ODBC Error 0: [4] [MySQL][ODBC 3.51 Driver][mysqld-4.0.21-nt]Unknown column 'x' in 'field list' > I've also noticed from an executing program when I close the DB that my dos > screen which is running MySql line interpreter usually loses it's connection > to > the data base.. any thoughts on this one? A command of "use DBname" > reconnects. Were you able to run queries without the 'use' command previously? Because I believe you either need to do the 'use db' command or add the db name to table and field names. Matt Lewis
6. Re: Matt's ODBC wrapper and Mysql
- Posted by George Walters <gwalters at sc.rr.com> Nov 03, 2004
- 635 views
Maybe it's a bug that 4.021 fixed...I'll down load it. On the dos comand issue. I've always used the "use DB" to connect. But what I'm saying is after that and having run some commands that when an EU program uses a closeDb function caused it to lose it's connection to the db. Again entering the command to "use db" it will again connect and work as expected. Not a big issue but just curious. george
7. Re: Matt's ODBC wrapper and Mysql
- Posted by Matt Lewis <matthewwalkerlewis at yahoo.com> Nov 03, 2004
- 633 views
George Walters wrote: > > Maybe it's a bug that 4.021 fixed...I'll down load it. > > On the dos comand issue. > I've always used the "use DB" to connect. But what I'm saying is after that > and having run some commands that when an EU program uses a closeDb function > caused > it to > lose it's connection to the db. Again entering the command to "use db" it will > again connect and work as expected. Not a big issue but just curious. Yeah, sounds like something internal to MySQL. Matt Lewis
8. Matt's ODBC wrapper and Mysql
- Posted by George Walters <gwalters at sc.rr.com> Nov 04, 2004
- 633 views
Matt, what do you make of this? I don't know what happened. It consistently crashes. C:\EUPHORIA\include\odbc.ew:972 in function getHandleODBC() subscript value 0 is out of bounds, reading from a sequence of length 41 id = 0 ... called from C:\EUPHORIA\include\odbc.ew:1156 in procedure freeHandleODBC() id = 0 handle = <no value> ix = <no value> ... called from C:\EUPHORIA\include\odbc.ew:1706 in function execDirectODBC() hconn = 2 sql = {105'i',110'n',115's',101'e',114'r',116't',32' ',105'i',103'g', 110'n',111'o',114'r',101'e',32' ',105'i',110'n',116't',111'o',32' ',97'a', 112'p',79'O',112'p',101'e',110'n',32' ',118'v',97'a',108'l',117'u',101'e', 115's',32' ',40'(',34'"',32' ',49'1',32' ',32' ',32' ',49'1',48'0',48'0', 57'9',48'0',53'5',53'5',52'4',52'4',54'6',52'4',32' ',32' ',52'4',32' ', 49'1',34'"',32' ',44',',32' ',49'1',44',',32' ',49'1',48'0',48'0',44',', 32' ',34'"',57'9',48'0',53'5',53'5',52'4',52'4',54'6',52'4',34'"',44',', 32' ',52'4',44',',32' ',49'1',44',',32' ',50'2',48'0',48'0',52'4',49'1', 49'1',48'0',52'4',44',',32' ',56'8',57'9',44',',32' ',48'0',44',',32' ', 34'"',49'1',50'2',51'3',34'"',44',',32' ',48'0',44',',32' ',48'0',48'0', 48'0',48'0',48'0',48'0',48'0',48'0',44',',32' ',34'"',34'"',44',',32' ', 48'0',48'0',48'0',48'0',48'0',48'0',48'0',48'0',44',',32' ',34'"',34'"', 44',',32' ',34'"',78'N',34'"',41')'} data = 0 hstmt = 0 ... called from C:\Acutrack\lib/dbfile.e:318 in procedure addDb() t = 3 recordKey = {32' ',49'1',32' ',32' ',32' ',49'1',48'0',48'0',57'9', 48'0',53'5',53'5',52'4',52'4',54'6',52'4',32' ',32' ',52'4',32' ',49'1'} recordDb = {1,100'd',{57'9',48'0',53'5',53'5',52'4',52'4',54'6',52'4'}, 4,1,{2004,11,4},89,0,{49'1',50'2',51'3'},0,{0,0,0},{},{0,0,0},{},{78'N'}} a = <no value> tmp = <no value> ... called from apu110.exw:979 in procedure postChecks() tmpRec = <no value> i = 2 george
9. Re: Matt's ODBC wrapper and Mysql
- Posted by Matt Lewis <matthewwalkerlewis at yahoo.com> Nov 04, 2004
- 654 views
George Walters wrote: > > > Matt, what do you make of this? I don't know what happened. It consistently > crashes. > > C:\EUPHORIA\include\odbc.ew:972 in function getHandleODBC() > subscript value 0 is out of bounds, reading from a sequence of length 41 > id = 0 > > ... called from C:\EUPHORIA\include\odbc.ew:1156 in procedure freeHandleODBC() > > id = 0 > > ... called from C:\EUPHORIA\include\odbc.ew:1706 in function execDirectODBC() > > hconn = 2 It looks to me like there was a problem in allocating the statement handle from within runDirectODBC, however, the error isn't trapped correctly. Try replacing runDirectODBC and execDirectODBC with the following, and you should be able to get a valid error for why the statement handle wasn't created:
--/topic API --/func runDirectODBC( atom hconn, sequence sql ) --Same as /execDirectODBC(), but runDirectODBC() does not return any data. You --must use /getColumnHeaders() and /getData(). This function returns an ODBC --statement handle, which must be freed by the application ( /freeHandleODBC). global function runDirectODBC( atom hconn, sequence sql ) sequence data, data_type atom hstmt, h_ptr, ok, mset, handle, ptr1, ptr2, ptr3, ptr4, ptr5, ptr6, ptr7, hs integer cols, row atom len data = {} -- mset = new_memset() h_ptr = allocate( 4 ) hstmt = allocHandleODBC( SQL_HANDLE_STMT, hconn ) free( h_ptr ) if not hstmt then return 0 end if hs = getHandleODBC( hstmt ) h_ptr = allocate_string( sql ) ok = c_func( SQLExecDirect, { hs, h_ptr, length( sql ) }) free( h_ptr ) if not SQL_SUCCEEDED( ok ) then return -hstmt end if return hstmt end function --/topic API --/func execDirectODBC( atom hconn, sequence sql ) -- --Returns the results of query sql_text. This function ignores the settings made --by /setMaxRecords. If no errors occur, /execDirectODBC frees the statement handle --it creates. If there is an error, a negative handle is returned, so --that the application can query for errors. The returned handle may be either the --statement or the connection, if there was an error in allocating the handle. --The statment handle (if one was created) must then be freed by --the application ( /freeHandleODBC) to avoid resource leakage. global function execDirectODBC( atom hconn, sequence sql ) object data atom hstmt, records hstmt = runDirectODBC( hconn, sql ) if hstmt > 0 then current_handle = hstmt records = max_records max_records = -1 data = {getColumnHeaders( hstmt )} & getData( hstmt ) max_records = 1 -- Josef Jindra: freeHandleODBC( hstmt ) elsif hstmt then data = hstmt else data = - hconn end if return data end function
Matt Lewis
10. Re: Matt's ODBC wrapper and Mysql
- Posted by George Walters <gwalters at sc.rr.com> Nov 04, 2004
- 612 views
It made the fix and it now returns "ODBC error #0: Invalid ODBC Handle". Don't know why. BTW: MySQL 4.1.7 in now the suggested download however I could not get it to install. It quit during the setup when trying to start the service, with no help on why or what to do. I installed 4.0.22 and it's working but with the above error. This program last worked with 4.0.15. Soooo, I'm at a loss. george
11. Re: Matt's ODBC wrapper and Mysql
- Posted by Matt Lewis <matthewwalkerlewis at yahoo.com> Nov 04, 2004
- 643 views
George Walters wrote: > > It made the fix and it now returns "ODBC error #0: Invalid ODBC Handle". > Don't know why. > > BTW: MySQL 4.1.7 in now the suggested download however I could not get it > to install. It quit during the setup when trying to start the service, with > no help on why or what to do. I installed 4.0.22 and it's working but with > the above error. This program last worked with 4.0.15. Soooo, I'm at a loss. I don't know what to tell you. It seems like a MySQL thing. The only other thing I'd recommend is use prepare/execute getData rather than execDirect, so that you can more easily see where the error is happening. If you're getting invalid handle from here, it sounds like there's a problem with the connection. For kicks, you could try disconnecting and then reconnecting. Matt Lewis
12. Re: Matt's ODBC wrapper and Mysql
- Posted by George Walters <gwalters at sc.rr.com> Nov 05, 2004
- 632 views
My bug here. I had actually closed the database then tried to write to it. The fix on the reported error sure helped find it. thanks Matt. george
13. Re: Matt's ODBC wrapper and Mysql
- Posted by George Walters <gwalters at sc.rr.com> Nov 05, 2004
- 624 views
Matt, would you know how to track down "error #124 from the table Handler " ODBC interface? About 8 or so reads through a program that loads gl figures into a financial format, I get that message returned from ODBC. I've searched through the MySQL docs for "124" and don't find a match. george
14. Re: Matt's ODBC wrapper and Mysql
- Posted by Matt Lewis <matthewwalkerlewis at yahoo.com> Nov 08, 2004
- 659 views
- Last edited Nov 09, 2004
George Walters wrote: > Matt, would you know how to track down "error #124 from the table Handler" > ODBC interface? About 8 or so reads through a program that loads gl figures > into a financial format, I get that message returned from ODBC. I've searched > through the MySQL docs for "124" and don't find a match. What function did you call that returned the error? Is that the actual error message that is returned? Matt Lewis
15. Re: Matt's ODBC wrapper and Mysql
- Posted by George Walters <gwalters at sc.rr.com> Nov 09, 2004
- 632 views
Matt, don't worry about that one. The data base appeared corrupted. After the message, junked up data was being returned,then a few minutes later it cleared up. I did nothing to clear it up. It must have been a MySQL bug that appeared and went away. I'm thinking it was perhaps a buffer issue. I'm testing update programs and periodically copy a backup set of data back to the set I'm using. I think that was what confused it. Would this make sense? The error messaged text was what was returned from execDirect. That was pretty close to the text. I couldn't clip it from the messageBox. george Matt Lewis wrote: > > > posted by: Matt Lewis <matthewwalkerlewis at yahoo.com> > > > George Walters wrote: > >>Matt, would you know how to track down "error #124 from the table Handler" >>ODBC interface? About 8 or so reads through a program that loads gl figures >>into a financial format, I get that message returned from ODBC. I've searched >>through the MySQL docs for "124" and don't find a match. > > > What function did you call that returned the error? Is that the actual > error message that is returned? > > Matt Lewis > > > >
16. Matt's ODBC wrapper and Mysql
- Posted by George Walters <gwalters at sc.rr.com> Oct 20, 2004
- 634 views
Matt, I'm at a road block using your ODBC wrapper and Mysql. I'm getting "out of memory" reported from XP and the program then crashes with an ODBC error.I've tried this with several rather simple programs. I'm simply reading "next larger key" through an inventory file. Here's the function that reads next records:
recDb = execDirectODBC(dbId,"select * from " & openTbNames[t] & " where dbKey > \"" & lastKey[t] & "\" limit 1")
After about 15, 000 records out of 22,300 it croaks with the "out of memory" issue. I would think that this would not consume all the memory. I have about 150mb available before the program starts. Here's the read loop: I've rem'd out building the sort table trying to find if the memory issue was caused by my program. After this failure the XP computer performance is hosed and never recovers. I have to reboot to get it back.
dbRec = readNextDb (icBranch) -- ic Branch read next while not EOF[icBranch] do icbrKey = dbRec[1] icbrRec = dbRec[2] if icbrRec[icbrWhseNbr] = whseNbr then icmaRec = readDb(icMaster, icbrRec[1]) if not EOF[icMaster] then if equal(iccoRec[iccoCostCd], "S") then itemCost = icmaRec[icmaStdCost] else itemCost = icmaRec[icmaAvgCost] end if unitVol = round(max(0,icbrRec[icbrAvgMthlyUse])*12 * itemCost,0) totalVol += unitVol --sortKeys = append(sortKeys, sprintf("%9d",(999999999 - unitVol))) --fileKeys = append(fileKeys,{icbrKey}) setText(statusBar,"***** Calculating Sales Volumes ***** "&icbrKey[1..20]) else -- if no master then delete it?? tmp = message_box("Branch Item " & icbrRec[1] & " has no master file record","",0) end if end if dbRec = readNextDb (icBranch) -- ic Branch read next end while
I hope you have some idea to explain the of memory failure. The computer has 256Mb and there is about 150Mb available before the program launches. thanks for any help george
17. Re: Matt's ODBC wrapper and Mysql
- Posted by Matt Lewis <matthewwalkerlewis at yahoo.com> Oct 20, 2004
- 640 views
George Walters wrote: > > > Matt, I'm at a road block using your ODBC wrapper and Mysql. I'm getting > "out of memory" reported from XP and the program then crashes with an > ODBC error.I've tried this with several rather simple programs. I'm > simply reading "next larger key" through an inventory file. Here's the > function that reads next records: Which version do you have? v1.31.1 fixed a resource leak in execDirectODBC(). This could be the cause of your problem. Matt Lewis
18. Re: Matt's ODBC wrapper and Mysql
- Posted by George Walters <gwalters at sc.rr.com> Oct 20, 2004
- 670 views
gezz!! I'm running 1.2 I'll look for the updated version. thanks george
19. Re: Matt's ODBC wrapper and Mysql
- Posted by Matt Lewis <matthewwalkerlewis at yahoo.com> Oct 21, 2004
- 634 views
- Last edited Oct 22, 2004
George Walters wrote: > > I'm simply reading "next larger key" through an inventory file. > Here's the function that reads next records: > > }}} <eucode> > > recDb = execDirectODBC(dbId,"select * from " & openTbNames[t] & > " where dbKey > \"" & lastKey[t] & "\" limit > 1") > > </eucode> {{{ George, if you're doing this to run through the table, you might consider using createCursor() and moveToRecord():
the_cursor = createCursor( dbId, "select * from " & openTbNames[t] & " order by dbKey" ) key = moveToRecord( the_cursor, SQL_FETCH_FIRST, 1 ) while length( key ) do -- ...do stuff with data key = moveToRecord( the_cursor, SQL_FETCH_NEXT, 1 ) end while
Matt Lewis PS Jonas sent me some changes that allow the library to work under Linux using UnixODBC. I hope to have v1.33 tested and released by next week.
20. Re: Matt's ODBC wrapper and Mysql
- Posted by George Walters <gwalters at sc.rr.com> Oct 21, 2004
- 642 views
- Last edited Oct 22, 2004
Thanks, Matt. I'm aware of the create cursor and have used it. At this point I have the data access completely separate from any of the software. I can use EU data base, Tsunami, or ODBC with just changing an include. When I have finished the complete project and know that ODBC and mysql will work I will then go into all these programs that use sequential reads and imbed cursors inside the programs. But for now,... I've installed your latest version and still after about 15,000 reads it crashes. Sometimes with a memory complaint, but sometimes other strange messages. Do you know how much memory should be available? The programs start with about 150MB available memory. I was also wondering if we used a column type of "BLOB" in mysql if that could be an EU sequence that could be written out and read back in w/o any conversion at all. If that's possible it would be pretty neat and speed up I/O a lot. I also want to use "BLOB" type to archive printed invoices which will vary in length w/o having each printed line a table row. Any thoughts? george