Unix Technical Forum

SQL Procedure problem!!!!

This is a discussion on SQL Procedure problem!!!! within the DB2 forums, part of the Database Server Software category; --> Hi All, I'm trying to create a simple SQL procedure, But DB2 is giving an error..can anyone pls help ...


Go Back   Unix Technical Forum > Database Server Software > DB2

Register FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 02-26-2008, 04:36 PM
Praveen
 
Posts: n/a
Default SQL Procedure problem!!!!

Hi All,

I'm trying to create a simple SQL procedure, But DB2 is giving an
error..can anyone pls help in this..My proc is something like this and
stored proc1.db2 file.

CREATE PROCEDURE DB2INST1.Proc1()
LANGUAGE SQL
P1: BEGIN
declare a integer;
declare b integer;
declare c integer;
set c=a+b;
END P1

when i try to create this using db2 -vf proc1.db2..it says..
CREATE PROCEDURE DB2INST1.Proc1()

DB21034E The command was processed as an SQL statement because it was
not a
valid Command Line Processor command. During SQL processing it
returned:
SQL1760N The CREATE statement for stored procedure "PROC1" must have
a valid
LANGUAGE clause, EXTERNAL clause and PARAMETER STYLE clause. LINE
NUMBER=1.

LANGUAGE SQL
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 "END-OF-STATEMENT" was found following
"LANGUAGE
SQL". Expected tokens may include: "JOIN <joined_table>".
SQLSTATE=42601

P1: BEGIN
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 "P1" was found following
"BEGIN-OF-STATEMENT".
Expected tokens may include: "<call>". SQLSTATE=42601

declare a integer;
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 "declare" was found following
"BEGIN-OF-STATEMENT". Expected tokens may include:
"<labeled_begin_atomic>".
SQLSTATE=42601

declare b integer;
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 "declare" was found following
"BEGIN-OF-STATEMENT". Expected tokens may include:
"<labeled_begin_atomic>".
SQLSTATE=42601

declare c integer;
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 "integer;" was found following "declare
c ".
Expected tokens may include: "<space>". SQLSTATE=42601

set c=a+b;
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 "set c=" was found following
"BEGIN-OF-STATEMENT". Expected tokens may include: "<values>".
SQLSTATE=42601

END P1
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 "END-OF-STATEMENT" was found following
"END P1".
Expected tokens may include: "JOIN <joined_table>". SQLSTATE=42601
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 02-26-2008, 04:36 PM
Knut Stolze
 
Posts: n/a
Default Re: SQL Procedure problem!!!!

Praveen <spraveen2001@yahoo.com> wrote:

> Hi All,
>
> I'm trying to create a simple SQL procedure, But DB2 is giving an
> error..can anyone pls help in this..My proc is something like this and
> stored proc1.db2 file.
>
> CREATE PROCEDURE DB2INST1.Proc1()
> LANGUAGE SQL
> P1: BEGIN
> declare a integer;
> declare b integer;
> declare c integer;
> set c=a+b;
> END P1
>
> when i try to create this using db2 -vf proc1.db2..it says..
> CREATE PROCEDURE DB2INST1.Proc1()

[...]

What do you use as statement terminator? The default is the end-of-line,
which would mean that you have 8 different statements above. You might
want to use some other symbol like an '@':

db2 -td@

db2 =>
db2 => CREATE PROCEDURE DB2INST1.Proc1()
db2 => LANGUAGE SQL
db2 => P1: BEGIN
db2 => declare a integer;
db2 => declare b integer;
db2 => declare c integer;
db2 => set c=a+b;
db2 => END P1
db2 => @


--
Knut Stolze
Information Integration
IBM Germany / University of Jena
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 02-26-2008, 04:36 PM
Jan M. Nelken
 
Posts: n/a
Default Re: SQL Procedure problem!!!!

Knut Stolze wrote:

> Praveen <spraveen2001@yahoo.com> wrote:
>
>
>>Hi All,
>>
>>I'm trying to create a simple SQL procedure, But DB2 is giving an
>>error..can anyone pls help in this..My proc is something like this and
>>stored proc1.db2 file.
>>
>>CREATE PROCEDURE DB2INST1.Proc1()
>>LANGUAGE SQL
>>P1: BEGIN
>>declare a integer;
>>declare b integer;
>>declare c integer;
>>set c=a+b;
>>END P1
>>
>>when i try to create this using db2 -vf proc1.db2..it says..
>>CREATE PROCEDURE DB2INST1.Proc1()

>
> [...]
>
> What do you use as statement terminator? The default is the end-of-line,
> which would mean that you have 8 different statements above. You might
> want to use some other symbol like an '@':
>
> db2 -td@
>
> db2 =>
> db2 => CREATE PROCEDURE DB2INST1.Proc1()
> db2 => LANGUAGE SQL
> db2 => P1: BEGIN
> db2 => declare a integer;
> db2 => declare b integer;
> db2 => declare c integer;
> db2 => set c=a+b;
> db2 => END P1
> db2 => @
>
>


.... and Praveen, how do you propose to return the result to caller?

Jan M. Nelken
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump


All times are GMT. The time now is 06:35 PM.


Powered by vBulletin® Version 3.6.5
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.2.0
www.UnixAdminTalk.com