473,666 Members | 2,044 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

IF Exists Bad Parser

NHM
I don't know if it's just me, but DB2 seems to have the worst syntatic
parser ever created!

Even after triple checking the documentation online, for the syntax of
the statements the CLP seems to be unable to parse the simplest of
statemets!

For example, I would very much like to have this piece of work to
work:

IF EXISTS ( Select 'DELETE'
from sysibm.routines
where specific_schema = 'NHM'
and ROUTINE_TYPE = 'FUNCTION'
and ROUTINE_NAME = 'TESTCONSTRUCTS ')
THEN DROP FUNCTION TESTCONSTRUCTS
END IF@

The parser messages are ambiguous as always:

Erros msg: An unexpected token "IF EXISTS ( Select 'DELETE'" was
found following "BEGIN-OF-STATEMENT". Expected tokens may include:
"<space>
This wonderful parser is so user friendly, it also seem to be able to
parse better the previous code, if it's surrounded by a BEGIN
Atomic ... END@ statement;
in this last case, the parser only fails when it's faced with the END
IF statement.

I am farily used to both PL/SQL and TSQL and can say without a doubt,
that i've never seen any parser this bad! Not only does CLP force a
person to introduce ending statement characters, not even there own
offical SQL PL syntax is parsable.

Any help?
Sep 30 '08 #1
3 5070
NHM
On 30 Set, 14:30, NHM <Nuno.GodinhoMa ...@gmail.comwr ote:
I don't know if it's just me, but DB2 seems to have the worst syntatic
parser ever created!

Even after triple checking the documentation online, for the syntax of
the statements the CLP seems to be unable to parse the simplest of
statemets!

For example, I would very much like to have this piece of work to
work:

IF EXISTS ( Select 'DELETE'
* * * * from sysibm.routines
* * * * where specific_schema = 'NHM'
* * * * and ROUTINE_TYPE = 'FUNCTION'
* * * * and ROUTINE_NAME = 'TESTCONSTRUCTS ')
THEN DROP FUNCTION TESTCONSTRUCTS
END IF@

The parser messages are ambiguous as always:

Erros msg: An unexpected token "IF EXISTS ( Select 'DELETE'" was
found following "BEGIN-OF-STATEMENT". *Expected tokens may include:
"<space>

This wonderful parser is so user friendly, it also seem to be able to
parse better the previous code, if it's surrounded by a BEGIN
Atomic ... END@ statement;
in this last case, the parser only fails when it's faced with the END
IF statement.

I am farily used to both PL/SQL and TSQL and can say without a doubt,
that i've never seen any parser this bad! Not only does CLP force a
person to introduce ending statement characters, not even there own
offical SQL PL syntax is parsable.

Any help?
On further note I've spotted that after the THEN token, the SQL
statments have to be preceded by a semicolon; a little small detail
hard to notice on the syntax page. Still...
It's not working:

SQL0104N An unexpected token "DROP FUNCTION" was found following
"ESTCONSTRUCTS' )
THEN". Expected tokens may include: "<signal_stmt_h ead>

Code executed:
BEGIN ATOMIC
IF EXISTS ( Select 'DELETE'
from sysibm.routines
where specific_schema = 'NHM'
and ROUTINE_TYPE = 'FUNCTION'
and ROUTINE_NAME = 'TESTCONSTRUCTS ')
THEN DROP FUNCTION TESTCONSTRUCTS;
END IF;
END@

And why "the hell", can't a person put an IF token after a BEGIN
Statement token, as the CLP likes to point out?
Does it have to be inside, a function, procedure or compount statemnt?
Again the documentation tells nothing of the sort.
I can only say: i hate SQL PL, so alike every other procedure
language, and at the same time so much worse!
Sep 30 '08 #2
NHM wrote:
On 30 Set, 14:30, NHM <Nuno.GodinhoMa ...@gmail.comwr ote:
>I don't know if it's just me, but DB2 seems to have the worst syntatic
parser ever created!

Even after triple checking the documentation online, for the syntax of
the statements the CLP seems to be unable to parse the simplest of
statemets!

For example, I would very much like to have this piece of work to
work:

IF EXISTS ( Select 'DELETE'
from sysibm.routines
where specific_schema = 'NHM'
and ROUTINE_TYPE = 'FUNCTION'
and ROUTINE_NAME = 'TESTCONSTRUCTS ')
THEN DROP FUNCTION TESTCONSTRUCTS
END IF@

The parser messages are ambiguous as always:

Erros msg: An unexpected token "IF EXISTS ( Select 'DELETE'" was
found following "BEGIN-OF-STATEMENT". Expected tokens may include:
"<space>

This wonderful parser is so user friendly, it also seem to be able to
parse better the previous code, if it's surrounded by a BEGIN
Atomic ... END@ statement;
in this last case, the parser only fails when it's faced with the END
IF statement.

I am farily used to both PL/SQL and TSQL and can say without a doubt,
that i've never seen any parser this bad! Not only does CLP force a
person to introduce ending statement characters, not even there own
offical SQL PL syntax is parsable.

Any help?

On further note I've spotted that after the THEN token, the SQL
statments have to be preceded by a semicolon; a little small detail
hard to notice on the syntax page. Still...
It's not working:

SQL0104N An unexpected token "DROP FUNCTION" was found following
"ESTCONSTRUCTS' )
THEN". Expected tokens may include: "<signal_stmt_h ead>

Code executed:
BEGIN ATOMIC
IF EXISTS ( Select 'DELETE'
from sysibm.routines
where specific_schema = 'NHM'
and ROUTINE_TYPE = 'FUNCTION'
and ROUTINE_NAME = 'TESTCONSTRUCTS ')
THEN DROP FUNCTION TESTCONSTRUCTS;
END IF;
END@

And why "the hell", can't a person put an IF token after a BEGIN
Statement token, as the CLP likes to point out?
Does it have to be inside, a function, procedure or compount statemnt?
Again the documentation tells nothing of the sort.
I can only say: i hate SQL PL, so alike every other procedure
language, and at the same time so much worse!
I will not discuss whether this is obvious, intuitive or not, but keep
in mind that DROP <objectis an administrative command - not SQL element.

This should work:

db2 -td@ -vf test.sql
BEGIN ATOMIC
IF EXISTS ( Select 'DELETE'
from sysibm.routines
where specific_schema = 'NHM'
and ROUTINE_TYPE = 'FUNCTION'
and ROUTINE_NAME = 'TESTCONSTRUCTS ')
THEN CALL ADMIN_CMD('DROP FUNCTION TESTCONSTRUCTS' );
END IF;
END
DB20000I The SQL command completed successfully.

Jan M. Nelken
Sep 30 '08 #3
SQL0104N An unexpected token "DROP FUNCTION" was found following
"ESTCONSTRUCTS' )
THEN". Expected tokens may include: "<signal_stmt_h ead>
Well the parser is absolutely right here. DROP FUNCTION is not supported
in inline SQL PL (Dynamic compound statement)
dynamic compounds are meant for quick ETL kind of stuff. It's not the
full blown SQL PL.

W.r.t. the other comments send me a note, I may be able to help.

Cheers
Serge
--
Serge Rielau
DB2 Solutions Development
IBM Toronto Lab
Oct 10 '08 #4

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

Similar topics

13
2283
by: Paulo Pinto | last post by:
Hi, does anyone know of a Python package that is able to load XML like the XML::Simple Perl package does? For those that don't know it, this package maps the XML file to a dictionary.
1
5278
by: Karalius, Joseph | last post by:
Can anyone explain what is happening here? I haven't found any useful info on Google yet. Thanks in advance. mmagnet:/home/jkaralius/src/zopeplone/Python-2.3.5 # make gcc -pthread -c -fno-strict-aliasing -DNDEBUG -g -O3 -Wall -Wstrict-prototypes -I. -I./Include -DPy_BUILD_CORE -o Modules/python.o Modules/python.c gcc -pthread -c -fno-strict-aliasing -DNDEBUG -g -O3 -Wall -Wstrict-prototypes -I. -I./Include -DPy_BUILD_CORE -o...
3
3123
by: Himanshu Garg | last post by:
Hello, I am trying to pinpoint an apparent bug in HTML::Parser. The encoding of the text seems to change incorrectly if the locale isn't set properly. However Parser.pm in the directory (/usr/lib/perl5/vendor_perl/5.8.0/i386-linux-thread-multi/HTML/) doesn't seem to contain the "real" parsing statements.
28
2080
by: Stefan Mueller | last post by:
I can display the value of the following input box with alert(parent.MyFrame.document.MyForm.MyInput.value); But if the frame, the form or the input box doesn't exist I get of course an error message. How can I figure out before I display the value if the frame 'MyFrame', the form 'MyForm' and also the input box 'MyInput' exists without getting an error message? Stefan
2
3219
by: Joel Hedlund | last post by:
Hi! I have a possibly dumb question about imports. I've written two python modules: parser.py ------------------------------------ class Parser(object): "my parser" ------------------------------------
5
2325
by: thewarden | last post by:
I've come into a situation where I require to have BBCode parsed, this includes the standard tags supported by PEAR package HTML_BBCodeParser and custom BBCode tags I've added myself. My problem is this, I've discovered that when an value has a space within the value the value is truncated at the first occurrence of the space. This applies to a URL, image file names and any additional attribute values (alt, style, etc.). This issue is...
28
16386
by: Marc Gravell | last post by:
In Linq, you can apparently get a meaningful body from and expression's .ToString(); random question - does anybody know if linq also includes a parser? It just seemed it might be a handy way to write a safe but easy implementation (i.e. no codedom) for an IBindingListView.Filter (by compiling to a Predicate<T>). Anybody know if this is possible at all? Marc
0
2225
by: UncleRic | last post by:
Environment: Mac OS X (10.4.10) on MacBook Pro I'm a Perl Neophyte. I've downloaded the XML::Parser module and am attempting to install it in my working directory (referenced via PERL5LIB env): PERL5LIB=/Users/Ric/Library/Perl/ ls XML-Parser-2.34/ XML-Parser-2.34.tar
18
4712
by: Just Another Victim of the Ambient Morality | last post by:
Is pyparsing really a recursive descent parser? I ask this because there are grammars it can't parse that my recursive descent parser would parse, should I have written one. For instance: from pyparsing import * grammar = OneOrMore(Word(alphas)) + Literal('end') grammar.parseString('First Second Third end')
0
8356
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 synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8869
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8781
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8551
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 most users, this new feature is actually very convenient. If you want to control the update process,...
0
8639
tracyyun
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 choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7386
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6198
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
2
2011
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1775
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.