Re: [SQL] SQL -select count-

2002-11-26 Thread Achilleus Mantzios
On Tue, 19 Nov 2002, Giannis wrote: > when I do : > > select count(column_name) from table_name > > should I get the count for all columns or just those which are not null? &Ggr;&igr;&aacgr;&ngr;&ngr;&eegr;, &thgr;&agr; &pgr;&aacgr;&rgr;&egr;&igr;&sfgr; &tgr;&ogr; &pgr;&lgr;&eeacgr;&thgr;&ogr;&sf

Re: [SQL] [SQL/BUGS] (possible) inconsistent behaviour of timestamp?

2002-11-26 Thread Tom Lane
"Rison, Stuart" <[EMAIL PROTECTED]> writes: > The first SELECT returns a 'timestamp', but the next two return a > 'timestamptz' (presumably with timezone); is this inconsitent behaviour? Yes. It's a transitional behavior in 7.2: timestamp without any quotes is translated by the parser to timestam

Re: [SQL] copy from command - quotes and header lines

2002-11-26 Thread Peter Eisentraut
Kenneth Evans writes: > On the other hand the COPY FROM file command has it the other way round - if the >separators are semi-colons then the source file > London;12;15.7 > Paris;13;22.2 > will work > > but > 'London'; '12'; '15.7' > 'Paris';'13';'22.2' > will not! The COPY input data is a separ

[SQL] Casting Money To Numeric

2002-11-26 Thread Thomas Good
Hi All. Having perused all the online docs I can find it appears there is no SQL solution for casting the dread money type to numeric. Is this true? select rent::numeric(9,2) from x; ERROR: Cannot cast type 'money' to 'numeric' I guess my cash ain't nothing but trash... ;-) TIA! --

Re: [SQL] celko nested set functions -- tree move

2002-11-26 Thread Martin Crundall
Hi Robert; The math actually works either way; if it goes negative, the offset is positive, which is okay. Your selects are way more elegant. I guess I was just raising the point that using a key other than lft (which tends to move around in an active tree), is probably safer. The table lock

Re: [SQL] escape single quote in INSERT command

2002-11-26 Thread Thomas Good
On Wed, 27 Nov 2002 [EMAIL PROTECTED] wrote: > Why dont' you use prepare and execute in case you are using DBI > same program is like this. > > $dbh = DBI -> connect ( ".."); > $sth = $dbh -> prepare("insert into tab (a,b) values (?,?)"); > $sth -> execute($a , $b ); > $sth -> finish(); > $db

Re: [SQL] escape single quote in INSERT command

2002-11-26 Thread Thomas Good
On Wed, 27 Nov 2002 [EMAIL PROTECTED] wrote: > Why dont' you use prepare and execute in case you are using DBI > same program is like this. > > $dbh = DBI -> connect ( ".."); > $sth = $dbh -> prepare("insert into tab (a,b) values (?,?)"); > $sth -> execute($a , $b ); > $sth -> finish(); > $db

Re: [SQL] escape single quote in INSERT command

2002-11-26 Thread Dan Langille
On 27 Nov 2002 at 0:01, [EMAIL PROTECTED] wrote: > > Hi Group - > > > > I have a perl application for a registration form. > > Same Here, > > Why dont' you use prepare and execute in case you are using DBI > same program is like this. > > $dbh = DBI -> connect ( ".."); > $sth = $dbh -> pre

Re: [SQL] escape single quote in INSERT command

2002-11-26 Thread mallah
> Hi Group - > > I have a perl application for a registration form. Same Here, Why dont' you use prepare and execute in case you are using DBI same program is like this. $dbh = DBI -> connect ( ".."); $sth = $dbh -> prepare("insert into tab (a,b) values (?,?)"); $sth -> execute($a , $b ); $

Re: [SQL] Are sub-select error suppressed?

2002-11-26 Thread Stephan Szabo
On Tue, 26 Nov 2002 [EMAIL PROTECTED] wrote: > > On Tue, 26 Nov 2002, Richard Huxton wrote: > > > >> On Tuesday 26 Nov 2002 9:43 am, patrick wrote: > >> > Greetings, > >> > > >> > I'm not sure what the correct behavior is here but the observed > >> > behavior seems "wrong" (or at least undesirable

Re: [SQL] How does postgres handle non literal string values

2002-11-26 Thread Rob Hills
Hi, On 25 Nov 2002 at 4:57, javaholic wrote: Your problem is really a JSP one rather than a postgres problem, and probably doesn't really belong on this list. That said, I know much more java/jsp than I do postgres, so I'll try and help. > I have some jsp code that should insert a user name

Re: [SQL] Are sub-select error suppressed?

2002-11-26 Thread dev
> On Tue, 26 Nov 2002, Richard Huxton wrote: > >> On Tuesday 26 Nov 2002 9:43 am, patrick wrote: >> > Greetings, >> > >> > I'm not sure what the correct behavior is here but the observed >> > behavior seems "wrong" (or at least undesirable). >> Don't look right to me, and I still see it here in 7.

Re: [SQL] join question

2002-11-26 Thread Stephan Szabo
On Fri, 22 Nov 2002, Nathan Young wrote: > Hi all. > > I have a table with members and a table with payments. Each payment is > related to a member by memberID and each payment has (among other things) a > year paid. > > I can create a join to find a list of members who have paid for a given yea

Re: [SQL] How does postgres handle non literal string values

2002-11-26 Thread Charles H. Woloszynski
Actually, we use JDBC Prepared Statements for this type of work. You put a query with '?' in as placeholders and then add in the values and the library takes care of the encoding issues. This avoids the double encoding of (encode X as String, decode string and encode as SQL X on the line). T

Re: [SQL] select for update

2002-11-26 Thread Stephan Szabo
On Wed, 20 Nov 2002, Justin Georgeson wrote: > I'm pretty new to databases in general, and would like to find a spiffy > way to do something. I want to use two columns from one table to > populate three columns in two other tables. Assuming t1 is the table I > want to take the values from, here is

Re: [SQL] celko nested set functions -- tree move

2002-11-26 Thread Robert Treat
I think you should take a closer look at Greg's function. It is uses lfts as parameters in the function mainly just to make the function implementation independent; I was able to easily adapt it to my schema which uses unique id's for each object in the tree hierarchy. After looking your function

Re: [SQL] How to recover Data

2002-11-26 Thread mallah
Sridhar such questions shud be posted to pgsql-admin list. generally in case of power failure pgsql is unable to remove its pid file., if u are using RPM based installation the file shud be in /var/lib/pgsql/ in the name of postmaster.pid If such a file exists postmaster will refuse to start. in

Re: [SQL] can i decrease the query time?

2002-11-26 Thread Stephan Szabo
On 20 Nov 2002, [EMAIL PROTECTED] wrote: > i created index already. how can i decrease the query time more. > > number of record is over 1 million. > the following is the query plan. > > Group (cost=34082.59..34085.62 rows=61 width=112) > -> Sort (cost=34082.59..34082.59 rows=607 width=112) > -> N

Re: [SQL] Are sub-select error suppressed?

2002-11-26 Thread Stephan Szabo
On Tue, 26 Nov 2002, Richard Huxton wrote: > On Tuesday 26 Nov 2002 9:43 am, patrick wrote: > > Greetings, > > > > I'm not sure what the correct behavior is here but the observed > > behavior seems "wrong" (or at least undesirable). > > > > I have a few tables and a view on one of the tables selec

Re: [SQL] How does postgres handle non literal string values

2002-11-26 Thread Richard Huxton
On Monday 25 Nov 2002 12:57 pm, javaholic wrote: > Hi All, > > I have some jsp code that should insert a user name and password into > a table called login. > > Instead of inserting the values given by the client, it insert the > literal string 'username' and 'password. The problem is somewhere in

Re: [SQL] SQL -select count-

2002-11-26 Thread Richard Huxton
On Tuesday 19 Nov 2002 5:06 pm, Giannis wrote: > when I do : > > select count(column_name) from table_name > > should I get the count for all columns or just those which are not null? Just "not null" - use count(*) or count(0) for a count of rows. -- Richard Huxton ---

Re: [SQL] help on sql query

2002-11-26 Thread Richard Huxton
On Tuesday 26 Nov 2002 1:14 pm, Zuev Dmitry wrote: > Suppose you have a table T: > > A B > 1 '111' > 2 '222' > > How do you select A and B of the record with A maximum? > 1) SELECT A, B FROM T ORDER BY A DESC LIMIT 1 > > 2) SELECT A, B FROM T WHERE A IN (SELECT MAX(A) FROM T) > > What

Re: [SQL] Two TIMESTAMPs in one pl/sql function

2002-11-26 Thread Richard Huxton
On Tuesday 26 Nov 2002 1:54 pm, Rison, Stuart wrote: > Hi, > > I'm trying to time a pl/sql function using a rougn and ready method, > basically: print a TIMESTAMP at the begining of the function, print a > TIMESTAMP at the end of the function. [snip] > Gives me: > > testdb2=# select timer(); > NOTI

Re: [SQL] subselect instead of a view...

2002-11-26 Thread Dan Langille
On 26 Nov 2002 at 0:29, Tom Lane wrote: > "Dan Langille" <[EMAIL PROTECTED]> writes: > > SELECT E.name, EP.pathname, E.id, EP2.pathname, CL.id > > ... > > and EP2.pathname like EP.pathname || '/%' > > > I am still suspicous of that like. It seems to be the performance > > killer here. The

Re: [SQL] How does postgres handle non literal string values

2002-11-26 Thread Henshall, Stuart - Design & Print
Title: RE: [SQL] How does postgres handle non literal string values I'm guessing it would have to be more like: <%     String insertString =     "INSERT INTO  \"login\" (\'user\', \'password\') VALUES ('"+username+"', '"+password+"')"; %> to actually con

[SQL] SQL -select count-

2002-11-26 Thread Giannis
when I do : select count(column_name) from table_name should I get the count for all columns or just those which are not null? __ Do you Yahoo!? Yahoo! Web Hosting - Let the expert host your site http://webhosting.yahoo.com

Re: [SQL] Problems invoking psql. Help please.

2002-11-26 Thread jasiek
> Here are the results from reversing the arguments. > > >hesco@biko:~$ su postgres > >Password: > >postgres@biko:/home/hesco$ cd > >postgres@biko:~$ cd /usr/bin > >postgres@biko:/usr/bin$ psql tempate1 -U postgres > >Could not execv /usr/lib/postgresql/bin/psql > >postgres@biko:/usr/bin$ psql tem

[SQL] How does postgres handle non literal string values

2002-11-26 Thread javaholic
Hi All, I have some jsp code that should insert a user name and password into a table called login. Instead of inserting the values given by the client, it insert the literal string 'username' and 'password. The problem is somewhere in the INSERT statement. Here is the code: <%@page contentType

[SQL] How to recover Data

2002-11-26 Thread Padmanab Sridhar
I had a m/c with Postgres 7.2 and huge amount of data. on Power failure and restart of the m/c pgsql refused connect to any of the database. Being an invoice i took a tar of the data dir. I tried reinstalling PGSQL and copied the data dir to the same dir where the new data is being stored. ie cp /b

[SQL] LIMIT and/or GROUP BY help!

2002-11-26 Thread Arcadius A.
Hello! I hope that someone here could help. I'm using PostgreSQL7.1.3 I have 3 tables: entry, subcategory and category. The table "entry" has a foreign key "subcategoryid" with reference to the table "subcategory", and the "subcategory" table has a foreign key "categoryid" with reference to th

[SQL] copy from command - quotes and header lines

2002-11-26 Thread Kenneth Evans
a) First an observation about populating tables. The standard syntax for literal values is to put single quotes around all the strings and not around the numbers eg insert into table values ('London', 12, 15.7); However when bulk loading from files it needs an extra step to find out which f

[SQL] SQL query help!

2002-11-26 Thread Arcadius A.
Hello! I hope that someone here could help. I'm using PostgreSQL7.1.3 I have 3 tables in my DB: the tables are defined in the following way: CREATE TABLE category( id SERIAL NOT NULL PRIMARY KEY, // etc etc ) ; CREATE TABLE subcategory( id SERIAL NOT NULL PRIMARY KEY, categoryid int CONSTRAI

[SQL] help on sql query

2002-11-26 Thread Zuev Dmitry
Suppose you have a table T: -- A B -- 1 '111' 2 '222' -- How do you select A and B of the record with A maximum? The desirable result therefore is (2, '222') The two variants I could grow with are: 1) SELECT A, B FR

[SQL] join question

2002-11-26 Thread Nathan Young
Hi all. I have a table with members and a table with payments. Each payment is related to a member by memberID and each payment has (among other things) a year paid. I can create a join to find a list of members who have paid for a given year (2002 in this case): select member.memberID,membe

Re: [SQL] escape single quote in INSERT command

2002-11-26 Thread mark carew
Woops should have been masquerading ---(end of broadcast)--- TIP 4: Don't 'kill -9' the postmaster

[SQL] escape single quote in INSERT command

2002-11-26 Thread Hunter
Hi Group - I have a perl application for a registration form. I'd like to put escape characters in my insert command to accommodate for ' (i.e. O'Brien, O'Malley, etc). I've tired double quotes, single quotes, back tick, forward ticks, curly bracket, round brackets - no success. Thanks, dave -

Re: [SQL] escape single quote in INSERT command

2002-11-26 Thread mark carew
Hi Hunter, From my xbase++ program suite, sqlcontext class. * cValue := strtran(cValue,['],[\']) * Its called masquarading, simply replace the single quote with back_slash + single quote. Regards Mark Carew Brisbane Australia

Re: [SQL] [HACKERS] [GENERAL] Bug with sequence

2002-11-26 Thread scott.marlowe
On 21 Nov 2002, Rod Taylor wrote: > On Thu, 2002-11-21 at 15:09, scott.marlowe wrote: > > On 21 Nov 2002, Rod Taylor wrote: > > > > > On Thu, 2002-11-21 at 14:11, Bruce Momjian wrote: > > > > Of course, those would be SQL purists who _don't_ understand > > > > concurrency issues. ;-) > > > > >

Re: [SQL] [HACKERS] [GENERAL] Bug with sequence

2002-11-26 Thread scott.marlowe
On 21 Nov 2002, Rod Taylor wrote: > On Thu, 2002-11-21 at 14:11, Bruce Momjian wrote: > > Of course, those would be SQL purists who _don't_ understand > > concurrency issues. ;-) > > Or they're the kind that locks the entire table for any given insert. Isn't that what Bruce just said? ;^) --

Re: [SQL] [HACKERS] [GENERAL] Bug with sequence

2002-11-26 Thread Rod Taylor
On Thu, 2002-11-21 at 14:11, Bruce Momjian wrote: > Of course, those would be SQL purists who _don't_ understand > concurrency issues. ;-) Or they're the kind that locks the entire table for any given insert. -- Rod Taylor <[EMAIL PROTECTED]> ---(end of broadcast)-

[SQL] retrieving specific info. from one column and locating it in another

2002-11-26 Thread MARC BEDOIS
I'm trying to retrieve some info from one column and put it in another. I have a column that has a bunch of information in it called 'Route'. I don't need to show all of that information. Instead I need divide that single column into two seperate columns called 'Sender' and 'Receiver'. How do I

[SQL] select for update

2002-11-26 Thread Justin Georgeson
I'm pretty new to databases in general, and would like to find a spiffy way to do something. I want to use two columns from one table to populate three columns in two other tables. Assuming t1 is the table I want to take the values from, here is the structure of what I want to insert into t2 an

[SQL] can i decrease the query time?

2002-11-26 Thread [EMAIL PROTECTED]
i created index already. how can i decrease the query time more. number of record is over 1 million. the following is the query plan. Group (cost=34082.59..34085.62 rows=61 width=112) -> Sort (cost=34082.59..34082.59 rows=607 width=112) -> Nested Loop (cost=0.00..34054.51 rows=607 width=112) ->

Re: [SQL] Problems invoking psql. Help please.

2002-11-26 Thread Hugh Esco
Thank you Tom Lane and Oliver Elphick. Here is the latest shell dialogue. postgres@biko:/home/hesco$ ./usr/lib/postgresql/bin/psql -d template1 sh: ./usr/lib/postgresql/bin/psql: No such file or directory postgres@biko:/home/hesco$ /usr/lib/postgresql/bin/psql -d template1 sh: /usr/lib/postgresq

Re: [SQL] Date trunc in UTC

2002-11-26 Thread Juan Fernandez
Hi Richard Ok, I'll do my best to explain clearer ;) I have to make some monthly reports about some service requests activity. So, I'm keeping in a table the monthly traffic. TABLE traffic +-+++ | service | month | visits | +-+---

[SQL] Two TIMESTAMPs in one pl/sql function

2002-11-26 Thread Rison, Stuart
Hi, I'm trying to time a pl/sql function using a rougn and ready method, basically: print a TIMESTAMP at the begining of the function, print a TIMESTAMP at the end of the function. So...: CREATE OR REPLACE FUNCTION timer() RETURNS INTEGER AS ' DECLARE timer1 TIMESTAMP; timer2 T

[SQL] [SQL/BUGS] (possible) inconsistent behaviour of timestamp?

2002-11-26 Thread Rison, Stuart
Here's an "interesting" timestamp related postgreSQL quirk: testdb2=# select "timestamp"('now'); timestamp 2002-11-26 13:47:12.454157 (1 row) testdb2=# select 'now'::timestamp; timestamptz -- 2002-11-26 13:47:34.88358+00

[SQL] Inheritance in SQL99 ?

2002-11-26 Thread Albrecht Berger
Hello, is the inheritance of tables specified in the SQL99 standard, or is this a postgresql "add-on" ? Does anybody know when the primary key bug, which is documented in the docs, of this feature will be fixed ? Thx berger ---(end of broadcast)-

Re: [SQL] PL/SQL trouble

2002-11-26 Thread Christoph Haller
> I really don't understand following PostgreSQL 7.2.3 behaviour: > > $ psql mydb > mydb=> CREATE FUNCTION MONDAY(timestamp) RETURNS DATE AS ' > DECLARE > var1 date; > BEGIN > select into var1 to_date($1::date-(case when extract(DOW from > timestamp $1) = 0 then 6 else (extract(DOW from times

Re: [SQL] PL/SQL trouble

2002-11-26 Thread Richard Huxton
On Tuesday 26 Nov 2002 8:56 am, Ferruccio Zamuner wrote: > CREATE FUNCTION MONDAY(timestamp) RETURNS DATE AS ' > DECLARE > var1 date; > BEGIN > select into var1 to_date($1::date-(case when extract(DOW from > timestamp $1) = 0 then 6 else (extract(DOW from timestamp $1)-1) end)); > RETURN va

Re: [SQL] Are sub-select error suppressed?

2002-11-26 Thread Richard Huxton
On Tuesday 26 Nov 2002 9:43 am, patrick wrote: > Greetings, > > I'm not sure what the correct behavior is here but the observed > behavior seems "wrong" (or at least undesirable). > > I have a few tables and a view on one of the tables selecting > entries that may be purged. > > My delete statement

[SQL] Are sub-select error suppressed?

2002-11-26 Thread patrick
Greetings, I'm not sure what the correct behavior is here but the observed behavior seems "wrong" (or at least undesirable). I have a few tables and a view on one of the tables selecting entries that may be purged. My delete statement uses the view to delete data from one of the tables. Like so

[SQL] PL/SQL trouble

2002-11-26 Thread Ferruccio Zamuner
Hi, I really don't understand following PostgreSQL 7.2.3 behaviour: $ psql mydb mydb=> CREATE FUNCTION MONDAY(timestamp) RETURNS DATE AS ' DECLARE var1 date; BEGIN select into var1 to_date($1::date-(case when extract(DOW from timestamp $1) = 0 then 6 else (extract(DOW from timestamp $1)-1)