Обсуждение: Cursor need it?

Поиск
Список
Период
Сортировка

Cursor need it?

От
Lucas Hernndez
Дата:
I am a new postgres user

I want to get a list of tables from pg_tables where tables are like 
‘%wo%’ (for example).. and then query that list ….

Select count(*) from tableVARIABLENAMEFROMFIRSTQUERY

In SQL SERVER I can do that using cursor but in postgresql I don’t 
understand how to use cursors

Here is what I am trying to do
for each table on the list
Select tablename, count(*) tables from ( list of tables)

tablename tables
table1 25
table2 35

Any Idea would be appreciated

Thanks

Lucas



Re: Cursor need it?

От
KÖPFERL Robert
Дата:

|
|I am a new postgres user
|
|I want to get a list of tables from pg_tables where tables are like
|‘%wo%’ (for example).. and then query that list ….
|
|Select count(*) from tableVARIABLENAMEFROMFIRSTQUERY
|
|In SQL SERVER I can do that using cursor but in postgresql I don’t
|understand how to use cursors

Sorry, but this is a SQL-Server.
You are looking for cross table joins. Join the pg_class table (where you
get the table name) with another table which you want to query additional
data. Then select your columns off both tables.

select p.name, m.foo from pg_class p JOIN myinfo m ON p.name=m.info
this is equal to
select p.name, m.foo from pg_class p, myinfo m  where p.name=m.info

|
|Here is what I am trying to do
|for each table on the list
|Select tablename, count(*) tables from ( list of tables)
|
|tablename tables
|table1 25
|table2 35
|
|Any Idea would be appreciated
|
|Thanks
|
|Lucas
|
|
|---------------------------(end of
|broadcast)---------------------------
|TIP 2: you can get off all lists at once with the unregister command
|    (send "unregister YourEmailAddressHere" to
|majordomo@postgresql.org)
|