Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion Groups
Database Servers
DB2InformixIngresMS SQLOraclePervasive.SQLPostgreSQLProgressSybase
Desktop Databases
FileMakerFoxProMS AccessParadox
General
General DB TopicsDatabase Theory
Related Topics
Java Development.NET DevelopmentVB DevelopmentMore Topics ...

Database Forum / DB2 Topics / August 2006

Tip: Looking for answers? Try searching our database.

create procedure problem - db2 8.2.3 (DPF) on AIX - help?

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
peteh - 29 Aug 2006 15:00 GMT
Hi All;
I have what I hope is a simple environmental problem. I have some SQL
that creates a VERY simple procedure. When the create is executed from
Quest (from a Windows client) - no problem. As soon as I go to the
command line (on the actual DB server), I get a strange (and somewhat
frightening) sqlcode -1007 (corrupt tablespace!?). I'm pretty sure it
has something to do with CLP/statement terminator behavior, but cannot
find the recipe for success. Any help really appreciated!

Here's the SQL that runs fine from Windows/Quest:

CREATE PROCEDURE DVLXTRCT_TEST_ECHO_SP
(IN P_ECHO_TEXT CHARACTER(50)
)
 DYNAMIC RESULT SETS 1
 LANGUAGE SQL
 NOT DETERMINISTIC
 CALLED ON NULL INPUT
 READS SQL DATA
 INHERIT SPECIAL REGISTERS
 pgm: begin
               DECLARE c1 CURSOR WITH RETURN TO CALLER FOR
               values(P_Echo_Text)
;
 -- to return result set, do not CLOSE cursor
       OPEN c1;
 end;
=========================================================
=========================================================

Here is my command line session with the sqlcode:
--> db2 connect to xxxxx

  Database Connection Information

Database server        = DB2/AIX64 8.2.3
SQL authorization ID   = xxxxxxxx
Local database alias   = xxxxxxxxxxx

--> db2 -atf pete_test_proc.ddl

SQLCA Information

sqlcaid : SQLCA     sqlcabc: 136   sqlcode: 1007   sqlerrml: 0
sqlerrmc:
sqlerrp : SQL08023
sqlerrd : (1) 0                (2) 0                (3) 0
          (4) 0                (5) 0                (6) 0
sqlwarn : (1)      (2)      (3)      (4)        (5)       (6)
          (7)      (8)      (9)      (10)       (11)
sqlstate:

explanation of sqlcode -1007
----------------------------------------------------------
User Response:

Discontinue use of the object or table space. Contact IBM service
to inspect the object and the table space.

sqlcode :   -1007

====================================================================
====================================================================

I have tried replacing the semi-colons with @, but get the same error.
Help?!

Pete H
Raj - 29 Aug 2006 15:54 GMT
I replaced the semi column   with an @ and ran it as db2 -td@ -vsf
proc.sql and it compiles succesfully.  But the error you got it
weird....  try runnning inspect or db2dart on the db
Serge Rielau - 29 Aug 2006 16:52 GMT
> I replaced the semi column   with an @ and ran it as db2 -td@ -vsf
> proc.sql and it compiles succesfully.  But the error you got it
> weird....  try runnning inspect or db2dart on the db

Pete,

Are you sure you didn't misread the SQLCODE? The parser spits
essentially two error codes -104 (syntax error) and -007:
SQL0007N The character "<character>" following "<text>" is
          not valid.

Cheers
Serge

Signature

Serge Rielau
DB2 Solutions Development
IBM Toronto Lab

IOD Conference
http://www.ibm.com/software/data/ondemandbusiness/conf2006/

peteh - 29 Aug 2006 19:32 GMT
Hi Serge;
Below is the actual screen print from my AIX command line:
--> db2 -atf pete_test_proc.ddl

SQLCA Information

sqlcaid : SQLCA     sqlcabc: 136   sqlcode: 1007   sqlerrml: 0
sqlerrmc:
sqlerrp : SQL08023
sqlerrd : (1) 0                (2) 0                (3) 0
          (4) 0                (5) 0                (6) 0
sqlwarn : (1)      (2)      (3)      (4)        (5)       (6)
          (7)      (8)      (9)      (10)       (11)
sqlstate:

Is CLP doing something funky to SQLCA? That might be even more
frightening than a corrupt tables space :-o

Pete H
------------------------------------------------------
> > I replaced the semi column   with an @ and ran it as db2 -td@ -vsf
> > proc.sql and it compiles succesfully.  But the error you got it
[quoted text clipped - 17 lines]
> IOD Conference
> http://www.ibm.com/software/data/ondemandbusiness/conf2006/
peteh - 29 Aug 2006 19:55 GMT
Thanks Raj;
I too tried the @ replacement and got the same error. Is this what you
ran (below)?
============================================================
--> db2 connect to xxxxxxxx

  Database Connection Information

Database server        = DB2/AIX64 8.2.3
SQL authorization ID   = xxxxxxxx
Local database alias   = xxxxxxxx

--> db2 -atf dvlxtrct.pete_test_proc.ddl

SQLCA Information

