Received: from orion3.ori-ind.com (IDENT:root@[206.81.197.190]) by hub.org (8.9.3/8.9.3) with ESMTP id OAA14781 for ; Tue, 22 Jun 1999 14:23:03 -0400 (EDT) (envelope-from ken@ori-ind.com) Received: from ken (stimpy.ori-ind.com [192.168.61.96]) by orion3.ori-ind.com (8.8.7/8.8.7) with SMTP id LAA28088 for ; Tue, 22 Jun 1999 11:30:13 -0700 Message-Id: <3.0.1.32.19990622112305.00a78cb0@ori-ind.com> X-Sender: ken@ori-ind.com X-Mailer: Windows Eudora Pro Version 3.0.1 (32) Date: Tue, 22 Jun 1999 11:23:05 -0700 To: pgsql-interfaces@postgreSQL.org From: "Ken J. Wright" Subject: Re: [INTERFACES] Perl Interface In-Reply-To: <9906229300.AA930073628@ccmailgw.state.il.us> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" > help. I am planning to port our applications over to C but... that's a > several month job. I'm looking for a quick fix here to buy me some > time. The other side of that is C is not my preferred language of > choice... I do pascal and perl. See the Free Pascal page. A great cross-platform compiler, both Borland Pascal & Delphi compatible. http://tfdec1.fys.kuleuven.ac.be/~michael/fpc/ On the contributed units page, you will find a postgres unit, which is a pascal wrapper for libpq (postgres 'c' library). I have been using this for about a year now on Linux. Works wonderfully and allows me to stay with the language of my choice ;-). GPC is another cross-platform compiler more focused on portability than FPC. It can also wrap 'c' libraries, but I have no experience with it yet. Cheers! Ken > > I am not clear yet as how to navigate multiple rows on the recordset > return using the pg method. Ideally I want to put all the results into > an array like this: > username|password|lastname > marty|next|Robinson > mel|foreman|Johnson > > The <$ret = $result->fetchrow> function only returns a portion of the > row. > > I have created a lttle subroutine using the getvalue method that > iterates thru each row and pushes it into an array. This will work for > now. However I am curious, is there another, more simpler method to > accomplish this? > > Thanks, > > -Rob > > ############################ > # Subroutine # > ############################ > > $query = "Select username,password,knickname,emailaddy,forward,ip,date > from temp"; > $conn = Pg::connectdb("dbname=$dbname"); > $result = $conn->exec($query); > $tuples = $result->ntuples; > $fields = $result->nfields; > $count = 0; > while ($count < $tuples ) { > $fieldcount = 0; > for ($fieldcount = 0;;$fieldcount++) { > $entry .= $result->getvalue($count,$fieldcount); > if ($fieldcount != $fields) { > $entry .= "\|"; > } > else { > last; > } > } > push(@set,$entry); > $entry=""; > $count++; > } > > for $member (@set) { > print "$member\n"; > } > > ########################### > When run it produces this output. We need to keep this format for > existing scripts. > > marty|marty|fghu|sdfg@fghj|t|208.130.70.9|Tue Jun 22 00:09:34 1999 CDT > marty1|marty|fghu|sdfg@fghj|f|208.130.70.9|Tue Jun 22 00:10:18 1999 > CDT > > >