Re: Prepare statement in SPL
Posted in 2001
Topics: Stored Procedures & SPL
Hello
thanks for responding ..
>How about this ?
>in SPL
> let mytable = "mytable";
> let str = "select max(blah) from " || mytable;
> prepare myquery from str;
nope, the parser just barfs at the word "prepare". Syntax error (-201).
below is the full procedure I tested.
>>As in the example, I want to use a variable for a tablename, in SPL.
>>Is there a workaround ?
>================================
>create procedure test();> define str char(256);
> define mytable char(256);
>
>
> let mytable = "mytable";
> let str = "select max(blah) from " || mytable;
>
> prepare myquery from str;
>end procedure;
>=================================
thanks,
*-pike
*----------pike-------------*
Instructions for Life in the new millennium (2001>) from the Dalai Lama:
* Take into account that great love and great achievements involve great risk.
* When you lose, do not lose the lesson.
* Follow the three Rs: Respect for self, respect for others, responsibility for all your actions.
* Remember that not getting what you want is sometimes a wonderful stroke of luck.
* Learn the rules so you know how to break them properly.
* Do not let a little dispute injure a great friendship.
* When you realize you have made a mistake, take immediate steps to correct it.
* Spend some time alone every day.
* Open your arms to change, but do not let go of your values.
* Remember that silence is sometimes the best answer.
* Live a good, honorable life. Then, when you get older and think back,
you will be able to enjoy it a second time.
* A loving atmosphere in your home is the foundation for your life.
* In disagreements with loved ones, deal only with the current
situation. Do not bring up the past.
* Share your knowledge. It is a way to achieve immortality.
* Be gentle with the earth.
* Once a year, go someplace you have never been before.
* Remember that the best relationship is one in which your love for
each other exceeds your need for each other.
* Judge your success by what you had to give up in order to get it.
* Approach love and cooking with reckless abandon.
Pike wrote:
> thanks for responding ..
>
> >How about this ?
> >in SPL
> > let mytable = "mytable";
> > let str = "select max(blah) from " || mytable;
> > prepare myquery from str;
>
> nope, the parser just barfs at the word "prepare". Syntax error (-201).
> below is the full procedure I tested.
>
> >>As in the example, I want to use a variable for a tablename, in SPL.
> >>Is there a workaround ?
>
> >================================
> >create procedure test();> > define str char(256);
> > define mytable char(256);
> >
> >
> > let mytable = "mytable";
> > let str = "select max(blah) from " || mytable;
> >
> > prepare myquery from str;
> >end procedure;
> >=================================
SPL cannot handle dynamic SQL at all, unless you have the Dynamic SQL
UDR(s) that Paul Brown wrote. I find it difficult to believe that this
is not in the FAQ (the basic "No, you can't" part; the reference to the
UDRs might not be there yet).
--
Yours,
Jonathan Leffler (Jonathan.Leffler@Informix.com) #include <disclaimer.h>
Guardian of DBD::Informix v1.00.PC1 -- http://www.perl.com/CPAN
"I don't suffer from insanity; I enjoy every minute of it!"
In article <93um3o$jf0$1@news.xmission.com>, Pike <pike@kw.nl> wrote [ Something about PREPARE in SPL ] > Check out: http://www.iiug.org/software/index_ORDBMS.html The Exec_SQL_UDR() is what you need. Sent via Deja.com http://www.deja.com/