What's wrong with this code ?

Hello Forum,

I’m a newbie with corona and have a problem with a query. see the sniplett below

local mySQL = require"luasql.mysql" local env = assert (luasql.mysql()) local con = assert (env:connect("mand14","user","Password","Server","Port")) local cur = assert (con:execute("SELECT ARTNR FROM mand14.sg\_auf\_artikel Where EANNUMMER = '0088381639767' ")) print(con) print(cur) print(cur:numrows()) row = cur:fetch ({}, "a") while row do   print(string.format("Artikel: %s", row.ARTNR))   -- reusing the table of results   row = cur:fetch (row, "a") end cur:close() con:close() env:close()

When I will run this LUA Prog I got following output

12:40:02.037  Copyright (C) 2009-2017  C o r o n a   L a b s   I n c . 12:40:02.037      Version: 3.0.0 12:40:02.037      Build: 2017.3068 12:40:02.097  Platform: Sensation / x64 / 10.0 / Intel(R) HD Graphics 4600 / 4.3.0 - Build 20.19.15.4531 / 2017.3068 / de\_DE | DE | de\_DE | de 12:40:02.097  Loading project from:   C:\Users\FRANZB~1.BAL\DOCUME~1\Outlaw\Sandbox\10 12:40:02.097  Project sandbox folder: C:\Users\FranzBalleis.BALL\AppData\Local\Corona Labs\Corona Simulator\Sandbox\10-477AEEBEC084C34AB4354A8D16EFBC08\Documents 12:40:02.107  MySQL connection (0B112A50) 12:40:02.107  MySQL cursor (0B0FB628) 12:40:02.107  1 12:40:27.798  The stdin connection has closed.

It seems that the connect and the cursor are ok. Also the query of the numrow seems to bring the result.

But after them within 30 seconds nothing happens .

Effixx

Hi,

Since this is not a pure Lua module, I’m skeptical that it will work with Corona.

To dig deeper into a possible error, try something like:

local res, err = env:connect("mand14","user","Password","Server","Port") print(res, err)

-dev

Meanwhile it seems I found the solution. the problem was this line off code

row = cur:fetch ({}, “a”)

in combination with the sql statement

local cur = assert (con:execute("SELECT ARTNR FROM mand14.sg_auf_artikel Where EANNUMMER = ‘0088381639767’ "

It goes wrong. the statement expected one value (ARTNR) but the fetch line waiting for an Array {}. I changed this statement to receive only von ariable an the result was ok.

Hi,

Since this is not a pure Lua module, I’m skeptical that it will work with Corona.

To dig deeper into a possible error, try something like:

local res, err = env:connect("mand14","user","Password","Server","Port") print(res, err)

-dev

Meanwhile it seems I found the solution. the problem was this line off code

row = cur:fetch ({}, “a”)

in combination with the sql statement

local cur = assert (con:execute("SELECT ARTNR FROM mand14.sg_auf_artikel Where EANNUMMER = ‘0088381639767’ "

It goes wrong. the statement expected one value (ARTNR) but the fetch line waiting for an Array {}. I changed this statement to receive only von ariable an the result was ok.