473,322 Members | 1,496 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,322 software developers and data experts.

replace array values in a select statement

hi!
i need a list of all primary keys in my database! for this reson i build
these sql-statement:
/SELECT
pg_class.relname AS tableName,
pg_constraint.conname AS pkName,
pg_constraint.conkey AS columns
FROM
pg_catalog.pg_constraint
INNER JOIN pg_catalog.pg_class ON pg_constraint.conrelid = pg_class.oid
WHERE
pg_constraint.contype = 'p'
/
my result is:
/tablename pkname columns
------------ ------------- ----------
customer customer_pkey {1}
employee employee_pkey {1}
part part_pkey {1}
/
i write a second statement to get the column-names for the column-numbers:
/SELECT
pg_class.relname,
pg_attribute.attname,
pg_attribute.attnum
FROM
pg_catalog.pg_attribute
INNER JOIN pg_catalog.pg_class ON pg_attribute.attrelid =
pg_class.oid
WHERE
pg_class.relname in ('employee','customer','part')
AND
pg_attribute.attnum = 1/

my result is:
/relname attname attnum
---------- ----------- ---------
customer customer_id 1
employee employee_id 1
part part_id 1// /

is it possible to replace the columnNumbers in the colums array of the
first statement with the real column-names of the second statement i one
big select statement?
this should be my result:
/tablename pkname columns
------------ ------------- ----------
customer customer_pkey {//customer_id//}
employee employee_pkey {//employee_id//}
part part_pkey {//part_id//}
/

--
G & H Softwareentwicklung GmbH Tel.: +49(0)7451/53706-20
Robert-Bosch-Str. 23 Fax: +49(0)7451/53706-90
D-72160 Horb a.N. http://www.guh-software.de
Nov 23 '05 #1
0 1489

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

19
by: Westcoast Sheri | last post by:
To keep track of how many fruits my visitors buy, I use a mySQL database (2 columns: "fruit" and "quantity")....so can we make these following mySQL queries work somehow? (visitor buys 5...
3
by: Mark A Framness | last post by:
Greetings, I am working on a project and we need to write a conversion script to initialize a new field on a table. The number of records on this table is on the order of millions so routine...
5
by: K.Simon | last post by:
Hello, it's very often neccessary to replace strings or a single character in my stylesheets. My solution looks awful and very long. Now i thought to solve this with an array like structure but...
22
by: Michael Nahas | last post by:
Antti & all interested, The draft description of my language to replace C is available at: http://nahas.is-a-geek.com/~mike/MyC.pdf I am a long time C programmer (I read the old testament...
4
by: serge | last post by:
I managed to put together C# code and have it do the following: 1- Get all the table names that start with the letter "Z" from sysobjects of my SQL 2000 database and put these table names...
2
by: Leszek | last post by:
I have a form with 5 dropdown lists I want to put all selected values to an array called $data so i wrote sometthing like this: for(i=0;i<5;i++){ echo"<select name=\"\$data\">"; echo"<option...
3
by: Roy W. Andersen | last post by:
Hi, I need to do some replace-calls on certain strings in order to replace smiley glyphs and other keywords with graphical icons on the client. Unfortunately, my knowledge of regular expressions...
52
by: MP | last post by:
Hi trying to begin to learn database using vb6, ado/adox, mdb format, sql (not using access...just mdb format via ado) i need to group the values of multiple fields - get their possible...
9
by: MrHelpMe | last post by:
Hello again experts, I have successfully pulled data from an LDAP server and now what I want to do is drop the data into a database table. The following is my code that will insert the data but...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.