# PGConn - qutie a trivial question from a newb

**URL:** <https://www.ruby-forum.com/t/pgconn-qutie-a-trivial-question-from-a-newb/77656>\
**Category:** Ruby\
**Created:** [November 29, 2006, 4:03pm UTC](https://www.ruby-forum.com/t/pgconn-qutie-a-trivial-question-from-a-newb/77656 "2006-11-29T16:03:29Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![nicken](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/d07c76/32.png) [@nicken](https://www.ruby-forum.com/u/nicken)\
**Post date:** [November 29, 2006, 4:03pm UTC](https://www.ruby-forum.com/t/pgconn-qutie-a-trivial-question-from-a-newb/77656/1 "2006-11-29T16:03:29Z")

</div>

Hello,

I have this code:

```
 28 dbh = get_connection
 29 res = dbh.exec("select max(ogc_fid) from #{table};")
 30 max = res[0]
 31
 32 puts max

```

Which successfully prints the SQL query to the terminal. I want to be  
able  
to use the result later in the code, but I’m not really clear what type  
of  
object is being returned. How can I figure out what is being returned  
and  
convert it to an integer or a string?

Thanks,

---

<div class="post-metadata">

**Author:** ![nicken](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/d07c76/32.png) [@nicken](https://www.ruby-forum.com/u/nicken)\
**Post date:** [November 29, 2006, 10:55pm UTC](https://www.ruby-forum.com/t/pgconn-qutie-a-trivial-question-from-a-newb/77656/2 "2006-11-29T22:55:14Z")

</div>

On Thu, 30 Nov 2006, Nick B. wrote:

> Which successfully prints the SQL query to the terminal. I want to be able  
> to use the result later in the code, but I’m not really clear what type of  
> object is being returned. How can I figure out what is being returned and  
> convert it to an integer or a string?

i’m not quite sure what you’re asking, but i think exec returns rows.

[http://ruby.scripting.ca/postgres/rdoc/](http://ruby.scripting.ca/postgres/rdoc/)

-a
