Re: [SQL] umlimited arguments on function

2004-02-15 Thread Robert Treat
On Monday 09 February 2004 14:49, Christian Hergert wrote: > Is it possible to write a function (in sql or plpgsql) that allows for > an unknown amount of arguments? Something similar to C's printf() > function. > AFAIK no, but I know of two possible work arounds... first is to write multiple cop

Re: [SQL] Passing composite values to functions

2004-02-15 Thread Tom Lane
"Jatinder Sangha" <[EMAIL PROTECTED]> writes: > I'm having trouble passing a composite variable to a function. AFAIK, plpgsql doesn't support this --- it doesn't have any way to pass a row or record variable as a parameter to the main executor. Possibly this will get fixed someday; I don't know o

Re: [SQL] bytea or blobs?

2004-02-15 Thread Dana Hudes
I'm in the same situation. I struggled with it for days considering various implementation issues for my application and what I hoped to achieve. I opted to use bytea but getting the data in and out is going to be interesting . have to use encode/decode. However I don't have to worry about making t

Re: [SQL] ORDER BY TIMESTAMP_column ASC, NULL first

2004-02-15 Thread Rod Taylor
On Thu, 2004-02-12 at 05:06, Fredrik Wendt wrote: > Hi! > > I read posts telling me that NULL values are considered greater than > non-null values. Fine. Is there a way to explicitly reverse this? ORDER BY column IS NOT NULL, column ASC; ---(end of broadcast)

Re: [SQL] Function

2004-02-15 Thread Stephan Szabo
On Thu, 12 Feb 2004, Sumita Biswas (sbiswas) wrote: > Hi All, > > This function of mine gives a Parse Error: > > CREATE or replace FUNCTION Proc_ConferenceSummary(date,date,int,int,int) > RETURNS SETOF tbl_error_master AS > ' > declare > li_CallManagerId int; > begin > select * FROM tb

Re: [SQL] max timestamp

2004-02-15 Thread Bruno Wolff III
On Tue, Feb 10, 2004 at 10:14:04 -0800, Michael Sterling <[EMAIL PROTECTED]> wrote: > i'm trying to get the max time stamp, from each day, of a range of > dates, not just the max time stamp for the complete range dates but > for each day. SELECT DISTINCT ON can probably do what you want. Somethi

Re: [SQL] writing a dynamic sql

2004-02-15 Thread Tomasz Myrta
Dnia 2004-02-10 10:48, Użytkownik Senthil Kumar S napisał: Dear friends, I am having an lengthy SQL, which will be called every conditions of if...else statement. I tried with passing that via a string and execute it. But I got error. v_sql := 'INSERT INTO activities( activity_id, paren

Re: [SQL] max timestamp

2004-02-15 Thread Tomasz Myrta
Dnia 2004-02-10 19:14, Użytkownik Michael Sterling napisał: i'm trying to get the max time stamp, from each day, of a range of dates, not just the max time stamp for the complete range dates but for each day. select max(some_time) group by some_time::date or select max(some_time) group by date_tr

Re: [SQL] max timestamp

2004-02-15 Thread Robert Creager
When grilled further on (10 Feb 2004 10:14:04 -0800), [EMAIL PROTECTED] (Michael Sterling) confessed: > i'm trying to get the max time stamp, from each day, of a range of > dates, not just the max time stamp for the complete range dates but > for each day. > Well, one gross and ugly way is: SE

Re: [SQL] Unable to convert date to tm

2004-02-15 Thread Tom Lane
Ramiro Arenas R <[EMAIL PROTECTED]> writes: > I have a column x in a table of type date and i have an index on x > runing the query "SELECT * FROM table WHERE x >= '2004-01-01" > i get this: > Unable to convert date to tm AFAICT, that error message hasn't existed in PG since 7.1. If you are run

Re: [SQL] ORDER BY TIMESTAMP_column ASC, NULL first

2004-02-15 Thread Stephan Szabo
On Thu, 12 Feb 2004, Fredrik Wendt wrote: > I read posts telling me that NULL values are considered greater than > non-null values. Fine. Is there a way to explicitly reverse this? Not directly, but I think ORDER BY assignedAt IS NOT NULL, assignedAt ASC will give the ordering you want at the co

Re: [SQL] max timestamp

2004-02-15 Thread Stephan Szabo
On Tue, 10 Feb 2004, Michael Sterling wrote: > i'm trying to get the max time stamp, from each day, of a range of > dates, not just the max time stamp for the complete range dates but > for each day. Maybe something like? SELECT CAST(timestampcol AS DATE), max(timestampcol) FROM thetable GROUP

Re: [SQL] ORDER BY TIMESTAMP_column ASC, NULL first

2004-02-15 Thread Tomasz Myrta
Dnia 2004-02-12 11:06, Użytkownik Fredrik Wendt napisał: Hi! I read posts telling me that NULL values are considered greater than non-null values. Fine. Is there a way to explicitly reverse this? Sure, choose combination you need: order by some_value is null asc/desc, some_value asc/desc Regard

Re: [SQL] returning multiple resultset?

2004-02-15 Thread Tom Lane
[EMAIL PROTECTED] (ismail) writes: > I am fairly new to PostgreSQL and I am right now converting a database > from SQL server. SQL server can return multiple select statements in > the function body. Is there any way to return a function with two > different resultsets? You can fake it in some cas

[SQL] writing a dynamic sql

