Skip site navigation (1) Skip section navigation (2)

Postgresql string parsing

From: ycrux(at)club-internet(dot)fr
To: mike(at)fuhr(dot)org, pgsql-general(at)postgresql(dot)org
Subject: Postgresql string parsing
Date: 2006-03-29 16:51:23
Message-ID: mnet1.1143651083.25367.ycrux@club-internet.fr (view raw or flat)
Thread:
Lists: pgsql-general
Hi Folks,
I'm looking for the fatest way to parse string in a postgresql function and insert each parsed chunk in a table. Something like that:

CREATE FUNCTION parse_and_insert(text) RETURNS integer AS '

     DECLARE
     my_string   ALIAS FOR $1;

    -- empty string, do nothing
     IF my_string IS NULL THEN
        -- split my_string at each new line char '\n', '\r\n' or '\r'

        -- loop for each founded chunk, and simply insert it
        INSERT INTO tableX (data) VALUES (chunk);

     return 1;
     END IF;

    -- empty string, do nothing
    return 0;

   END;
' LANGUAGE 'plpgsql';

My be there is exists complety different and fasted method?

Thanks in advance guys

/Youn


Responses

pgsql-general by date

Next:From: Tony CadutoDate: 2006-03-29 17:19:34
Subject: Re: Postgresql string parsing
Previous:From: Bob PawleyDate: 2006-03-29 16:50:40
Subject: Re: Connecting

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group