473,406 Members | 2,377 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

Selection in pgsql using dynamic tables.

1
Hi,
I have a function(stored procedure) in the database. I need to pass the table name which is a variable. How do i do that?
Example :
I have 1st table : table name - cities
location | city
(text) | (text)
---------------------
1 bangalore
2 mangalore

Now from this table depending upon location 1 or 2, I need to select the particular city and each city is another table for me which contains different parameters like, population, num of educated ppl, and num of schools.
So, from this selected city, I need to select data from population column.

This needs to be done in stored procedures in pgsql and so, I would need a single query for this. If any one knows, please help me out.
Nov 23 '07 #1
1 4153
rski
700 Expert 512MB
Hi,
I have a function(stored procedure) in the database. I need to pass the table name which is a variable. How do i do that?
Example :
I have 1st table : table name - cities
location | city
(text) | (text)
---------------------
1 bangalore
2 mangalore

Now from this table depending upon location 1 or 2, I need to select the particular city and each city is another table for me which contains different parameters like, population, num of educated ppl, and num of schools.
So, from this selected city, I need to select data from population column.

This needs to be done in stored procedures in pgsql and so, I would need a single query for this. If any one knows, please help me out.
My english isn't good but aren't you looking for a dynamic queries in plpgsql (execute command see here
http://www.postgresql.org/docs/curre...-EXECUTING-DYN
Nov 23 '07 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

9
by: Google Mike | last post by:
To my surprise last month, my dad wanted to start dabbling in PHP and MySQL or pgSQL. I've been helping him out a bit. He's into athletic medicine and wants to have a website to help athletes and...
3
by: hamvil79 | last post by:
I'm implementig a java web application using MySQL as database. The main function of the application is basically to redistribuite documents. Those documents (PDF, DOC with an average size around...
34
by: Karam Chand | last post by:
Hello I have been working with Access and MySQL for pretty long time. Very simple and able to perform their jobs. I dont need to start a flame anymore :) I have to work with PGSQL for my...
2
by: Gellert, Andre | last post by:
Hello, I have following problem: A user "xy" shouldn't have any rights to a table, but needs data from the content of the table. My idea was to setup a PL/PGSQL procedure to fetch the data...
1
by: Graeme Hinchliffe | last post by:
Hiya, Not had much experience with tiggers under postgres but am liking them so far. My problem is this. I am writing an updates system, postgres holds the master copy of the database, any...
2
by: Tim Vadnais | last post by:
Hi, My boss wants to add some logging functionality to some of our tables on update/delete/insert. I need to log who, when, table_name, field name, original value and new value for each record,...
2
by: Matt | last post by:
Hi, I'm sure this has been asked before, but my searches haven't come up with an example. I'm writing a generic trigger function called from different tables in plpgsql that needs to get the...
5
by: srampally | last post by:
I need the capabilty to hide/show a selection list, just the way its done at http://www.lufthansa.com (place the cursor over "Group Companies"). However, I am looking for a javascript that is much...
4
by: pravinasp | last post by:
Hello there I have been trying to generate a dynamic querystring thats to be executed inside a trigger function and every time I use NEW.* pl/pgsql throws an error saying 'column * does not...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.