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
Apr 28 '06
15 2911
Jaraba wrote: 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.
Could it be the second argument is a CHAR(1)?
LX2P111.RangeEl ements (ac_req_number_ range, ',')
',' is a VARCHAR(1) and cannot be promoted to CHAR(1).
Try LX2P111.RangeEl ements (ac_req_number_ range, CHAR(','))
--
Serge Rielau
DB2 Solutions Development
IBM Toronto Lab
Thanks. I think that was most of the proble. I adjusted data types and
change few things. Now I am getting a privilege error message as
follows:
DB2 SQL error: SQLCODE: -551, SQLSTATE: 42501, SQLERRMC:
CD2KXG;SELECT;L X2P111.REQUISIT ION_DETAIL
"CD2KXG" does not have the privilege to perform operation "SELECT" on
object "LX2P111.REQUIS ITION_DETAIL".
Even thoug i can select records using the id in the command window
Everything basically works, but when I join the temp table to the
REQUISITION_DET AIL view, that is when I get the above error
Jaraba wrote: Everything basically works, but when I join the temp table to the REQUISITION_DET AIL view, that is when I get the above error
Now we are lacking the query :-)
If you post all the information together chances increase.
Cheers
Serge
--
Serge Rielau
DB2 Solutions Development
IBM Toronto Lab
The query is included in the nody of the stored proc:
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)
Jaraba wrote: The query is included in the nody of the stored proc:
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)
Well, do what the user response of the SQL0551 error message tells you:
grant the necessary privileges on the lx2p111.requisi tion_detail table to
the user who wants to create the procedure. There are some cases where
routines don't accept group privileges. I don't remember the details, but
this might be such a case.
--
Knut Stolze
DB2 Information Integration Development
IBM Germany 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: 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...
|
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.
| |