Received: from mail1.technauts.com (mail1.technauts.com [216.0.252.124]) by hub.org (8.9.3/8.9.3) with ESMTP id RAA11025 for ; Wed, 19 Apr 2000 17:21:14 -0400 (EDT) (envelope-from ganesanm@technauts.com) Received: from [216.0.252.125] By mail1.technauts.com[216.0.252.124]; Wed, 19 Apr 2000 17:23:13 EDT Message-ID: <38FE2289.E4A5E849@technauts.com> Date: Wed, 19 Apr 2000 17:18:01 -0400 From: ganesanm Organization: Technauts Inc X-Mailer: Mozilla 4.61 [en] (X11; U; Linux 2.2.12-20 i686) X-Accept-Language: en MIME-Version: 1.0 To: pgsql-interfaces@postgresql.org Subject: How do I select nth row from a table Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Archive-Number: 200004/157 hi , I have a table (USR_GROUP_TBL) with following attributes grp_name char(30) usr-name char(15) In my C program ( with embedded SQL using ecpg) I need to select the 'n'th user from the group. Where n can any value from 1 to Max number of users in the group. The following query works well in non-embedded sql select user_name from mail_file_dtl where grp_name = 'grp_1' order by user_name limit 1 offset 5; Will return the 5th user in the group 'grp_1'. How can I incorporate this query in an embedded sql ?? I tried the following but ecpg returned error on the last line. exec sql select mfl_size into :mfl_size from mail_file_dtl where mfl_recipient = :mfl_recipient order by mfl_file_name limit 1 offset = :nNumber ; Can a variable name be used in the offset option to pass the value ? I encountered a very similar problem when I tried to use a cursor with 'move forward' option. Thanks ganesh