|
From: RPG400-L [mailto:rpg400-l-bounces@xxxxxxxxxxxx] On Behalf Of JonService
Paris
Sent: Monday, January 15, 2018 12:24 PM
To: Rpg400 Rpg400-L
Subject: Re: Built-in %split RPGLE function
Birgitta has supplied an example. Others have mentioned Scott's RPG
routines.certainly
Both - I strongly suspect - will be faster than the SQL approach and
easier to understand and modify.<joseenocperez.jp@xxxxxxxxx>
Jon Paris
www.partner400.com
www.SystemiDeveloper.com
On Jan 15, 2018, at 12:32 PM, Jose Perez
wrote:how
I think instead of questioning the use of SQL or RPG, which is more
simple or faster what should be explained here with an example is
isto do it, the question is not RPG or SQL is how to do it.
is up to the user or however need to use this to consider which one
<jslanina@xxxxxxxxxx>faster or more simple.
"It is so good to have many way to skin a cat"
On Mon, Jan 15, 2018 at 12:02 PM, Slanina, John
wrote:LENGTH(@Data)>0
I would love to see the response time for the SQL over just calling
the program.
John Slanina
-----Original Message-----
From: RPG400-L [mailto:rpg400-l-bounces@xxxxxxxxxxxx] On Behalf Of
Jon Paris
Sent: Monday, January 15, 2018 11:59 AM
To: Rpg400 Rpg400-L
Subject: Re: Built-in %split RPGLE function
I love these "so simple" SQL responses that end up being more code
(and in my opinion) less obvious than RPG ... <grin>
Jon Paris
www.partner400.com
www.SystemiDeveloper.com
On Jan 15, 2018, at 10:34 AM, Jose Perezwrote:
<joseenocperez.jp@xxxxxxxxx>
it is so simple with Sql, just create below function(you can even
create it on green screen) and you will accomplish what you need.
CREATE FUNCTION Qgpl.SPLIT (@Data VARCHAR(32000), @Delimiter
VARCHAR(5))
RETURNS TABLE (ID INT, VALUE VARCHAR(256))
LANGUAGE SQL
DISALLOW PARALLEL
DETERMINISTIC
NOT FENCED
RETURN
WITH CTE_Items (ID,StartString,StopString) AS
(SELECT 1 AS ID, 1 AS StartString,
LOCATE(@Delimiter, @Data) AS
StopString
FROM SYSIBM.SYSDUMMY1
WHERE LENGTH(@Delimiter)>0 AND
first
UNION ALL
SELECT ID + 1,StopString + LENGTH(@Delimiter)
,LOCATE(@Delimiter, @Data, StopString +
LENGTH(@Delimiter))
FROM CTE_Items
WHERE StopString > 0)
SELECT ID, SUBSTRING(@Data,StartString,
CASE WHEN StopString=0 THEN LENGTH(@Data)
ELSE StopString-StartString
END)
FROM CTE_Items
This will split your record as rows and then you just have to
populate your array from each
row, be aware that the function should receive two parameters,
taketakeparms should be yourwrote:
delimited record as one big string and second parms should be the
delimiter in your case
it will be a comma. Hope this help.
On Mon, Jan 15, 2018 at 9:36 AM, Justin Taylor
<JUSTIN@xxxxxxxxxxxxx>
No. It would be nice though. I suggest an RFE.
-----Original Message-----
From: Gad Miron [mailto:gadmiron@xxxxxxxxx]
Sent: Monday, January 15, 2018 1:33 AM
To: rpg400-l@xxxxxxxxxxxx
Subject: Built-in %split RPGLE function
Hello all
Is there a built-in RPGLE function to split a comma (or other
delimiter) separated record into an array?
I know it can be done by creating a suitable procedure - I'm just
being lazy.
TIA
Gad
--
This is the RPG programming on the IBM i (AS/400 and iSeries)
(RPG400-L) mailing list To post a message email:
RPG400-L@xxxxxxxxxxxx To subscribe, unsubscribe, or change list
options,
visit: https://lists.midrange.com/mailman/listinfo/rpg400-l
or email: RPG400-L-request@xxxxxxxxxxxx Before posting, please
a moment to review the archives at--
https://archive.midrange.com/rpg400-l.
Please contact support@xxxxxxxxxxxx for any subscription related
questions.
Help support midrange.com by shopping at amazon.com with our
affiliate
link: http://amzn.to/2dEadiD
This is the RPG programming on the IBM i (AS/400 and iSeries)
(RPG400-L) mailing list To post a message email:
RPG400-L@xxxxxxxxxxxx To subscribe, unsubscribe, or change list
options,
visit: https://lists.midrange.com/mailman/listinfo/rpg400-l
or email: RPG400-L-request@xxxxxxxxxxxx Before posting, please
aa moment to review the archives atquestions.
https://archive.midrange.com/rpg400-l.
Please contact support@xxxxxxxxxxxx for any subscription related
Help support midrange.com by shopping at amazon.com with our
affiliate
link: http://amzn.to/2dEadiD
--
This is the RPG programming on the IBM i (AS/400 and iSeries)
(RPG400-L) mailing list To post a message email:
RPG400-L@xxxxxxxxxxxx To subscribe, unsubscribe, or change list
options,
visit: https://lists.midrange.com/mailman/listinfo/rpg400-l
or email: RPG400-L-request@xxxxxxxxxxxx Before posting, please take
amoment to review the archives at
https://archive.midrange.com/rpg400-l.
Please contact support@xxxxxxxxxxxx for any subscription related
questions.
Help support midrange.com by shopping at amazon.com with our
affiliate
link: http://amzn.to/2dEadiD
--
This is the RPG programming on the IBM i (AS/400 and iSeries)
(RPG400-L) mailing list To post a message email:
RPG400-L@xxxxxxxxxxxx To subscribe, unsubscribe, or change list
options,
visit: https://lists.midrange.com/mailman/listinfo/rpg400-l
or email: RPG400-L-request@xxxxxxxxxxxx Before posting, please take
RPG400-L@xxxxxxxxxxxxmoment to review the archives at--
https://archive.midrange.com/rpg400-l.
Please contact support@xxxxxxxxxxxx for any subscription related
questions.
Help support midrange.com by shopping at amazon.com with our
affiliate
link: http://amzn.to/2dEadiD
This is the RPG programming on the IBM i (AS/400 and iSeries)
(RPG400-L) mailing list To post a message email:
aTo subscribe, unsubscribe, or change list options,
visit: https://lists.midrange.com/mailman/listinfo/rpg400-l
or email: RPG400-L-request@xxxxxxxxxxxx Before posting, please take
affiliatemoment to review the archives atquestions.
https://archive.midrange.com/rpg400-l.
Please contact support@xxxxxxxxxxxx for any subscription related
Help support midrange.com by shopping at amazon.com with our
(RPG400-L)link: http://amzn.to/2dEadiD
--
This is the RPG programming on the IBM i (AS/400 and iSeries)
mailing list To post a message email: RPG400-L@xxxxxxxxxxxx Tosubscribe,
unsubscribe, or change list options,
visit: https://lists.midrange.com/mailman/listinfo/rpg400-l
or email: RPG400-L-request@xxxxxxxxxxxx
Before posting, please take a moment to review the archives at
https://archive.midrange.com/rpg400-l.
Please contact support@xxxxxxxxxxxx for any subscription related
questions.
Help support midrange.com by shopping at amazon.com with our affiliate
link: http://amzn.to/2dEadiD
As an Amazon Associate we earn from qualifying purchases.
This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].
Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.