Runtime error is possible because size of
Posted in 2012
Topics: Connectivity: ESQL/C, 4GL & Embedded SQL
Hi all, I do wish a happy new year to all. for a long time my code produces an error while compiling that I have simply ignored. But it is a boring warning. Within my esql/c-Code I have some code like the following: EXEC SQL begin declare section char *pointer; EXEC SQL end declare section pointer=malloc(8192); EXEC SQL select data into :pointer from table where snr=5000 The esqlc-compiler produces a warning like: Runtime error is possible because size of 'pointer' is unknown. I know the meaning of this warning, esqlc simply did not know the size of pointer because it wasn't declared with a static dimension. It only sees the pointer itself. Is there any way to disable the warning? A static declaration isn't a solution. Hopefully someone has an idea. Kind regards Andre -- Andre Koppel Software GmbH Prinz-Handjery-Str. 38 14167 Berlin Tel.: (+4930) 810 09 190 Fax: (+4930) 326 01 046 www.invep.de www.akso.de Eingetragen beim Amtsgericht Berlin Charlottenburg HRB92600 Geschäftsführer Andre Koppel
The only solution, if you really need to make 'pointer' dynamic, is to make the SELECT dynamic. You will have to PREPARE the statement and DESCRIBE it either INTO an SQL descriptor or USING an sqlda structure, then populate the descriptor or sqlda with the pointer to 'pointer' and the length of the memory segment it points to. Then you DECLARE a cursor and OPEN the cursor USING the descriptor or sqlda structure pointer. Art Art S. Kagel Advanced DataTools (www.advancedatatools.com) Blog: http://informix-myview.blogspot.com/ Disclaimer: Please keep in mind that my own opinions are my own opinions and do not reflect on my employer, Advanced DataTools, the IIUG, nor any other organization with which I am associated either explicitly, implicitly, or by inference. Neither do those opinions reflect those of other individuals affiliated with any entity with which I am affiliated nor those of the entities themselves. On Tue, Jan 3, 2012 at 3:07 AM, Andre Koppel <akoppel@akso.de> wrote: > Hi all, > I do wish a happy new year to all. > for a long time my code produces an error while compiling that I have > simply ignored. > But it is a boring warning. > Within my esql/c-Code I have some code like the following: > EXEC SQL begin declare section > char *pointer; > EXEC SQL end declare section > > pointer=malloc(8192); > EXEC SQL select data into :pointer from table where snr=5000 > > The esqlc-compiler produces a warning like: > Runtime error is possible because size of 'pointer' is unknown. > > I know the meaning of this warning, esqlc simply did not know the size > of pointer because it wasn't declared > with a static dimension. It only sees the pointer itself. > Is there any way to disable the warning? A static declaration isn't a > solution. > Hopefully someone has an idea. > Kind regards > Andre > > -- > Andre Koppel Software GmbH > Prinz-Handjery-Str. 38 > 14167 Berlin > Tel.: (+4930) 810 09 190 > Fax: (+4930) 326 01 046 > www.invep.de > www.akso.de > > Eingetragen beim Amtsgericht > Berlin Charlottenburg HRB92600 > Geschäftsführer Andre Koppel > > > > ******************************************************************************* > Forum Note: Use "Reply" to post a response in the discussion forum. > > --e89a8f839c1bd90cf004b59d88cc