Hi
I am not completely fluent in PL/SQL. But then, I'm not 100% sure how I'd do this in any other language anyway.
I want to write a function which standardises a string which is sent to it. Basically, the string is a chemical molecular formula. So for example,
C2H6BrC -> BrC3H6
because I was planning to just alphabeticise the output, and duplicate elements should be added together.
I was planning to use owa_pattern to extract each element, evaluate its number and add this to a running total for each element. At the end, I would order by the element type alphabetically and construct the output.
There are two problems - first, owa_pattern is not like any reg exp I have come across before, but this is a separate issue and I think I can cope.
The second is what do I use to maintain the running total? My latest and craziest idea is to use a helper table, which I fill up during the function, and execute regular SQL on to manage the collection of elements and order by at the end. Then I delete from this table. I was thinking to have an ID from a sequence in the table, and use this to avoid deleting any rows belonging to other calls of the function.
Is this a good idea? How do I persuade Oracle that this table is purely a memory structure, while still being able to issue SQL to it? Will this perform well? Have I lost the plot?
Thanks for any advice.
Mark
I am not completely fluent in PL/SQL. But then, I'm not 100% sure how I'd do this in any other language anyway.
I want to write a function which standardises a string which is sent to it. Basically, the string is a chemical molecular formula. So for example,
C2H6BrC -> BrC3H6
because I was planning to just alphabeticise the output, and duplicate elements should be added together.
I was planning to use owa_pattern to extract each element, evaluate its number and add this to a running total for each element. At the end, I would order by the element type alphabetically and construct the output.
There are two problems - first, owa_pattern is not like any reg exp I have come across before, but this is a separate issue and I think I can cope.
The second is what do I use to maintain the running total? My latest and craziest idea is to use a helper table, which I fill up during the function, and execute regular SQL on to manage the collection of elements and order by at the end. Then I delete from this table. I was thinking to have an ID from a sequence in the table, and use this to avoid deleting any rows belonging to other calls of the function.
Is this a good idea? How do I persuade Oracle that this table is purely a memory structure, while still being able to issue SQL to it? Will this perform well? Have I lost the plot?
Thanks for any advice.
Mark