Re: Opinions on approach, please...
- From: Robert <no@xxxxxx>
- Date: Thu, 29 May 2008 12:49:56 -0500
On Thu, 29 May 2008 23:50:59 +1200, "Pete Dashwood" <dashwood@xxxxxxxxxxxxxxxxxxxxxxxxx>
wrote:
"Robert" <no@xxxxxx> wrote in message
news:7i3t34tmtq8u8v410f3rk9jbn99j254jh8@xxxxxxxxxx
On Thu, 29 May 2008 22:39:51 +1200, "Pete Dashwood"
<dashwood@xxxxxxxxxxxxxxxxxxxxxxxxx>
wrote:
"Frederico Fonseca" <real-email-in-msg-spam@xxxxxxxxx> wrote in message
news:7bos345far6d9sglmuc59ga9mfdlu1qe4n@xxxxxxxxxx
On Wed, 28 May 2008 11:55:01 +1200, "Pete Dashwood"
<dashwood@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote:
When using dynamic SQL you almost always need to PREPARE.
You also need to use DESCRIBE in some situations, but NOT in all of
them.
small example below. Take in consideration that dependign on how you
go on the dynamic sql route, you will not be able to do it exactly as
follows.
move "SELECT TABNAME FROM SYSCAT.TABLES
- " ORDER BY 1
"ORDER BY 1" ? I don't understand this.
It's a Cobol continuation line. You're not yet at the end of SELECT.
I'm familiar with COBOL syntax, Robert, having coded 1 or 2 lines of it over
a number of decades... :-)
It was ORDERing something BY 1, that I didn't recognise. (Your comment
didn't explain it either)
It means the first column in the result set. One could alternatively use its name TABNAME.
They allow it because of UNIONs (intersect, minus, etc.), where the first columns in the
select lists might have different names. It's not necessary because the result set uses
names from the first select in the union. The same notation can be used for GROUP BY.
I'm surprised you haven't seen this because it is frequently used (by two finger typists).
- " WHERE TABNAME <> ?" to st.
EXEC SQL PREPARE s1 FROM :st END-EXEC.
EXEC SQL DECLARE c1 CURSOR FOR s1 END-EXEC.
Yes, this is pretty close to what I'm looking at. I used the examples in
the
Fujitsu docs and it is the same as this, except that it makes the declare
of
the cursor part of the statement to be prepared. It is interesting to see
that it it possible to prepare part of a statement. Thanks.
No, it is NOT possible to prepare part of a statement.
You misunderstood.
He has prepared a statement that is then embedded in another statement.
That's what I meant by my comment (I realize it was ambiguous).
Declare is a statement to the precompiler; it is not sent to the server. It defines a
local handle for the cursor. PREPARE creates a remote handle to the compiled select.
OPEN sends either the select, in the case of static, or its remote handle, in the case of
dynamic.
.
- References:
- Re: Opinions on approach, please...
- From: Pete Dashwood
- Re: Opinions on approach, please...
- From: Robert
- Re: Opinions on approach, please...
- From: Pete Dashwood
- Re: Opinions on approach, please...
- From: Robert
- Re: Opinions on approach, please...
- From: Pete Dashwood
- Re: Opinions on approach, please...
- From: Robert
- Re: Opinions on approach, please...
- From: Pete Dashwood
- Re: Opinions on approach, please...
- From: Frederico Fonseca
- Re: Opinions on approach, please...
- From: Pete Dashwood
- Re: Opinions on approach, please...
- From: Robert
- Re: Opinions on approach, please...
- From: Pete Dashwood
- Re: Opinions on approach, please...
- Prev by Date: Re: Opinions on approach, please...
- Next by Date: Re: mySQL
- Previous by thread: Re: Opinions on approach, please...
- Next by thread: Re: Opinions on approach, please...
- Index(es):
Relevant Pages
|