pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Chris Travers <chris@travelamericas.com>
To: pgsql-sql@postgresql.org
Subject: How to retrieve N lines of a text field.
Date: Thu, 29 Jan 2004 22:01:59 +0700
Message-ID: <010301c3e679$077698b0$5444053d@winxp> (raw)

Hi all;

This is a complex issue, and i am tryign to figure out how to use regular
expressions to resolve this issue.  I need to retrieve the first N lines of
a text field.  N would be assigned using a parameterized query, if possible.

I had thought about using something like:
select substring(test from '#"' || repeat('%\n', $1) || '#"%' for '#') from
multiline_test;
However, this always selects every line but the final one (because %\n seems
to be interpreted to be the largest possible string, while I want it to be
the smallest possible string).

Is there a workaround?  Any other help?  Or do I need to write a UDF?

Best Wishes,
Chris Travers




view thread (3+ messages)  latest in thread

Message-ID: <010301c3e679$077698b0$5444053d@winxp>
Permalink:  ../010301c3e679$077698b0$5444053d@winxp/
Also on:    postgresql.org/message-id/010301c3e679$077698b0$5444053d@winxp

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: chris@travelamericas.com
  Subject: Re: How to retrieve N lines of a text field.
  In-Reply-To: <010301c3e679$077698b0$5444053d@winxp>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox