I am working in a project that I need to parse an arrayt an select
records based upon the values parsed. I used the functions developed by
Knut Stolze in his article 'Parsing Strings'. I am particulary having
problems inserting records using a function.
I am attaching the code for your review. Please, help.
=============== =============== ===--Function
1--=============== =============== ======
CREATE FUNCTION lx2p111.Delimit erIndex ( string varchar(8000),
Delimiter char(1) )
RETURNS TABLE ( ordinal INTEGER, index INTEGER )
-- string = any string delimited by a character
-- Delimiter = the delimimeter character i.e. ',', -, *
-- Description This functions returns the begining and end
position for every array.
-- supports RangeElements function
LANGUAGE SQL
DETERMINISTIC
NO EXTERNAL ACTION
CONTAINS SQL
RETURN
WITH t(ordinal, index) AS
( VALUES ( 0, 0 )
UNION ALL
SELECT ordinal+1, COALESCE(NULLIF (
-- find the next delimiter ','
LOCATE(',', string, index+1), 0),
LENGTH(string)+ 1)
FROM t
WHERE ordinal < 10000 AND
LOCATE(Delimite r, string, index+1) <> 0 )
SELECT ordinal, index
FROM t
UNION ALL
-- add indicator for the end of the string
SELECT MAX(ordinal)+1, LENGTH(string)+ 1
FROM t
=============== =============== ===--Function
2--=============== =============== ======
CREATE FUNCTION LX2P111.RangeEl ements ( string varchar (8000),
delimiter char (1) )
RETURNS TABLE ( elements varchar(255) )
------------------------------------------------------------------------
-- string = any string delimited by a character
-- Delimiter = the delimimeter character i.e. ',', -, *
-- Description This functions returns every array element in the
list (i.e. ranges)
LANGUAGE SQL
DETERMINISTIC
NO EXTERNAL ACTION
CONTAINS SQL
RETURN
WITH t(ordinal, index) AS
( SELECT ordinal, index
FROM TABLE ( LX2P111.Delimit erIndex(string, Delimiter) )
AS x )
SELECT SUBSTR(string, t1.index+1, t2.index - t1.index - 1)
FROM t AS t1 JOIN t AS t2 ON
( t2.ordinal = t1.ordinal+1 )
=============== =============== ===--Stored
Proc--=============== =============== ======
CREATE PROCEDURE LX2P111.LDBS_RE QUISITION_DETAI L_TEST (
IN
ac_req_number_r ange
VARCHAR(8000),
IN adt_begin
DATE
)
DYNAMIC RESULT SETS 1
LANGUAGE SQL
-- ac_req_number_r ange = Requisition ranges (parse string, for
dsicrete values
min=max)
-- adt_begin = The beginning date range to present
(single
value)
-- Description This procedure will parse the ai_req_number_r ange
and insert
-- all rows into temp table. It first checks to see
if there
P1: BEGIN
--Create temp table to hold for the parsed array element values
DECLARE GLOBAL TEMPORARY TABLE SESSION.TempLis t
(
RecordId varchar(255)
) ;
-- Insert record into tempList using function
insert into session.templis t
select *
from table (LX2P111.RangeE lements (ac_req_number_ range, ','))
;
--Insert elelements of array into separate fields
DECLARE GLOBAL TEMPORARY TABLE SESSION.TempLis t2
(
ParamName Varchar(25),
MinValue varchar(15),
Maxvalue varchar(15)
) ;
insert into session.templis t2
select 'ReqNo' ,
left(RecordId, (locate('-', RecordID, 1)-1)) ,
substr (RecordId, (locate('-', RecordId,
1)+1),(length
(RecordId)- (locate('-', RecordId, 1))))
from SESSION.TEMPLIS T;
--Declare cursor
BEGIN
DECLARE MyCursor CURSOR WITH RETURN FOR
select RQH_REQ_LOCATIO N,
RQH_REQ_NUMBER,
RQH_CREATED,
RQH_REQUESTER,
RQH_DELIVER_TO
from lx2p111.requisi tion_detail rd, session.templis t2 t2
where rd.RQH_REQ_NUMB ER between cast(t2.MinValu e as int)
and cast(t2.MaxValu e as Int)
and rd.RLN_CREATED >= coalesce(adt_be gin, '01/01/1900')
;
-- Cursor left open for client application
OPEN MyCursor;
END;
END P1 15 2909
Jaraba wrote: I am working in a project that I need to parse an arrayt an select records based upon the values parsed. I used the functions developed by Knut Stolze in his article 'Parsing Strings'. I am particulary having problems inserting records using a function.
I am attaching the code for your review. Please, help.
What error message are getting? For that matter, are you getting an
error message or are these just not working as you expected?
=============== =============== ===--Function 1--=============== =============== ======
CREATE FUNCTION lx2p111.Delimit erIndex ( string varchar(8000), Delimiter char(1) ) RETURNS TABLE ( ordinal INTEGER, index INTEGER )
-- string = any string delimited by a character -- Delimiter = the delimimeter character i.e. ',', -, * -- Description This functions returns the begining and end position for every array. -- supports RangeElements function
LANGUAGE SQL DETERMINISTIC NO EXTERNAL ACTION CONTAINS SQL RETURN WITH t(ordinal, index) AS ( VALUES ( 0, 0 ) UNION ALL SELECT ordinal+1, COALESCE(NULLIF ( -- find the next delimiter ',' LOCATE(',', string, index+1), 0),
Well, looks like these are basically the same as the functions Knut
wrote about in his article, although you've added a parameter to make
the delimiter character configurable. Unfortunately, in the line above,
you've still got a constant ',' that needs to be replaced with
DELIMITER.
LENGTH(string)+ 1) FROM t WHERE ordinal < 10000 AND LOCATE(Delimite r, string, index+1) <> 0 )
SELECT ordinal, index FROM t UNION ALL -- add indicator for the end of the string SELECT MAX(ordinal)+1, LENGTH(string)+ 1 FROM t
[snip]
Dave.
--
I am getting an error in the following piece of code, everything else
works well specially the ones yjay Knut wrote.
Thanks
-- Insert record into tempList using function
insert into session.templis t
select *
from table (LX2P111.RangeE lements (ac_req_number_ range, ','))
;
Sorry, forgot to post the code in the previous entry.
Jaraba wrote: -- Insert record into tempList using function
insert into session.templis t select * from table (LX2P111.RangeE lements (ac_req_number_ range, ',')) ;
Sorry, forgot to post the code in the previous entry.
.... and the error?
Dave.
--
I am getting an error building the stored procedure. It is expecting
different parameters. maybe the construction of the insert statement
with the function is not properly done
Jaraba wrote: I am getting an error building the stored procedure. It is expecting different parameters. maybe the construction of the insert statement with the function is not properly done
You should run the INSERT statement alone on the command line to test its
proper functioning. Also, please post the exact and complete error message
here. This helps tremendously to understand your problem.
My best guess is that you have not provided a correlation name for the
resulting table. This might work better:
insert into session.templis t
select *
from table (LX2P111.RangeE lements (ac_req_number_ range, ',')) AS t
Note the "AS t" at the end of the FROM clause. This correlation name
(called correlation-clause in the manual http://tinyurl.com/7av8b) is
mandatory.
--
Knut Stolze
DB2 Information Integration Development
IBM Germany
Jaraba wrote: I am getting an error building the stored procedure. It is expecting different parameters. maybe the construction of the insert statement with the function is not properly done
Could you please post the *error* *message* you are getting?
Honestly... Like trying to get blood out of a stone.
In the absence of any further information, I'll take a wild stab in the
dark (insert Blackadder II quote here ;-)
insert into session.templis t
select *
from table (LX2P111.RangeE lements (ac_req_number_ range, ','));
The above code will fail, but not with an error about parameters. It'll
fail because you're missing a mandatory correlation name from the end:
insert into session.templis t
select *
from table (LX2P111.RangeE lements (ac_req_number_ range, ',')) AS T;
However, that'll fail too because the string literal ',' will be
interpreted as a VARCHAR when your function is expecting a CHAR in that
position. Either change the function to expect a VARCHAR as the second
parameter, or use:
insert into session.templis t
select *
from table (LX2P111.RangeE lements (ac_req_number_ range, CHAR(',')))
AS T;
Not that the second parameter is much use... As mentioned in a prior
post you've got a bug in your altered version of Knut's functions.
Change:
LOCATE(',', string, index+1), 0),
To:
LOCATE(DELIMITE R, string, index+1), 0),
Finally, you may run into some problems by having declared the certain
parameters as VARCHAR(8000). I seem to recall a note in the LOCATE
function's documentation that the maximum length it can handle is
VARCHAR(4000) (when passed a VARCHAR that is), like a number of other
functions in the SYSFUN schema.
Finally, and without putting too blunt a point on it (re: Blackadder II
quote earlier ;-), here's a checklist for future use:
* Post the code that's causing the error. Try and reduce the code to a
minimal use case that demonstrates the problem without requiring extra
objects like tables to be defined. If extra objects are necessary, post
the code defining them.
* Format the code in your post so that it doesn't wrap across lines
(especially in the case of comments) allowing people to simply copy and
paste your code if they want to test it.
* Post the *entire* error message including any apparently cryptic
codes. Even if the error message isn't English, the code at the start
of a DB2 error can be used to find the English definition in the Info
Center.
* Include the version, fixpak level, and platform of DB2 that you're
using (e.g. DB2 UDB v8.1 FP11 for LUW), or better still include the
output of db2level on your system.
Dave.
--
DB2 SQL error: SQLCODE: -440, SQLSTATE: 42884, SQLERRMC:
RANGEELEMENTS;F UNCTION
Message: No authorized routine named "RANGEELEME NTS" of type
"FUNCTION" having compatible arguments was found
Is the message that I am getting.
DB2 SQL error: SQLCODE: -440, SQLSTATE: 42884, SQLERRMC:
RANGEELEMENTS;F UNCTION
Message: No authorized routine named "RANGEELEME NTS" of type
"FUNCTION" having compatible arguments was found.
I keep getting this error message. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Dave |
last post by:
After following Microsofts admonition to reformat my system before doing a
final compilation of my app I got many warnings/errors upon compiling an rtf
file created in word. I used the Help Workshop program: hcw.exe that's
included with Visual Basic. This exact same file compiled perfectly with no
notes, warnings or errors prior to reformatting my system. Prior to the
reformatting, I copied the help.rtf file onto a CD and checked the box to...
|
by: Tom |
last post by:
A question for gui application programmers. . .
I 've got some GUI programs, written in Python/wxPython, and I've got
a help button and a help menu item. Also, I've got a compiled file
made with the microsoft HTML workshop utility, lets call it
c:\path\help.chm. My question is how do you launch it from the GUI?
What logic do I put behind the "help" button, in other words.
I thought it would be
os.spawnv(os.P_DETACH,...
|
by: Sudheer Kareem |
last post by:
Dear All
Please tell me how to assosiate help files with my Vb.net
Project.
Regards
Sudheer
|
by: wukexin |
last post by:
Help me, good men. I find mang books that introduce bit "mang header
files",they talk too bit,in fact it is my too fool, I don't learn it, I have
do a test program, but I have no correct doing result in any way. Who can
help me, I thank you very very much.
list.cpp(main program)
//--------------------------------------------------------------------------
-
#pragma hdrstop
#pragma argsused
|
by: Colin J. Williams |
last post by:
Python advertises some basic service:
C:\Python24>python
Python 2.4.1 (#65, Mar 30 2005, 09:13:57) on
win32
Type "help", "copyright", "credits" or "license" for more information.
>>>
With numarray, help gives unhelpful responses:
| |
by: Corepaul |
last post by:
Missing Help Files
When I enter "recordset" as the keyword and search the Visual Basic Help index,
I get many topics of interest in the resulting list. But there isn't any
information available from clicking on many of the available topics (mostly
methods but some properties are also unavailable). This same problem occurs
with many, if not most, keywords.
Is there any way I can activate these "missing" help topics? HELP!
|
by: Steve |
last post by:
I have written a help file (chm) for a DLL and referenced it using Help.ShowHelp
My expectation is that a developer using my DLL would be able to access this help file during his development time using "F1" help within the VB IDE. Is this expectation achievable
In trying to test my help file in the IDE, I have a solution with 2 projects: the DLL and a tester. VB does not look for my help file; instead, it looks for path to my source code...
|
by: Mark |
last post by:
I have loaded Visual Studio .net on my home computer and my laptop, but my
home computer has an abbreviated help screen not 2% of the help on my laptop.
All the settings look the same on both including search the internet for
help, but the help is worthless. Any ideas?
|
by: trunxnirvana007 |
last post by:
'UPGRADE_WARNING: Array has a new behavior. Click for more: 'ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?keyword="9B7D5ADD-D8FE-4819-A36C-6DEDAF088CC7"'
'UPGRADE_WARNING: Couldn't resolve default property of object Label. Click for more: 'ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
Label = New Object(){Box1, Box2, Box3, Box4, Box5, Box6, Box7, Box8, Box9, Box10, Box11,...
|
by: hitencontractor |
last post by:
I am working on .NET Version 2003 making an SDI application that calls MS Excel 2003.
I added a menu item called "MyApp Help" in the end of the menu bar to show Help-> About.
The application calls MS Excel, so the scenario is that I am supposed to see the Excel Menu bar,
FILE EDIT VIEW INSERT ... HELP.
I am able to see the menu bar, but in case of Help, I see the Help of Excel and help of my application, both as a submenu of help.
...
|
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 usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
| |
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,...
|
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...
|
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...
|
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,...
|
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...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
|
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...
| |