473,503 Members | 1,501 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

adressing column

i have the following function:

declare
prim_col_name Alias for $1;
prim_col_val Alias for $2;
my_column Alias for $3;
link_table Alias for $4;
link_col Alias for $5;
data_table alias for $6;
my_record Record;
result_string varchar;
i integer;
begin
result_string := '';
i := 0;
For my_record in execute 'select ' || my_column || ' from ' ||
data_table || ' where ' || link_col || ' in (select ' || link_col || '
from ' || link_table || ' where ' || prim_col_name || ' = ' ||
prim_col_val || ') order by lower(' || my_column || ')' loop
if i = 0 then
result_string := my_record.col;
else
result_string := result_string || ', ' || my_record.col;
end if;
i := i + 1;
end loop;
return result_string;
end
now i am searching for a way, to access my_column in my_record (now it
just works if my_column = 'col')
can anyone help please!
thanx
steffn
---------------------------(end of broadcast)---------------------------
TIP 3: if posting/reading through Usenet, please send an appropriate
subscribe-nomail command to ma*******@postgresql.org so that your
message can get through to the mailing list cleanly

Nov 12 '05 #1
2 1549
On Wednesday 01 October 2003 11:20, Stefan Leitich wrote:
i have the following function: [snip code]
now i am searching for a way, to access my_column in my_record (now it
just works if my_column = 'col')
can anyone help please!


That's not going to work in plpgsql at the moment. Because it's "compiled", it
has problems with things like this.

The usual answer is to use pltcl or some other more dynamic language.

In you particular example you could just build your execute statement as:
... || my_column || ' AS foo FROM ' || ...

Then you can access the column as "foo"
--
Richard Huxton
Archonet Ltd

---------------------------(end of broadcast)---------------------------
TIP 3: if posting/reading through Usenet, please send an appropriate
subscribe-nomail command to ma*******@postgresql.org so that your
message can get through to the mailing list cleanly

Nov 12 '05 #2
thanx a lot.
i thought much to complicated!
this will work in my case perfectly!

Richard Huxton wrote:
On Wednesday 01 October 2003 11:20, Stefan Leitich wrote:

i have the following function:

[snip code]

now i am searching for a way, to access my_column in my_record (now it
just works if my_column = 'col')
can anyone help please!


That's not going to work in plpgsql at the moment. Because it's "compiled", it
has problems with things like this.

The usual answer is to use pltcl or some other more dynamic language.

In you particular example you could just build your execute statement as:
... || my_column || ' AS foo FROM ' || ...

Then you can access the column as "foo"

Nov 12 '05 #3

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

Similar topics

5
5277
by: nimdez | last post by:
Hi, I am working on an existing code base in which a lot of data displayed to the user is formatted in tables. Most tables are printed row-by-row using printf() with "%s" print conversion...
4
4954
by: perspolis | last post by:
I have 3 columns in my datatabel name Total,unit,Price. I use a column expression in my project..and in this expression i multiplied two column... for example ...
6
3218
by: Robert Schuldenfrei | last post by:
Dear NG, After being away from C# programming for a spell, I am trying my hand at what should be a simple task. I have been hitting my head against the wall this morning. I have a simple order...
19
25424
by: Owen T. Soroke | last post by:
Using VB.NET I have a ListView with several columns. Two columns contain integer values, while the remaining contain string values. I am confused as to how I would provide functionality to...
6
10641
by: Aaron Smith | last post by:
Ok. I have a dataset that has multiple tables in it. In one of the child tables, I have a column that I added to the DataSet (Not in the DataSource). This column does not need to be stored in the...
0
909
by: Erik Juhlin | last post by:
Hello! I use wse to implement ws-security and everything works just fine and the SOAP-Header looks nice. Though I want to remove the elements that involve adressing (or not include them). But I...
2
3924
by: ricky | last post by:
Hello, If anyone could help me with this I would highly appreciate it. I've tried everything and nothing works. What I am trying to do is so damn basic and it's just frustrating that it seems...
3
3516
by: TPhelps | last post by:
I have a sample of an unbound (autogeneratecolumns is true) sortable/pagable datagrid that works. I want to change one of the columns to a hyperlink. The examples I find use a bound column. I...
4
10637
by: Steph. | last post by:
I have a List view displaying data in Detail mode with several columns. How I can get the column index the user clicked on ? (when user click on an item inside the ListView, not on a column...
0
7203
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7089
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7282
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7463
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
5581
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
3168
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
1515
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
738
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
389
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.