1

Topic: To select from a line the data

Good afternoon!
There is a line of parameters, is generated by certain rules of a following type:
"SYNCHRO.CARDS#1#186#2#10.02.2010#3#12:03#4#3#5#"
Each parameter is divided as ##, parameters there can be an unlimited number.
It is necessary to write function PL/SQL which depending on parameter selected values:
Parameter 1 it SYNCHRO.CARDS
The parameter 2 is 186
And .
The order of parameters is mandatory! I.e. cannot be after #1# at once #3#
Made the decision on SQL, and here PL/SQL I do not know, prompt, please, it will be possible on PL/SQL the decision easier

SELECT ' SYNCHRO.CARDS#1#186#2#10.02.2010#3#12:03#4#3#5# ' as name
into #a1
--drop table #a2;
CREATE TABLE #a2 (
name varchar (max)
) ON [PRIMARY]
DECLARE @all int
SET @all = (SELECT REPLACE (SUBSTRING (name, LEN (name)-2,3), ' # ', ")
FROM #a1)
DECLARE @calc int
SET @calc=1
DECLARE @Param varchar (5)
DECLARE @S varchar (5)
WHILE @calc <@all
BEGIN
SET @Param=STUFF (' # # ', 2, 1, REPLACE (' # # ', ' # ', ") + calc)
SET @S=STUFF (@Param, 2, 1, REPLACE (@Param, ' # ', ")-1)
insert into #a2
SELECT SUBSTRING (name, CHARINDEX (@S, name) +case when @S ='#0# ' then 0 else 3 end, CHARINDEX (@Param, name) - (CHARINDEX (@S, name) +case when @S ='#0# ' then 0 else 3 end)) as params
FROM #a1
SET @calc = calc+1
END;

2

Re: To select from a line the data

Takashi;
On  it dares in one request.... To search on " a line"

3

Re: To select from a line the data

Takashi;
for a start kick . Remains  calculation of lines on the first/second and to take all first lines.
But about mod and row_number itself look what to esteem....

4

Re: To select from a line the data

Kind  - Eh;
It and on t-sql in one request dares

;with an as (SELECT 0 as id, cast (N'SYNCHRO.CARDS#1#186#2#10.02.2010#3#12:03#4#3#5# ' as nvarchar (2000)) as par, cast (N "as nvarchar (2000)) as name
union all
select id+1 as id, cast (substring (par, CHARINDEX (' # ', par) +1, len (par)) as nvarchar (2000)) as par, cast (substring (par, 1, CHARINDEX (' # ', par)-1) as nvarchar (2000)) as name
from a where CHARINDEX (' # ', par)> 0)
select name from a
where name! ="