Re: ESQLC pointer interchange
Posted in 1992
Topics: Connectivity: ESQL/C, 4GL & Embedded SQL, Server Administration
In article <1992Apr30.073237.1307@picasso.cssc-syd.tansu.oz.au>, giggalo@picasso.cssc-syd.tansu.oz.au (Steve Giardullo) writes: |> Hi |> |> I quick question on ESQL C and passing parameters. |> |> If i have a function with a C variable and then pass that variable |> to another function but delcare within the other function that the variable |> is know a ESQL C variable will this cause a problem. |> |> |> EG. |> |> main() |> { |> |> char fred[20]; |> |> esql_fun(fred); |> |> printf("%s",fred); |> } |> |> esql_fun(fred) |> $char * fred; |> { |> EXEC SQL SELECT fred INTO :fred FROM fred; |> } |> |> I have written code and it does work but after a while a get |> a core dump and thats that. |> |> If anyone has any news about this can you mail me. |> |> One more question for all you ESQL programmers what debuggers do |> you use with the .ec files. I have saber-C but am having problems |> using it with the ESQL. Any comments . |> |> |> Thank you in advance |> |> Steven... |> The guess is that Informix likes to write all over memory when giving any opportunity to do so. Your using a pointer inside an SQL function and I am sure that isn't good. My solution would not use any pointer in the esql function. Now I haven't used ESQL/C in a very long time and I don't have time to check this out, but something like this is my guess on what to do: esql_fun(fred_ptr) char * fred_ptr; { $char fred_real(80); EXEC SQL SELECT fred INTO :fred_real FROM fred; strcpy(fred_ptr, fred_real); } I guess I'm only posting this to see what action I can stir up. This seems like a good one to get in on. ------------------------------------------------------------------------------ John R. Carter, Sr. Programmer/Analyst - Informix DBA Computer Sciences Corporation jcarter@nas.nasa.gov Numerical Aerodynamic Simulation 415/604-3662 NASA Ames Research Center, Moffett Field, CA 94035-1000 M/S 258-6 ------------------------------------------------------------------------------