473,405 Members | 2,344 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,405 software developers and data experts.

Create function error DB2 UDB v8.1.5 Linux

I don't understand the following error:

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 "CREATE FUNCTION NALF_PREFIX(tattoo
varchar" was
found following "BEGIN-OF-STATEMENT". Expected tokens may include:
"<values>". LINE NUMBER=8. SQLSTATE=42601

which I received when doing

db2 -td@ -vf $1.db2
on the file:

-- vim: set ai ts=4 sw=4 :
connect to animals@

set schema is3@

-- drop function nalf_prefix@

CREATE FUNCTION nalf_prefix(tattoo varchar(50))
returns varchar(50)
language sql
deterministic
no external action

begin
declare result varchar(50);
result = replace(upcase(tattoo,' ',''));
result = substr(result,1,length(result)-1);
result = replace(translate(tattoo,'','0123456789'),' ','');
return result;
end@

Any help would be appreciated. I thought I followed the example from the
'book' (IBM documentation PDF) pretty faithfully.
Nov 12 '05 #1
5 2836
Bob Stearns wrote:
I don't understand the following error:

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 "CREATE FUNCTION NALF_PREFIX(tattoo
varchar" was
found following "BEGIN-OF-STATEMENT". Expected tokens may include:
"<values>". LINE NUMBER=8. SQLSTATE=42601


Correcting syntax errors renders function usable:

CREATE FUNCTION nalf_prefix(tattoo varchar(50))
returns varchar(50)
language sql
deterministic
no external action

begin atomic
declare result varchar(50);
set result = replace(upper(tattoo),' ','');
set result = substr(result,1,length(result)-1);
set result = replace(translate(tattoo,'','0123456789'),' ','');
return result;
end @
E:\>db2 values nalf_prefix('a1b2c3 d4 e5')

1
--------------------------------------------------
abcde

1 record(s) selected.
Jan M. Nelken
Nov 12 '05 #2
Jan M. Nelken wrote:
Bob Stearns wrote:
I don't understand the following error:

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 "CREATE FUNCTION NALF_PREFIX(tattoo
varchar" was
found following "BEGIN-OF-STATEMENT". Expected tokens may include:
"<values>". LINE NUMBER=8. SQLSTATE=42601

Correcting syntax errors renders function usable:

CREATE FUNCTION nalf_prefix(tattoo varchar(50))
returns varchar(50)
language sql
deterministic
no external action

begin atomic
declare result varchar(50);
set result = replace(upper(tattoo),' ','');
set result = substr(result,1,length(result)-1);
set result = replace(translate(tattoo,'','0123456789'),' ','');
return result;
end @
E:\>db2 values nalf_prefix('a1b2c3 d4 e5')

1
--------------------------------------------------
abcde

1 record(s) selected.
Jan M. Nelken

Thank you. The syntax diagram of the BEGIN statement (Page 767 of SQL
Reference Vol. 1) indicates that the ATOMIC clause is optional, at least
that is how I read it.
Nov 12 '05 #3
Bob Stearns wrote:
I don't understand the following error:

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 "CREATE FUNCTION NALF_PREFIX(tattoo
varchar" was
found following "BEGIN-OF-STATEMENT". Expected tokens may include:
"<values>". LINE NUMBER=8. SQLSTATE=42601

which I received when doing

db2 -td@ -vf $1.db2
on the file:

-- vim: set ai ts=4 sw=4 :
connect to animals@

set schema is3@

-- drop function nalf_prefix@

CREATE FUNCTION nalf_prefix(tattoo varchar(50))
returns varchar(50)
language sql
deterministic
no external action

begin
declare result varchar(50);
result = replace(upcase(tattoo,' ',''));
result = substr(result,1,length(result)-1);
result = replace(translate(tattoo,'','0123456789'),' ','');
return result;
end@

Any help would be appreciated. I thought I followed the example from the
'book' (IBM documentation PDF) pretty faithfully.

http://publib.boulder.ibm.com/infoce...n/r0004240.htm
One word: ATOMIC

Cheers
Serge
--
Serge Rielau
DB2 SQL Compiler Development
IBM Toronto Lab
Nov 12 '05 #4
Bob Stearns wrote:
Jan M. Nelken wrote:
Bob Stearns wrote:
I don't understand the following error:

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 "CREATE FUNCTION NALF_PREFIX(tattoo
varchar" was
found following "BEGIN-OF-STATEMENT". Expected tokens may include:
"<values>". LINE NUMBER=8. SQLSTATE=42601


