[SQL] Return more than a record

2004-02-26 Thread Kumar
Dear Friends,   Postgres 7.3.4 on RH Linux 7.2.   Get the following from the groupscreate or replace function ExpensiveDepartments() returns setof table1 as ' declare r table1%rowtype; begin for r in select departmentid, sum(salary) as totalsalary from GetEmployees() group by de

Re: [SQL] Field list from table

2004-02-26 Thread Christopher Browne
"Jan Pips" <[EMAIL PROTECTED]> wrote: > How can I, using SELECT, get the full list of fields from a given table? portfolio=# select column_name, data_type from information_schema.columns where table_catalog = 'portfolio' and table_schema = 'public' and table_name = 'stocktxns'; column_name |

Re: [SQL] Scalar in a range (but textual not numeric)

2004-02-26 Thread Edmund Bacon
On Wed, 2004-02-25 at 12:18, Richard Huxton wrote: As a complete aside: Is there any advantage to use varchar instead of type text? Thanks ---(end of broadcast)--- TIP 3: if posting/reading through Usenet, please send an appropriate sub

Re: [SQL] Scalar in a range (but textual not numeric)

2004-02-26 Thread Bruno Wolff III
On Thu, Feb 26, 2004 at 07:55:14 -0700, Edmund Bacon <[EMAIL PROTECTED]> wrote: > On Wed, 2004-02-25 at 12:18, Richard Huxton wrote: > > As a complete aside: > > Is there any advantage to use varchar instead of type text? Only if there is a business rule that limits the length of the data. --

Re: [SQL] Return more than a record

2004-02-26 Thread Stephan Szabo
On Thu, 26 Feb 2004, Kumar wrote: > Get the following from the groups > create or replace function ExpensiveDepartments() returns setof table1 as Note that at least the example with this name in the SetReturningFunctions guide seems to use setof int as the return type. > ' > declare > r tabl

[SQL] a few Questions about quoted varaibles in psql

2004-02-26 Thread Leo Leo
Hi! How can I interpret a variable in psql, when the variable has to be quoted? for example: \set myVar myValue \echo :myVar The Result ist then "myValue" ==> ok But: in my case the variable-values have to be in quotes: \set db_username myUsername \set db_password myPassword CREATE USER :db_u

Re: [SQL] Last day of month

2004-02-26 Thread Michael Chaney
On Thu, Feb 26, 2004 at 03:07:52AM -, Greg Sabino Mullane wrote: > > -BEGIN PGP SIGNED MESSAGE- > Hash: SHA1 > > > > How to find the last sunday/mon/sat of any given month. > > There is probably a smoother way to do it, but here is a > quick little function to do what you ask

Re: [SQL] Return more than a record

2004-02-26 Thread Kumar
Dear Friends, I am using the record type as follows in my code. CREATE OR REPLACE FUNCTION fn_daily_calendar(date) RETURNS SETOF activities AS DECLARE p_cal_date ALIAS FOR $1; rec_activity activities%ROWTYPE; v_activity_start_date

Re: [SQL] Return more than a record

2004-02-26 Thread Stephan Szabo
On Fri, 27 Feb 2004, Kumar wrote: > Dear Friends, > I am using the record type as follows in my code. > > CREATE OR REPLACE FUNCTION fn_daily_calendar(date) > RETURNS SETOF activities AS > DECLARE > p_cal_date ALIAS FOR $1; > rec_activity act

Re: [SQL] updating remote database

2004-02-26 Thread Achilleus Mantzios
O kyrios Richard Huxton egrapse stis Feb 26, 2004 : > On Thursday 26 February 2004 02:54, Kenneth Gonsalves wrote: > > i have a database on a local machine, and another on a remote machine. I > > have a dialup connection between the two - so band width is a problem. What > > is the most efficient

Re: [SQL] updating remote database

2004-02-26 Thread Olivier Hubaut
Kenneth Gonsalves wrote: i have a database on a local machine, and another on a remote machine. I have a dialup connection between the two - so band width is a problem. What is the most efficient way of updating the remote from the local? Does SQL or postgres have simple commands for this? Is t

Re: [SQL] updating remote database

2004-02-26 Thread Richard Huxton
On Thursday 26 February 2004 02:54, Kenneth Gonsalves wrote: > i have a database on a local machine, and another on a remote machine. I > have a dialup connection between the two - so band width is a problem. What > is the most efficient way of updating the remote from the local? Does SQL > or post

Re: [SQL] Scalar in a range (but textual not numeric)

2004-02-26 Thread Richard Huxton
On Wednesday 25 February 2004 22:37, Tom Lane wrote: > I wrote: > > try writing > > WHERE 'ABCDE' >= pr_min AND 'ABCDE' <= pr_max > > AND pr_min < (SELECT pr_min FROM table > > WHERE pr_min > 'ABCDE' > > ORDER BY pr_min LIMIT 1) > > The