Dear all,

I have a problem with a PostgreSQL connection (haven't tested it with
other dbms'). When a query has the same attribute name for a column,
there seems to be no way in accessing any of these columns except for
the first one. Consider the following example.

I create a table test with:

db=# create table test( id serial );

and insert a few rows:

db=# insert into test default values;
INSERT 0 1
db=# insert into test default values;
INSERT 0 1
db=# insert into test default values;
INSERT 0 1
db=# select * from test;
 id
----
  1
  2
  3
(3 rows)

Now if I issue the query:

db=# select * from test t1, test t2;
 id | id
----+----
  1 |  1
  1 |  2
  1 |  3
  2 |  1
  2 |  2
  2 |  3
  3 |  1
  3 |  2
  3 |  3
(9 rows)

I get, as expected, all possible combinations. But, when I create a
datasource and a dataview in Gambas (FMain):

Public con As New Connection


Public Sub _new()
  With con
    .Type = "postgresql"
    .Name = "db"
    .User = "markus"
    .Password = "secret"
    .Open
  End With
  With DataSource1
    .Connection = con
    .Table = "SELECT * FROM test t1, test t2"
  End With
End

I get:

id | id
--------
 1 |  1
 1 |  1
 1 |  1
 2 |  2
 2 |  2
 2 |  2
 3 |  3
 3 |  3
 3 |  3

e.g. only the first id is accessed. I've also tried to implement the
dataview manually by using a grid view but the res!att syntax doesn't
allow me to access any other but the first id attribute. Is there a
way to get the attributes by index?

I know I could rewrite the query as "select t1.id as id1, t2.id from
test t1, test t2" to get distinct column names, but this is not an
option for the application at hand since it deals with user supplied
queries. Yes, I could parse each query and rewrite it before
executing, but this would be at least an "ugly hack".

Any ideas?

All the best,

M.




-- 
Markus Schatten, PhD
Assistant professor
University of Zagreb
Faculty of Organization and Informatics
Pavlinska 2, 42000 Varazdin, Croatia
http://www.foi.hr/nastavnici/schatten.markus/index.html
http://www.researchgate.net/profile/Markus_Schatten1

------------------------------------------------------------------------------
Don't let slow site performance ruin your business. Deploy New Relic APM
Deploy New Relic app performance management and know exactly
what is happening inside your Ruby, Python, PHP, Java, and .NET app
Try New Relic at no cost today and get our sweet Data Nerd shirt too!
http://p.sf.net/sfu/newrelic-dev2dev
_______________________________________________
Gambas-user mailing list
Gambas-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/gambas-user

Reply via email to