Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.misc -> Re: Finding a pattern with SQL or SQLPlus
In relational databases (including Oracle) you should not make any
assumptions about the
way the database stores (orders) the rows internally.
Unless you specifically specify an ORDER BY clause in your fetch of the data, your "patterns" may change from pull to pull.
Ken Hill <hillke_at_umkc.edu> wrote in message
news:7vdah3$rev$1_at_ns3.umkc.edu...
> Oct 29, 1999
>
> I need some assistance and hoepfully I'm not the first
person
> to encounter such a problem. I have an Oracle 7 database and I need to
find
> a pattern in some records. Assume the records are in the table as
follows:
>
> 1 T
> 2 T
> 3 K
> 4 K
> 5 K
> 6 T
> 7 T
> 8 T
> 9 K
> 10 K
> 11 T
> 12 T
> 13 T
> 14 K
> 15 T
> 16 T
>
> I need to determing if this sequence of records contains a pattern of
> this type 'TKTK'. Now here is the the interesting thing, this set of
> records does contain this pattern. These records are composed of 2 T's, 3
> K's, 3 T's, 2 K's, 3 T's, 1 K, 2 T's. Hence this sequence of records does
> contain a 'TKTK' pattern if you ignore repeated instances of a character.
> In fact it contains the pattern twice once in records 1-10 and again in
> records 6-14. In fact you could argue that the pattern exists many more
> times if you consider the set of records 2-10, records 1-9, records 2-9,
> etc. But I am only interested in the largest sequence records. Also note,
> the pattern 'TKTK' does not exist in records 1-8, records 3-13, or records
> 11-16 or any other combination.
>
> Knowing that this pattern exists is minimally sufficient, I would also
> like to know where the pattern begins and ends.
>
>
> One other question, how can I take the above sequence of records and
> turn it into a string (i.e. TTKKKTTTKKTTTKTT)?
>
> Thanks
>
>
Received on Mon Nov 01 1999 - 12:53:20 CST