Received: from davinci.ethosmedia.com (davinci.ethosmedia.com [209.10.40.250]) by postgresql.org (8.11.3/8.11.1) with ESMTP id f6HNVja40621 for ; Tue, 17 Jul 2001 19:31:45 -0400 (EDT) (envelope-from josh@agliodbs.com) Received: from [209.10.40.250] (account ) by davinci.ethosmedia.com (CommuniGate Pro WebUser 3.4.1) with HTTP id 87103; Tue, 17 Jul 2001 16:31:41 -0700 From: "Josh Berkus" Subject: Re: PL/PGSQL and external (flat ASCII) files - Urgent ... :) To: Chris Ruprecht , "pgsql-sql@postgresql.org" X-Mailer: CommuniGate Pro Web Mailer v.3.4.1 Date: Tue, 17 Jul 2001 16:31:41 -0700 Message-ID: In-Reply-To: MIME-Version: 1.0 Content-Type: text/plain; charset="ISO-8859-1" Content-Transfer-Encoding: 8bit X-Archive-Number: 200107/238 X-Sequence-Number: 4034 Chris, Hmmph. People are in a bad mood this week; obviously few other people on the list have had to write applications for the banking industry, which trades everything in flat files. Give Chris a break! > >From an input file where the records looks like this one: > > 020-13 016-05 07-15-2001 23:59:07 00:00:59 09678634321208 > 78634321208 > 0000005300 ^M The answer to your question is somewhat annoying, though: You can't use PL/pgSQL for this task. Basically, two other PostgreSQL function languages - PL/tcl and PL/perl - have excellent text-parsing ability. As such, there is no movement affort to replicate that functionality in PL/pgSQL. So: Hire yourself a perl or tcl hacker. Have them write parsing functions in pl/tclU or pl/perl to load the records. Then have your PL/pgSQL function call the tcl or perl functions. You'll need to get advice from other list members or the docs (and don't forget the "non-FAQ Documentation" page!) on how to use these other languages, as I have had no need for them, to date. -Josh ______AGLIO DATABASE SOLUTIONS___________________________ Josh Berkus Complete information technology josh@agliodbs.com and data management solutions (415) 565-7293 for law firms, small businesses fax 621-2533 and non-profit organizations. San Francisco