Correcting syntax errors renders function usable:

CREATE FUNCTION nalf_prefix(tattoo varchar(50))
returns varchar(50)
language sql
deterministic
no external action

begin atomic
declare result varchar(50);
set result = replace(upper(tattoo),' ','');
set result = substr(result,1,length(result)-1);
set result = replace(translate(tattoo,'','0123456789'),' ','');
return result;
end @
E:\>db2 values nalf_prefix('a1b2c3 d4 e5')

1
--------------------------------------------------
abcde

1 record(s) selected.
Jan M. Nelken


Thank you. The syntax diagram of the BEGIN statement (Page 767 of SQL
Reference Vol. 1) indicates that the ATOMIC clause is optional, at least
that is how I read it.

That's the wrong statement.
Only SQL Procedures use the regular compound statement.
Triggers and functions use the dynamic compound statement (see my
earlier URL).

Cheers
Serge
--
Serge Rielau
DB2 SQL Compiler Development
IBM Toronto Lab
Nov 12 '05 #5
Serge Rielau wrote:
Bob Stearns wrote:
I don't understand the following error:

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 "CREATE FUNCTION NALF_PREFIX(tattoo
varchar" was
found following "BEGIN-OF-STATEMENT". Expected tokens may include:
"<values>". LINE NUMBER=8. SQLSTATE=42601

which I received when doing

db2 -td@ -vf $1.db2
on the file:

-- vim: set ai ts=4 sw=4 :
connect to animals@

set schema is3@

-- drop function nalf_prefix@

CREATE FUNCTION nalf_prefix(tattoo varchar(50))
returns varchar(50)
language sql
deterministic
no external action

begin
declare result varchar(50);
result = replace(upcase(tattoo,' ',''));
result = substr(result,1,length(result)-1);
result = replace(translate(tattoo,'','0123456789'),' ','');
return result;
end@

Any help would be appreciated. I thought I followed the example from
the 'book' (IBM documentation PDF) pretty faithfully.


http://publib.boulder.ibm.com/infoce...n/r0004240.htm

One word: ATOMIC

Cheers
Serge

The update documentation differs from the base; I should have looked
there before complaining (I do have it bookmarked). Sorry.
Nov 12 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Alex Page | last post by:
This is probably really basic, but I can't seem to get it to work. I'm trying to create an enumerated type, using the following code: CREATE FUNCTION enum_gender_in (cstring) RETURNS enum_gender...
7
by: dog | last post by:
I've seen plenty of articles on this topic but none of them have been able to solve my problem. I am working with an Access 97 database on an NT4.0 machine, which has many Access reports. I...
8
by: Plissken.s | last post by:
I have a template function which print out the content of a list: The following compiles: void PrintInt2 (int i) { cout << i << " "; } template <class T> void printList(T& list) {
2
by: waitan | last post by:
#include <algorithm> #include <iostream> #include <fstream> #include <string> #include <vector> #include <sstream> #include <iterator> #include <iomanip> using namespace std;
5
by: Michael Sperlle | last post by:
Is it possible? Bestcrypt can supposedly be set up on linux, but it seems to need changes to the kernel before it can be installed, and I have no intention of going through whatever hell that would...
1
by: drk.kumar | last post by:
I have an implementation issue with WMI scripts to check the user machine processor. The implementation is working fine in the local machine (Windows XP operating system). It is throwing script...
5
by: Philip Nelson | last post by:
I get - db2inst1@dvorak /db2data $ db2 "create database DBTST001 automatic storage yes on /db2data/db2db dbpath on /db2data/db2db" SQL0805N Package "NULLID.SQLE2F0J 0X4141414141654557" was not...
15
by: harvey | last post by:
How do I make PHP create a database for mysql please? I can see how to make tables and I have read all the documents I can find but I don't understand how to make the database itself. All...
5
by: Charlie | last post by:
Hi All, I am new to using swig/C++/python. I got some problem with function pointers. I posted in swig-user, but got no response. So I forwarded it here. You help is greatly appreciated. ...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
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,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
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...
0
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...
0
agi2029
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,...
0
isladogs
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...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.