sqlcaid : SQLCA     sqlcabc: 136   sqlcode: 1007   sqlerrml: 0
sqlerrmc:
sqlerrp : SQL08023
sqlerrd : (1) 0                (2) 0                (3) 0
          (4) 0                (5) 0                (6) 0
sqlwarn : (1)      (2)      (3)      (4)        (5)       (6)
          (7)      (8)      (9)      (10)       (11)
sqlstate:

--> more dvlxtrct.pete_test_proc.ddl

CREATE PROCEDURE DVLXTRCT_TEST_ECHO_SP
(IN P_ECHO_TEXT CHARACTER(50)
)
 DYNAMIC RESULT SETS 1
 LANGUAGE SQL
 NOT DETERMINISTIC
 CALLED ON NULL INPUT
 READS SQL DATA
 INHERIT SPECIAL REGISTERS
 pgm: begin
               DECLARE c1 CURSOR WITH RETURN TO CALLER FOR
               values(P_Echo_Text)@
       OPEN c1@
 end@
=================================================
> I replaced the semi column   with an @ and ran it as db2 -td@ -vsf
> proc.sql and it compiles succesfully.  But the error you got it
> weird....  try runnning inspect or db2dart on the db
Raj - 29 Aug 2006 20:08 GMT
This is the proc.sql
----------------------
CREATE PROCEDURE DVLXTRCT_TEST_ECHO_SP
(IN P_ECHO_TEXT CHARACTER(50)
)
 DYNAMIC RESULT SETS 1
 LANGUAGE SQL
 NOT DETERMINISTIC
 CALLED ON NULL INPUT
 READS SQL DATA
 INHERIT SPECIAL REGISTERS
 pgm: begin
               DECLARE c1 CURSOR WITH RETURN TO CALLER FOR
               values(P_Echo_Text)
;
 -- to return result set, do not CLOSE cursor
       OPEN c1;
 end
@
----------------------------------------
the statement i used to compile: db2 -td@ -vsf proc.sql
peteh - 30 Aug 2006 14:29 GMT
Raj-
Thanks so much for your help. I have gotten the compile to work. It
appears to be my lack of knowleddge of CLP/statement terminator
behavior and a misleading sqlcode that are the issues.

If I could ask you for one more favor, could you help me understand the
CLP options you used so that I can integrate DROP and GRANT statements
into what I'm submitting via CLP?

In effect, I want to do this:
DROP PROCEDURE DVLXTRCT_TEST_ECHO_SP2
;
CREATE PROCEDURE DVLXTRCT_TEST_ECHO_SP2
(IN P_ECHO_TEXT CHARACTER(50)
)
DYNAMIC RESULT SETS 1
LANGUAGE SQL
NOT DETERMINISTIC
CALLED ON NULL INPUT
READS SQL DATA
INHERIT SPECIAL REGISTERS
pgm: begin
DECLARE c1 CURSOR WITH RETURN TO CALLER FOR
values(P_Echo_Text)
;
-- to return result set, do not CLOSE cursor
OPEN c1;
end;

GRANT EXECUTE ON PROCEDURE DVLXTRCT_TEST_ECHO_SP2 TO PUBLIC
@

When I do, I get the following:
--> db2 -td@ -vsf dvlxtrct.pete_test_proc.ddl
GRANT EXECUTE ON PROCEDURE DVLXTRCT_TEST_ECHO_SP2 TO PUBLIC
DB21034E  The command was processed as an SQL statement because it was
not a
valid Command Line Processor command.  During SQL processing it
returned:
SQL0104N  An unexpected token "DROP PROCEDURE DVLXTRCT_TEST_ECHO_SP2
;" was
found following "BEGIN-OF-STATEMENT".  Expected tokens may include:
"<space>".  SQLSTATE=42601

It's clear I have to dig into the CLP environment and educate myself,
but GREATLY appreciate your help!

Pete H

===========================================
> This is the proc.sql
> ----------------------
[quoted text clipped - 17 lines]
> ----------------------------------------
> the statement i used to compile: db2 -td@ -vsf proc.sql
Serge Rielau - 30 Aug 2006 15:05 GMT
> Raj-
> Thanks so much for your help. I have gotten the compile to work. It
> appears to be my lack of knowleddge of CLP/statement terminator
> behavior and a misleading sqlcode that are the issues.
Let's fix this at the root.
At the very first line of your CLP script please add:
--#SET TERMINATOR @
Now all statements will be assumed completed when you type @:

CREATE TABLE T(c1 INT)@

CREATE PROCEDURE P(OUT a INT)
BEGIN
  SET a = 5;
END@

....
If you want to change the terminator back to ; just type:
--#SET TERMINATOR ;

Now you can use db2 -t <filename>

Cheers
Serge

Signature

Serge Rielau
DB2 Solutions Development
IBM Toronto Lab

IOD Conference
http://www.ibm.com/software/data/ondemandbusiness/conf2006/

peteh - 30 Aug 2006 16:11 GMT
Hi Serge;
Excellent! Thanks very much. Once again you have saved me from pulling
my (my ever-receding) hair out.

Pete H

> > Raj-
> > Thanks so much for your help. I have gotten the compile to work. It
[quoted text clipped - 28 lines]
> IOD Conference
> http://www.ibm.com/software/data/ondemandbusiness/conf2006/
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.