Results 1 to 2 of 2
  1. #1
    Join Date
    Jan 2016

    Question Unanswered: HELP: How to EVAL a SELECT String and EXECUTE

    Hi, I am a newbie to Informix and this forum, so, the more hand-holding, the better, as long as your hands are not sticky.

    I wrote a function, StoogeFunk, that uses FOREACH against systables and syscolumns, to concatenate in a string the list of fields in a table (the name of which is passed as a function parameter). I surround with CAST/VARCHAR(30) the date fields, for reasons I dare not explain. So, I come to a point where I have in a string, SelectString, the equivalent of:

    SELECT Name, CAST(DOB AS VARCHAR(30)) AS DOB, ShoeSize FROM Stooges

    My function simply returns that LVARCHAR string (and it is a long one, due to many fields). That result-text SELECT works fine in a query window.

    1. ) Now, instead of returning that string (a simple "RETURN SelectString;" line before "END FUNCTION;"), I want to execute the string, returning from the function a nice, big, juicy bunch of records. I imagine something like an EVAL:

    RETURN EVAL(SelectString);

    How may I reach that dream?

    2.) If the above is impossible, could I call the SelectString-result function externally?

    EXECUTE EVAL(StoogeFunk("StoogeTable"))

    How would that be workable?

    Thanks in advance for washing your hands and helping out!

  2. #2
    Join Date
    Sep 2011
    Pont l'Abbé, Brittany, France
    Provided Answers: 1

    sorry for the delay ....Not sure I fully got what you want to do.

    In stored procedures, you can PREPARE statements. I think this may be part of the solution.
    check here

    There is NO eval command in SPL, simply due to a big security question.
    Also think about building a UDR with Java Code, this may be another solution.

    Go for it!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts