# Mrelation does not exist

**URL:** <https://www.ruby-forum.com/t/mrelation-does-not-exist/68024>\
**Category:** Ruby\
**Created:** [September 8, 2006, 5:06pm UTC](https://www.ruby-forum.com/t/mrelation-does-not-exist/68024 "2006-09-08T17:06:36Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![aladrin](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/5f8ce5/32.png) [@aladrin](https://www.ruby-forum.com/u/aladrin)\
**Post date:** [September 8, 2006, 5:06pm UTC](https://www.ruby-forum.com/t/mrelation-does-not-exist/68024/1 "2006-09-08T17:06:36Z")

</div>

Okay I originally posted the following in the rails forum, which was the  
wrong place to post it as I’m not using Rails (that thread just happens  
to be what came up in Google). Perhaps one of you could help me

C:\Documents and Settings\Will\My  
Documents\src\mm\web\cgi-bin\>processBounces.rb

Connection Test Successful - Connected To The Database  
Parsing Logfile Finished  
Processing Bounces…  
select id, bounce from sql\_languages where  
email=‘removed\_email\_address@domain.invalid’;  
c:/ruby/lib/ruby/site\_ruby/1.8/DBD/Pg/Pg.rb:640:in `execute': ERROR C42P01 Mrelation "sql_languages" does not exist Fnamespace.c L201 RRangeVa rGetRelid (DBI::ProgrammingError) from c:/ruby/lib/ruby/site_ruby/1.8/dbi.rb:617:in`execute’  
from C:/Documents and Settings/Will/My  
Documents/src/mm/web/cgi-bin/proc  
essBounces.rb:84:in `updateBounceCount' from C:/Documents and Settings/Will/My Documents/src/mm/web/cgi-bin/proc essBounces.rb:79:in`updateBounceCount’  
from C:/Documents and Settings/Will/My  
Documents/src/mm/web/cgi-bin/proc  
essBounces.rb:144  
from C:/Documents and Settings/Will/My  
Documents/src/mm/web/cgi-bin/proc  
essBounces.rb:142

Roughly the same issue, but it doesn’t seem to be an issue with the  
serial… any ideas?

The code is as follows:

data\_sources.each do |table\_name|  
email\_address = email\_address.downcase  
selectQry = “select id, bounce from “+table\_name+” where  
email=’”+email\_address+"’;"

sth = dbh.prepare(selectQry)  
sth.execute

while rows = sth.fetch do  
printf rows[0], rows[1],"\n"  
end  
end

---

<div class="post-metadata">

**Author:** ![aladrin](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/5f8ce5/32.png) [@aladrin](https://www.ruby-forum.com/u/aladrin)\
**Post date:** [September 8, 2006, 7:06pm UTC](https://www.ruby-forum.com/t/mrelation-does-not-exist/68024/2 "2006-09-08T19:06:28Z")

</div>

I should also note that it’s a Postgres-based database that I’m  
connecting to. I’ve scoured the internet, but everything has lead to  
dead ends.

William C. wrote:  
\src\mm\web\cgi-bin\>processBounces.rb

> Connection Test Successful - Connected To The Database  
> Parsing Logfile Finished  
> Processing Bounces…  
> select id, bounce from sql\_languages where  
> email=‘removed\_email\_address@domain.invalid’;  
> c:/ruby/lib/ruby/site\_ruby/1.8/DBD/Pg/Pg.rb:640:in `execute': ERROR C42P01 Mrelation "sql_languages" does not exist Fnamespace.c L201 RRangeVa rGetRelid (DBI::ProgrammingError) from c:/ruby/lib/ruby/site_ruby/1.8/dbi.rb:617:in`execute’  
> from C:/Documents and Settings/Will/My  
> Documents/src/mm/web/cgi-bin/proc  
> essBounces.rb:84:in `updateBounceCount' from C:/Documents and Settings/Will/My Documents/src/mm/web/cgi-bin/proc essBounces.rb:79:in`updateBounceCount’  
> from C:/Documents and Settings/Will/My  
> Documents/src/mm/web/cgi-bin/proc  
> essBounces.rb:144  
> from C:/Documents and Settings/Will/My  
> Documents/src/mm/web/cgi-bin/proc  
> essBounces.rb:142

---

<div class="post-metadata">

**Author:** ![aladrin](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/5f8ce5/32.png) [@aladrin](https://www.ruby-forum.com/u/aladrin)\
**Post date:** [September 8, 2006, 7:49pm UTC](https://www.ruby-forum.com/t/mrelation-does-not-exist/68024/3 "2006-09-08T19:49:30Z")

</div>

William C. wrote:

> select id, bounce from sql\_languages where  
> email=‘removed\_email\_address@domain.invalid’;  
> c:/ruby/lib/ruby/site\_ruby/1.8/DBD/Pg/Pg.rb:640:in `execute’: ERROR  
> C42P01  
> Mrelation “sql\_languages” does not exist Fnamespace.c L201  
> RRangeVa

And of course, the table ‘sql\_languages’ DOES exist, right?

---

<div class="post-metadata">

**Author:** ![aladrin](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/5f8ce5/32.png) [@aladrin](https://www.ruby-forum.com/u/aladrin)\
**Post date:** [September 8, 2006, 8:58pm UTC](https://www.ruby-forum.com/t/mrelation-does-not-exist/68024/4 "2006-09-08T20:58:36Z")

</div>

William C. wrote:

> William C. wrote:
> 
> > select id, bounce from sql\_languages where  
> > email=‘removed\_email\_address@domain.invalid’;  
> > c:/ruby/lib/ruby/site\_ruby/1.8/DBD/Pg/Pg.rb:640:in `execute’: ERROR  
> > C42P01  
> > Mrelation “sql\_languages” does not exist Fnamespace.c L201  
> > RRangeVa
> 
> And of course, the table ‘sql\_languages’ DOES exist, right?

Yes, the table ‘sql\_languages’ does exist. You don’t have to try to be  
a smart allack about it. I’m teaching myself this language and just  
wanted some help.

It’s Postgres. If you aren’t familiar with it, each database contains  
various schemas. sql\_languages is in the “information\_schema” schema.

---

<div class="post-metadata">

**Author:** ![aladrin](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/5f8ce5/32.png) [@aladrin](https://www.ruby-forum.com/u/aladrin)\
**Post date:** [September 8, 2006, 9:21pm UTC](https://www.ruby-forum.com/t/mrelation-does-not-exist/68024/5 "2006-09-08T21:21:25Z")

</div>

William C. wrote:

> William C. wrote:
> 
> > William C. wrote:
> > 
> > > William C. wrote:
> > > 
> > > > select id, bounce from sql\_languages where  
> > > > email=‘removed\_email\_address@domain.invalid’;  
> > > > c:/ruby/lib/ruby/site\_ruby/1.8/DBD/Pg/Pg.rb:640:in `execute’: ERROR  
> > > > C42P01  
> > > > Mrelation “sql\_languages” does not exist Fnamespace.c L201  
> > > > RRangeVa
> > > 
> > > And of course, the table ‘sql\_languages’ DOES exist, right?
> > 
> > Yes, the table ‘sql\_languages’ does exist. You don’t have to try to be  
> > a smart allack about it. I’m teaching myself this language and just  
> > wanted some help.
> > 
> > It’s Postgres. If you aren’t familiar with it, each database contains  
> > various schemas. sql\_languages is in the “information\_schema” schema.
> 
> I’m not being a smart aleck about it. You’d be amazed how often it’s  
> something simple that was just overlooked.

Oh, okay. Sorry about that, i misjudged your tone!

But yeah, essentially I am using Ruby’s DBI module as such  
(simplified)…

dbh = DBI.connect(“DBI:Pg:mavmail:192.168.1.19”, “mavmail”, “”)  
data\_sources = dbh.tables

…the above should return an array of table names, which it indeed  
does. It’s including the table names for not only the public tables,  
but the ones stored in the information schema as well. Then I do the  
following:

data\_sources.each{ do |table\_name|  
sth = dbh.prepare("SELECT something from "+table\_name)  
sth.execute  
end

…and then outputs the error noted above. I believe it’s crapping out  
because it’s running the query against non-public tables, so it can’t  
‘see’ them. Some weird quirk with Postgres as far as I can tell. If I  
could return only the public tables then it’d make my life easier…  
it’s back to the drawing board I guess.

---

<div class="post-metadata">

**Author:** ![aladrin](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/5f8ce5/32.png) [@aladrin](https://www.ruby-forum.com/u/aladrin)\
**Post date:** [September 8, 2006, 10:32pm UTC](https://www.ruby-forum.com/t/mrelation-does-not-exist/68024/6 "2006-09-08T22:32:29Z")

</div>

William C. wrote:

> dbh = DBI.connect(“DBI:Pg:mavmail:192.168.1.19”, “mavmail”, “”)  
> data\_sources = dbh.tables
> 
> …the above should return an array of table names, which it indeed  
> does. It’s including the table names for not only the public tables,  
> but the ones stored in the information schema as well. Then I do the  
> following:
> 
> data\_sources.each{ do |table\_name|  
> sth = dbh.prepare("SELECT something from "+table\_name)  
> sth.execute  
> end
> 
> …and then outputs the error noted above. I believe it’s crapping out  
> because it’s running the query against non-public tables, so it can’t  
> ‘see’ them. Some weird quirk with Postgres as far as I can tell. If I  
> could return only the public tables then it’d make my life easier…  
> it’s back to the drawing board I guess.

Hm, yeah, that’s not very helpful. It doesn’t seem to provide a way to  
tell what schema it’s in or anything. If you could, you could simply do  
schema.table\_name and it would pull it like you want.

It looks like it just pulls the list of tables by doing:  
select tablename from pg\_catalog.pg\_tables;

If you pulled the information yourself, you could choose only the schema  
‘public’ and get what you want.

---

<div class="post-metadata">

**Author:** ![aladrin](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/5f8ce5/32.png) [@aladrin](https://www.ruby-forum.com/u/aladrin)\
**Post date:** [September 8, 2006, 9:06pm UTC](https://www.ruby-forum.com/t/mrelation-does-not-exist/68024/7 "2006-09-08T21:06:16Z")

</div>

William C. wrote:

> William C. wrote:
> 
> > William C. wrote:
> > 
> > > select id, bounce from sql\_languages where  
> > > email=‘removed\_email\_address@domain.invalid’;  
> > > c:/ruby/lib/ruby/site\_ruby/1.8/DBD/Pg/Pg.rb:640:in `execute’: ERROR  
> > > C42P01  
> > > Mrelation “sql\_languages” does not exist Fnamespace.c L201  
> > > RRangeVa
> > 
> > And of course, the table ‘sql\_languages’ DOES exist, right?
> 
> Yes, the table ‘sql\_languages’ does exist. You don’t have to try to be  
> a smart allack about it. I’m teaching myself this language and just  
> wanted some help.
> 
> It’s Postgres. If you aren’t familiar with it, each database contains  
> various schemas. sql\_languages is in the “information\_schema” schema.

I’m not being a smart aleck about it. You’d be amazed how often it’s  
something simple that was just overlooked.
