Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 pgsql - selecting columns with arguments

Author  Topic 

endfx
Starting Member

2 Posts

Posted - 2005-03-26 : 23:13:48
I need to write a function where a parameter is the name of a column. I seem to be having problems using a parameter in an UPDATE query to select the proper column (attribute)

Example:
CREATE test_func(varchar) RETURNS integer AS '
DECLARE
BEGIN
UPDATE table1 SET $1 = 'whatever value';
RETURN 1;
END;
' LANGUAGE plpgsql;

Does anybody know how I can accomplish this?
Thanks.

Michael Valentine Jones
Yak DBA Kernel (pronounced Colonel)

7020 Posts

Posted - 2005-03-27 : 04:23:36
This is a site for SQL Server questions, not PostgreSQL questions.


Maybe you could start by reading the documentation here:
http://www.postgresql.org/docs/





CODO ERGO SUM
Go to Top of Page

endfx
Starting Member

2 Posts

Posted - 2005-03-27 : 14:56:18
quote:
This is a site for SQL Server questions, not PostgreSQL questions.


Yes, and plpqsql is a language that is used to write programs in/on SQL servers (specifically a postgresql server, but still an sql server)
and hence developers of sql servers would use plpgsql, and therefore
SQL Server Forums -> Developer would be a place to post this question.
Go to Top of Page

Michael Valentine Jones
Yak DBA Kernel (pronounced Colonel)

7020 Posts

Posted - 2005-03-27 : 17:26:17
When I said SQL Server, I meant Microsoft SQL Server. Most people working with databases understand SQL Server to be the name of Microsoft's or Sybase's database management systems. SQL Server is not a generic term for a database management system.

This forum is for Microsoft SQL Server Developer questions, not PostgreSQL questions.

Most people here do not work with PostgreSQL, so this forum is not a good source for PostgreSQL information.






CODO ERGO SUM
Go to Top of Page
   

- Advertisement -