I have read many many messages about temporary tables and stored
procedures. Still, I am struggling with a simple concept. I have a
java program which creates a temporary table. I now want to access
(read) this table in a stored procedure (written in SQL). This stored
procedure is called from the same java program. My question is - how
do I "compile" the stored procedure and avoid the error message:
DB21034E The command was processed as an SQL statement because it was
not a
valid Command Line Processor command. During SQL processing it
returned:
SQL0204N "SESSION.ALERTS MASSUPDATES" is an undefined name. LINE
NUMBER=15.
SQLSTATE=42704
I am running DB2 V8 on Linux.
Thanks so much
Mike Hubbard 7 7952
You'd have to make anything referencing the table dynamic sql (build the
select in a string var, and the execute immediate on it).
Mike Hubbard wrote: I have read many many messages about temporary tables and stored procedures. Still, I am struggling with a simple concept. I have a java program which creates a temporary table. I now want to access (read) this table in a stored procedure (written in SQL). This stored procedure is called from the same java program. My question is - how do I "compile" the stored procedure and avoid the error message: DB21034E The command was processed as an SQL statement because it was not a valid Command Line Processor command. During SQL processing it returned: SQL0204N "SESSION.ALERTS MASSUPDATES" is an undefined name. LINE NUMBER=15. SQLSTATE=42704
I am running DB2 V8 on Linux.
Thanks so much Mike Hubbard
Mike,
The declared global temp (aka DGTT) has to exist when you create the
stored procedure.
In my experience customers throw the declarations into a procedure of
it's own, e.g.
CREATE PROCEDURE setup_temps()
BEGIN
DECLARE GLOBAL TEMPORARY TABLE SESSION.T1(c1 INT);
END
%
CALL setup_temps();
CREATE PROCEDURE myproc()...
So whenever you run a CREATE PROCEDURE you would precede it with a
CALL setup_temps();
And in your App you throw in the same CALL:
....
CALL setup_temps();
.....
CALL myproc();
....
Cheers
Serge
--
Serge Rielau
DB2 SQL Compiler Development
IBM Toronto Lab
Mike Hubbard wrote: I have read many many messages about temporary tables and stored procedures. Still, I am struggling with a simple concept. I have a java program which creates a temporary table. I now want to access (read) this table in a stored procedure (written in SQL). This stored procedure is called from the same java program. My question is - how do I "compile" the stored procedure and avoid the error message: DB21034E The command was processed as an SQL statement because it was not a valid Command Line Processor command. During SQL processing it returned: SQL0204N "SESSION.ALERTS MASSUPDATES" is an undefined name. LINE NUMBER=15. SQLSTATE=42704
Besides Serge's and Sean's remarks, there is yet another way:
Have one procedure (or normal statement) create the temp table, and in the
body of the stored procedure that you want to create, you can do this:
CREATE PROCEDURE ...
BEGIN
IF 1 = 0 THEN
DECLARE GLOBAL TEMPORARY TABLE mytemp ...
END IF
-- now you can use "mytemp"
END
That way, you avoid the SQL0204 but the temp table is not created inside the
procedure. At execution time, the already existing temp table is used
instead.
--
Knut Stolze
Information Integration
IBM Germany / University of Jena
I go from very frustrated to having 3 great options. Thanks so much to everyone.
Mike
Knut Stolze <st****@de.ibm. com> wrote in message news:<c5******* ***@fsuj29.rz.u ni-jena.de>... Mike Hubbard wrote:
I have read many many messages about temporary tables and stored procedures. Still, I am struggling with a simple concept. I have a java program which creates a temporary table. I now want to access (read) this table in a stored procedure (written in SQL). This stored procedure is called from the same java program. My question is - how do I "compile" the stored procedure and avoid the error message: DB21034E The command was processed as an SQL statement because it was not a valid Command Line Processor command. During SQL processing it returned: SQL0204N "SESSION.ALERTS MASSUPDATES" is an undefined name. LINE NUMBER=15. SQLSTATE=42704
Besides Serge's and Sean's remarks, there is yet another way:
Have one procedure (or normal statement) create the temp table, and in the body of the stored procedure that you want to create, you can do this:
CREATE PROCEDURE ... BEGIN IF 1 = 0 THEN DECLARE GLOBAL TEMPORARY TABLE mytemp ... END IF
-- now you can use "mytemp" END
That way, you avoid the SQL0204 but the temp table is not created inside the procedure. At execution time, the already existing temp table is used instead.
Correct. This "pseudo-pragma" approach does have an achilles-heel however.
It lies in the fact that the definitoion for the DGTT is now not
centralized.
CREATE PROCEDURE p1(OUT c3 INT)
BEGIN
DECLARE c1 INT;
DECLARE c2 INT DEFAULT 5;
DECLARE c3 INT;
IF 1 = 0 THEN
DECLARE GLOBAL TEMPORARY TABLE SESSION.T1
(c1 INT);
END ID;
SELECT c2 + c1 INTO c3 FROM SESSION.T1;
END
@
DECLARE GLOBAL TEMPORARY TABLE SESSION.T1
(c1 INT, c2 INT)
@
INSERT INTO SESSION.T1 VALUES (1, 2)
@
CALL p1(?)
=> c3: 6
Good luck debugging that one.
Other scenarios are implicit bind errors.
The SQL/PSM standard requires variables to be resolved form the inside out.
I.e. first DB2 will try to bind c2 to the table. Only if that fails it
binds to the variable c2 (moving from the inner most compount towards
the parameters (and in some future version to global variables).
The decision what is part of the SQL Query and what is a variable of
sorts is made at CREATE PROCEDURE time. It is irrevocable.
So if you pass in another signature, add a column to a table, doesn't
matter. DB2 has made up its' midn on who is who.
It's one of those things where the SQL Standard isn't exactly
encouraging usability. Read: It pays to have a naming convention.
Cheers
Serge
--
Serge Rielau
DB2 SQL Compiler Development
IBM Toronto Lab
Serge,
Couldn't
CALL setup_temps();
simply be put into myproc() ??
Thus relieving the App. of the CALL myproc(); ?
also, would this then allow myproc() to be implemented
as static sql?
- a problem we had with temp tables were that they precluded
the procedures from being static.
I'll try anyway.
Thanks.
Paul.
Serge Rielau <sr*****@ca.e ye-be-em.com> wrote in message news:<c5******* ***@hanover.tor olab.ibm.com>.. . So whenever you run a CREATE PROCEDURE you would precede it with a CALL setup_temps();
And in your App you throw in the same CALL: ... CALL setup_temps(); .... CALL myproc(); ...
Cheers Serge
Paul,
If the temp table does not exist when you create the procedure then
the you need to use dynamic SQL.
However. If you do the CALL in your DDL script, then the procedure will
create just fine with static SQL.
This does not preclude you from embedding the CALL into the stored
procedure for execution.
Note that all statemenst that involve temp tables will be compiled on
the fly once the procedure executes for the first time and recompiled
everytime the temp gets recreated.
This technique is liek dynamic SQL in a way, but it observes
conservative semantics (timestamp, function reolution, schema, path, ...).
You find it explained in VALIDATE RUN under BIND or PREPARE.
Cheers
Serge
--
Serge Rielau
DB2 SQL Compiler Development
IBM Toronto Lab This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Yannick Turgeon |
last post by:
Hello all,
I'm using SS2K on W2K.
Brieffing: Many months ago, I created a stored procedure only used by those
with admin rights in SS. Now, someone else (without admin rights) has to run
it. I gave him rigth to execute the SP but, at the second and more
execution, he got a error message concerning a temp table already existing
(see...
|
by: nedbollard |
last post by:
Hi,
Having checked out a declared (rather than created) temporary table
successfully in SPUFI, I have hit a problem in running the same SQL in
the cobol prog I am ameding to use it.
I have:
existing SQL
declare temporary table
insert in temporary table
|
by: Yaro |
last post by:
Hello
DB2/NT 8.1.6
In procedure (SQL) I declare GLOBAL TEMPORARY TABLE. Sometimes this
procedure is called twice a session and error creating table occure. I know,
I can create table on session begin. I think I can check in procedure
existing this table and declare or not it. Unfortunately I cannot find how
do it. I don't see item in...
|
by: prasad |
last post by:
I am getting sql error during binding a program which access a temporary table.
The temporary table declaration and access methods are given below.
EXEC SQL
DECLARE GLOBAL TEMPORARY TABLE TEM88
LIKE SYSIBM.SYSDUMMY1
END-EXEC.
EXEC SQL
INSERT INTO TEM88
SELECT * FROM SYSIBM.SYSDUMMY1
END-EXEC.
|
by: Joe Weinstein |
last post by:
Hi all. I am debugging a JDBC application. I find that a certain
query that has an order-by clause fails with a
SQL1585N A system temporary table space with sufficient page size does not exist.
I can understand if there is not enough room for the temp data for sorting,
but why should the page *size* matter?
thanks,
Joe Weinstein at...
| |
by: gimme_this_gimme_that |
last post by:
I'm new to DB2 ...
The following statement results in a SQL1585N message :
"A system temporary table space with sufficient page size does not
exist"
Note that the column FIELD_DETAIL is a BLOB.
Is there something inefficent about the SQL and CASE statement
below that makes this error occur?
|
by: Adam W. Saxton |
last post by:
We have a few existing stored procedures which create a Global Temporary
Table (##), do some work on the table and then delete the table.
The issue we have is that if our Server application is using these is
running and then our Web application fires off, the Temp table is getting
deleted.
My thought was to change the Global Temporary...
|
by: OfficeDummy |
last post by:
Hello all!
I searched the Internet and this forum for a similar problem, but I found no help... Also, I'm a complete newbie to the fascinating world of programming, VBA and Access, so my question can very well be very stupid.
The tasks are:
1)Import an Excel table into Access
2)Add a new column and fill it with variables of date/time...
|
by: sonysunny |
last post by:
Hai,
I have a temporary table created in a stored procedure.How can i access that temporary table from another stored procedure.
thanks in advance.
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language...
| |
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |