Re: [SQL] casting to arrays

2003-07-19 Thread Greg Stark
Joe Conway <[EMAIL PROTECTED]> writes: > Not possible in current releases, but it will be in 7.4 (about to start beta). > It looks like this: Well there is the int_array_aggregate function in the contrib/intagg directory. It has to be compiled separately, and it has a few quirks (like the arrays

[SQL] Help Me

2003-07-19 Thread Ramesh Kumar B
How to convert charter varying type to integer while retrieving the value using ITL tag [query]?! ___ Click below to experience Sooraj R Barjatya's latest offering 'Main Prem Ki Diwani Hoon' starring Hrithik, Abhishek & Kareena http://www.mpkdh.com

[SQL] column doesn't get calculated

2003-07-19 Thread floyds
this must be a problem with my sql, but this one has me stumped. the column: Debit."cumm_dbt_blnce" - Credit."cumm_crd_blnce" in the long sql statement below comes out as the literal: Debit."cumm_dbt_blnce" - Credit."cumm_crd_blnce" rather than as the calculated value. WHY!?!?! this works with s

Re: [SQL] summing tables

2003-07-19 Thread Viorel Dragomir
The primary problem was that the update command doesn't modify rows in the order u want to do it. I think the update starts with the latest inserted rows. I guess. Anyway, in real life this update modifies only one row with a value wich is diff of null. It was really handy if it was specified the

[SQL] min() and NaN

2003-07-19 Thread Michael S. Tibbetts
Hi, I have a table containing a double precision column. That column contains at least one judiciously placed NaN. I'd expect the aggregate function min() to return the minimum, valid numeric value. Instead, it seems to return the minimum value from the subset of rows following the 'NaN'. Wh

[SQL] Datatype Conversion help

2003-07-19 Thread Ramesh Kumar B
How do i can convert character varying type to integer ___ Click below to experience Sooraj R Barjatya's latest offering 'Main Prem Ki Diwani Hoon' starring Hrithik, Abhishek & Kareena http://www.mpkdh.com ---(end of broadcast

[SQL] Timestamp problem

2003-07-19 Thread Raymond Chui
I am use PostgreSQL 7.2.1 in Redhat Linux 7.2 Java 1.4.x When I do JDBC String sql = "SELECT datetime_column FROM mytable"; Timestamp ts = resultSet.getTimestamp(2); If the timestamp return format like 2003-07-15 13:20:00.20+00 then is OK. But if timestamp return like 2003-07-15 13:20:00.

[SQL] changing an update via rules

2003-07-19 Thread Lauren Matheson
Hello, I am having difficulty setting an on update rule which seems to be caught in a recursive loop. Context is a table with three columns assigning users to groups with the third column being boolean to flag the primary group. I would like to set an update rule to enforce one primary group.

Re: [SQL] Recursive request ...

2003-07-19 Thread Benoît Bournon
Thx a lot,  I know now that it is possible to do that with pure sql. Have you the alogorythm, because your link is dead ? Ben Rajesh Kumar Mallah a écrit: Dear Bournon, There are already good implementation of Tree structures in databases ranging from using pure SQL to PostgreSQL spe

[SQL] Cannot insert dup id in pk

2003-07-19 Thread Scott Cain
Hello, I am having strange behavior when I try to do an insert. Postgres tells me that it cannot insert a duplicate key into a primary key index, when I am not trying to insert into it. Can anyone shed light on why this is happen, or point out the error of my ways? Here are the details: wormbas

[SQL] How to write this query!

2003-07-19 Thread Jo
These are my PostgreSQL tables: pid | name 1 | A 2 | B 3 | C 4 | D 5 | E tid | pid 1 | pid 2 | pid 3 1 | 1| 2| 3 Bascially, I would like to write a query to list only the names which their "pid" match those pids in the other table. If anyone knows, pls help!!

Re: [SQL] Problem with temporary table -- Urgent

2003-07-19 Thread Stephan Szabo
On Thu, 10 Jul 2003, Vijay Kumar wrote: > Hi, > We are using postgresql 7.3.3, we are encountering the following problems when we > used temporary tables. > > Here with i'm sending my Sample function. > > create or replace function TestTemp_refcur(refcursor) returns refcursor As ' > declare > re

Re: [SQL] unique value - trigger?

2003-07-19 Thread Richard Poole
On Thu, Jul 17, 2003 at 12:56:52PM +0100, Gary Stainburn wrote: > > nymr=# \d lnumbers >Table "lnumbers" > Column | Type | Modifiers > ---+---+--- > lnid | integer | not null > lnumber | character varyi

[SQL] "Truncate [ Table ] name [Cascade]"?

2003-07-19 Thread Andreas
Hi there, Would it be possible to implement some kind of cascading truncate? As far as I understand, the "no truncate if table is referenced" change was introduced to ensure database integrity. However, if the referencing table is truncated, too, there should be no problems as far as foreign k

[SQL] How access to array component

2003-07-19 Thread Cristian Cappo
Hello How access to especific array component of an function with return type _varchar declaration of my function: >>> create or replace __function( int2, int2 ) returns _varchar now use the function in SQL and access to the element 1... >>> select __function(10::int2, 20::int2)[1]

[SQL] Return a set of values from postgres Function

2003-07-19 Thread Derrick Betts
I want to get a set of values returned from a function.  The values (there will need to be four of them) come from 4 separate SELECT statements inside the Function.  For example SELECT one INTO variable1 from table1 where ...    then SELECT two INTO variable2 from table1 where...   At first

Re: [SQL] column doesn't get calculated - update # 2

2003-07-19 Thread floyds
i was wrong. it doesn't work as a prepared statement nor as a dynamic string using jdbc. it works fine if i paste it into psql. is it possible that a problem with a calculated column and a subselect in conjunction is a jdbc bug? Regards, Floyd Shackelford 4 Peaks Technology Group, Inc. VOICE:

Re: [SQL] column doesn't get calculated - updated

2003-07-19 Thread floyds
when i copy/paste the select stmt into psql, it works. or if i use it "dynamically". it doesn't work properly when i use it in a prepared statement -- which is what i am doing. Regards, Floyd Shackelford 4 Peaks Technology Group, Inc. VOICE: 334.735.9428 FAX: 702.995.6462 EMAIL: [EMAIL PROTEC

[SQL] Why do the two queries below return different results?

2003-07-19 Thread Warren Little
Look at the following two queries. select casepid, origpid from virbcase where date_trunc('day', origdt) >= '2003-07-01' and date_trunc('day', origdt) <= '2003-07-31' and origpid in (select pid from party where partyid in ('00339', '00310', '00320')) and not exists (select pid from casecombo wher

Re: [SQL] Recursive request ...

2003-07-19 Thread Benoît Bournon
I see connect by in Oracle ??? it is equivalent in PostgreSQL or not ?? Rajesh Kumar Mallah a écrit: Dear Bournon, There are already good implementation of Tree structures in databases ranging from using pure SQL to PostgreSQL specfic methods , less point in revinting wheel unless u r

[SQL] Join table with itself for heirarchial system?

2003-07-19 Thread Benjamin Smith
Can you query a set of nested entries to simulate a heirarchial system with a single query? I'm building a nested category table with a definition like below" CREATE TABLE category ( id serial, parent integer not null, title varchar); Idea is that we can "nest" categories so that we have

Re: [SQL] [JDBC] column doesn't get calculated - update # 2

2003-07-19 Thread Barry Lind
Floyd, I would recommend turning sql statement tracing on in the database to see the exact sql text that the driver is sending to the database (in case it is somehow munging it). Then take that exact same text (as found in the server log files) and run it in psql to see how it works there. --

Re: [SQL] (trigger function) -> ERROR: NEW used in non-rule query

2003-07-19 Thread Terence Kearns
Josh Berkus wrote: Terence, Oh well, can't win them all :/ Nope. I'll suggest that for the TODO list ... we already have several requests for added features for PL/pgSQL. The problem is that we currently don't have a lead developer for PL/pgSQL, so the language has rather stagnated. Well

Re: [SQL] How access to array component

2003-07-19 Thread Joe Conway
Cristian Cappo wrote: >>> select __function(10::int2, 20::int2)[1] ^^^ parsing error. Try: create or replace function foo(int2, int2 ) returns _varchar as ' select ''{1,2}''::_varchar ' language 'sql'; regression=# select (foo(10::int2, 20::int2))[1]; foo - 1 (1 row)

[SQL] SECURITY DEFINER changes CURRENT_USER?

2003-07-19 Thread Chris Travers
Hi all; I found an unexpected behavior while trying to write a function to allow users to change their own passwords. The function is as follows: CREATE OR REPLACE FUNCTION change_password(VARCHAR) RETURNS BOOL AS ' DECLARE username VARCHAR; CMD VARCHAR; password ALIAS FOR $1; BEGIN

Re: [SQL] Why do the two queries below return different results?

2003-07-19 Thread Tom Lane
Warren Little <[EMAIL PROTECTED]> writes: > Look at the following two queries. > ... > and not exists (select pid from casecombo where casepid = secondpid) > ... > and casepid not in (select secondpid from casecombo) > The second query is broken and I don't understand why. I'll bet there are some

Re: [SQL] column doesn't get calculated - updated

2003-07-19 Thread Tom Lane
<[EMAIL PROTECTED]> writes: > when i copy/paste the select stmt into psql, it works. or if i use it > "dynamically". it doesn't work properly when i use it in a prepared > statement -- which is what i am doing. Could we see a self-contained example of the problem? It's hard to tell whether you ar

Re: [SQL] min() and NaN

2003-07-19 Thread Tom Lane
"Michael S. Tibbetts" <[EMAIL PROTECTED]> writes: > I'd expect the aggregate function min() to return the minimum, valid > numeric value. Instead, it seems to return the minimum value from the > subset of rows following the 'NaN'. Not real surprising given than min() is implemented with float8s

Re: [SQL] min() and NaN

2003-07-19 Thread Stephan Szabo
On Sun, 20 Jul 2003, Tom Lane wrote: > "Michael S. Tibbetts" <[EMAIL PROTECTED]> writes: > > I'd expect the aggregate function min() to return the minimum, valid > > numeric value. Instead, it seems to return the minimum value from the > > subset of rows following the 'NaN'. > > Not real surprisi

Re: [SQL] Return a set of values from postgres Function

2003-07-19 Thread Stephan Szabo
On Thu, 17 Jul 2003, Derrick Betts wrote: > I want to get a set of values returned from a function. The values > (there will need to be four of them) come from 4 separate SELECT > statements inside the Function. For example SELECT one INTO variable1 > from table1 where ... then SELECT two INTO

Re: [SQL] SECURITY DEFINER changes CURRENT_USER?

2003-07-19 Thread Matthew Horoschun
Hi Chris, You want to use "session_user". I would expect this to change the password of the user currently logged in but instead it changes MY password. Evidently when a function is called which is set to SECURITY DEFINER, it changes the context of the current user. The CURRENT_USER then ret

Re: [SQL] changing an update via rules

2003-07-19 Thread Stephan Szabo
On 15 Jul 2003, Lauren Matheson wrote: > Hello, > > I am having difficulty setting an on update rule which seems to be > caught in a recursive loop. > > Context is a table with three columns assigning users to groups with the > third column being boolean to flag the primary group. I would like to

Re: [SQL] min() and NaN

2003-07-19 Thread Stephan Szabo
On Tue, 15 Jul 2003, Michael S. Tibbetts wrote: > Hi, > > I have a table containing a double precision column. That column > contains at least one judiciously placed NaN. > > I'd expect the aggregate function min() to return the minimum, valid > numeric value. Instead, it seems to return the min