View Single Post

   
  #2 (permalink)  
Old 02-27-2008, 07:55 AM
Serge Rielau
 
Posts: n/a
Default Re: Trranslating ORACLE functions to DB2

Joost van der Veen wrote:
> Hi,
>
> can somebody help me to translate this oracle function to a DB2
> function;
> I've tried to do this but it didn't work.
>
> With this function i can separate one textfield with a delimmeter in
> the text, in multiple colums without export to Excel.
>
> Please Help!
>
> Kind Regards,
>
> Joost
>
> CREATE FUNCTION list_element
> (p_string VARCHAR2,
> p_element INTEGER,
> p_separator VARCHAR2)
> RETURN VARCHAR2
> AS
> v_string VARCHAR2(32767);
> BEGIN
> v_string := p_string || p_separator;
> FOR i IN 1 .. p_element - 1 LOOP
> v_string := SUBSTR(v_string,INSTR(v_string,p_separator)+1);
> END LOOP;
> RETURN SUBSTR(v_string,1,INSTR(v_string,p_separator)-1);
> END list_element;
> /
>

Show me what you tried and I'll help debug. :-)

--
Serge Rielau
DB2 Solutions Development
IBM Toronto Lab
Reply With Quote