2004-02-15 Thread Senthil Kumar S
Dear friends,I am having an lengthy SQL, which will be called every conditions of if...else statement. I tried with passing that via a string and execute it.But I got error. v_sql :=  'INSERT INTO activities(    activity_id,    parent_activity_id,    activity_type_id,    subject,    descrip

[SQL] Trace for postgreSQL

2004-02-15 Thread beyaNet Consultancy
Hi, can anyone tell me whether there is a trace facility (application) available for postgreSQL version 7.4.1 which will enable me to see all incoming requests being made to the database (ala SQL Server)? many thanks in advance. ---(end of broadcast)-

[SQL] umlimited arguments on function

2004-02-15 Thread Christian Hergert
Is it possible to write a function (in sql or plpgsql) that allows for an unknown amount of arguments? Something similar to C's printf() function. ~ chris

[SQL] max timestamp

2004-02-15 Thread Michael Sterling
i'm trying to get the max time stamp, from each day, of a range of dates, not just the max time stamp for the complete range dates but for each day. ---(end of broadcast)--- TIP 5: Have you checked our extensive FAQ? http://www.postgr

[SQL] returning multiple resultset?

2004-02-15 Thread ismail
Hello all, I am fairly new to PostgreSQL and I am right now converting a database from SQL server. SQL server can return multiple select statements in the function body. Is there any way to return a function with two different resultsets? select * from table1; select * from table2; Thanks for

[SQL] ORDER BY TIMESTAMP_column ASC, NULL first

2004-02-15 Thread Fredrik Wendt
Hi! I read posts telling me that NULL values are considered greater than non-null values. Fine. Is there a way to explicitly reverse this? I have the situation where a table holds IP-addresses. The table has column of type timestamp, called assignedAt, which tells when the address was assigned to

[SQL] Unable to convert date to tm

2004-02-15 Thread Ramiro Arenas R
Hi I have a column x in a table of type date and i have an index on x runing the query "SELECT * FROM table WHERE x >= '2004-01-01" i get this: Unable to convert date to tm where using a cast like this: "SELECT * FROM table WHERE x >='2004-01-01::timestamp" result is ok but it doesn't use in

[SQL] Function

2004-02-15 Thread Sumita Biswas (sbiswas)
Hi All, This function of mine gives a Parse Error: CREATE or replace FUNCTION Proc_ConferenceSummary(date,date,int,int,int) RETURNS SETOF tbl_error_master AS ' declare li_CallManagerId int; begin select * FROM tbl_error_master; end; ' LANGUAGE SQL; psql:Proc_ConferenceSummary.sq

Re: [SQL] Unique Constraint with foreign Key

2004-02-15 Thread Greg Patnude
Pleas also note that the referenced column in the foreign table either needs to be the PRIMARY KEY or have a unique constraint on it or maybe it just requires an index on it -- I'm not sure but I discovered that if the column in the foreign table (containing the REFERENCED key...) is NOT the primar

Re: [SQL] determining how many products are in how many categories

2004-02-15 Thread Greg Patnude
You might be better off with something more like this: SELECT COUNT(P.*) AS p_count, P.p_product_category_id FROM p_product P WHERE P.p_product_category_id IN (SELECT DISTINCT id FROM p_product_category) GROUP BY P.p_product_category_id; obviously tailored to YOUR schema... not mine... -- Greg P

[SQL] bytea or blobs?

2004-02-15 Thread beyaNet Consultancy
Hi, what I am trying to do is to be able to store images in my database. What I wanted to know is this: 1. Would it be better to have the image field type as a bytea or a blob? I have heard it mentioned that bytea would be better as doing data dumps would also insure that the image was saved as

[SQL] nextval problem

2004-02-15 Thread Ivo Anon
I'm new to postgresql and I'm having problems with the 'nextval' function (or whatever it is called in postgresql). I created a table (called ADDRESS) using 'pgadmin' which has a serial field (called addressid). When I tried the sql statement: select nextval('public."ADDRESS_addressid_seq

Re: [SQL] 7.4 - FK constraint performance

2004-02-15 Thread Rod Taylor
On Thu, 2004-02-12 at 20:10, Tom Lane wrote: > ow <[EMAIL PROTECTED]> writes: > > Sounds pretty bad for my case. Any way to avoid the 10% scan? > > Can't see how we optimize your case without pessimizing more-common cases. > Sorry. Statistics say there are 10 values. Statistics list the 10 most c

Re: [SQL] 7.4 - FK constraint performance

2004-02-15 Thread Rod Taylor
On Thu, 2004-02-12 at 23:25, Tom Lane wrote: > Rod Taylor <[EMAIL PROTECTED]> writes: > > Statistics say there are 10 values. Statistics list the 10 most common > > values (all of them). Given this, would it not be reasonable to assume > > that 239 is a recent addition (if there at all) to the tabl

Re: [SQL] 7.4 - FK constraint performance

2004-02-15 Thread Rod Taylor
> In this precise example, could you not: > 1. Check index for value > 2. If found, seq-scan > > Of course that's only going to be a sensible thing to do if you're expecting > one of two results: > 1. Value not there > 2. Lengthy seq-scan if it is there Most of the queries are going to b

[SQL] Passing composite values to functions

2004-02-15 Thread Jatinder Sangha
Hi,   I'm having trouble passing a composite variable to a function.   I have a composite as follows:       declare userRecord dnaUsers%ROWTYPE;   and I manipulate it like this:       select into userRecord * from dnaUsers where etc;     userRecord.userid := 'jatinder'; --etc     I would l