[SQL] altering column width

2002-06-24 Thread tdn
Hi there, How do I increase the width of a column in a table. Can I do it without having to shut down the database? Rgds TDN ---(end of broadcast)--- TIP 3: if posting/reading through Usenet, please send an appropriate subscribe-nomail command

Re: [SQL] assign count() result to a declared variable in plpgsql

2002-06-24 Thread Tom Lane
Joseph Syjuco <[EMAIL PROTECTED]> writes: > i want to put my count() result in a plpgsql declared integer variable > declare f_count_var integer; > begin > select into f_count_var count(empno) from employee > end; > tried this one but it doesnt work Works for me: regression=# create functi

Re: [SQL] Request for builtin function: Double_quote

2002-06-24 Thread Josh Berkus
Tom, > Done; I also added its sister function quote_ident. See the devel > docs at > http://candle.pha.pa.us/main/writings/pgsql/sgml/functions-string.html Tante Grazie. -- -Josh Berkus ---(end of broadcast)--- TIP 6: Have you searched our

Re: [SQL] Request for builtin function: Double_quote

2002-06-24 Thread Tom Lane
"Josh Berkus" <[EMAIL PROTECTED]> writes: > Well, first off, quote_literal isn't in the documentation under > "Functions and Operators".So this is the first I've heard about it > -- or probably anyone else outside the core team. How long has it > been around? Awhile; however, the only docum

Re: [SQL] Can somebody help me to optimize this huge query?

2002-06-24 Thread Josh Berkus
Dirk, > SELECT DISTINCT > t_sek.docindex, > t_sek.envelope, > bt.oid, > bt.time > FROM > boxinfo bt, boxinfo bd, boxinfo bo, > docobj t_sek, docobj t_pgr, docobj t_sta, docobj t_sol, > docobj d_pnr, docobj d_sta, > docobj o_sek, docobj o_pgr, docobj o_pnr > WHERE > t_sek.docspe

Re: [SQL] Slow SELECT with distinct, in a TIMESTAMP type column

2002-06-24 Thread Marcos Garcia
When i make the set enable_seqscan = off the result is: dbname=# set enable_seqscan = off; SET VARIABLE dbname=# explain analyze SELECT distinct(smsdate) FROM send_total; NOTICE: QUERY PLAN: Unique (cost=0.00..31084.39 rows=1232 width=8) (actual time=108.60..195210.91 rows=6676 loops=1) ->

Re: [SQL] Slow SELECT with distinct, in a TIMESTAMP type column

2002-06-24 Thread Stephan Szabo
On 24 Jun 2002, Marcos Garcia wrote: > > When i make the set enable_seqscan = off the result is: > > dbname=# set enable_seqscan = off; > SET VARIABLE > dbname=# explain analyze SELECT distinct(smsdate) FROM send_total; > > NOTICE: QUERY PLAN: > > Unique (cost=0.00..31084.39 rows=1232 width=8)

Re: [SQL] Slow SELECT with distinct, in a TIMESTAMP type column

2002-06-24 Thread Stephan Szabo
On 24 Jun 2002, Marcos Garcia wrote: > The problem is that my query is too slow when i use distinct: > > pgsql> explain analyze SELECT distinct(smsdate) FROM send_total; > > NOTICE: QUERY PLAN: > > Unique (cost=15840.31..15870.81 rows=1220 width=8) (actual > time=56358.93..56452.78 rows=6670 l

Re: [SQL] assign count() result to a declared variable in plpgsql

2002-06-24 Thread Jeff Eckermann
try: f_count_var := count(empno) from employee; --- Joseph Syjuco <[EMAIL PROTECTED]> wrote: > > i want to put my count() result in a plpgsql > declared integer variable > > > declare f_count_var integer; > begin > select into f_count_var count(empno) from employee > end; > > tried this

Re: [SQL] variance aggregate function incorrect? Reference Materials

2002-06-24 Thread Bruce Momjian
Joseph Syjuco wrote: > hi > i needed the variance function ... i dont know if i introduced the wrong > parameters or maybe this variance is not the variance that im looking > for but it doesnt provide the right results > > variance=(nEx^2 - (Ex)^2)/(n(n-1)) > my sql statement > select variance(an

Re: [SQL] variance aggregate function incorrect? Reference Materials reg create aggregate

2002-06-24 Thread Tom Lane
Joseph Syjuco <[EMAIL PROTECTED]> writes: > i needed the variance function ... i dont know if i introduced the wrong > parameters or maybe this variance is not the variance that im looking > for but it doesnt provide the right results > variance=(nEx^2 - (Ex)^2)/(n(n-1)) That's what I'd expect i

[SQL] Slow SELECT with distinct, in a TIMESTAMP type column

2002-06-24 Thread Marcos Garcia
Hi, I've a table "send_total" like this: Table "send_total" Column | Type | Modifiers ---+--+--- id

[SQL] index problem

2002-06-24 Thread Oleg Lebedev
Title: Message Hi, I have an objectid field of type bigint, but when I run queries like: select * from table where objectid=123; index is not used on objectid even though it's declared. However when I run: select * from table where objectid='123'; index is used. Is there an optionĀ I can

[SQL] assign count() result to a declared variable in plpgsql

2002-06-24 Thread Joseph Syjuco
i want to put my count() result in a plpgsql declared integer variable declare f_count_var integer; begin select into f_count_var count(empno) from employee end; tried this one but it doesnt work ---(end of broadcast)--- TIP 3:

Re: [SQL] slow DELETE queries

2002-06-24 Thread Denis
On Thursday 20 June 2002 05:01 pm, you wrote: > On Thu, 20 Jun 2002 15:23:53 +0200, Denis <[EMAIL PROTECTED]> wrote: > >I traced the queries slowing it all down to this snippet in the debug log: > >DELETE FROM phpbb_search_wordlist WHERE word_id IN ( > >SELECT word_id FROM phpbb_search_wordmatch W

[SQL] variance aggregate function incorrect? Reference Materials regcreate aggregate

2002-06-24 Thread Joseph Syjuco
hi i needed the variance function ... i dont know if i introduced the wrong parameters or maybe this variance is not the variance that im looking for but it doesnt provide the right results variance=(nEx^2 - (Ex)^2)/(n(n-1)) my sql statement select variance(answer) from tbl_answer (where answer i

Re: [SQL] Select + min question

2002-06-24 Thread Devrim GUNDUZ
Hi, On Sun, 23 Jun 2002, Christopher Kings-Lynne wrote: > > Use a subselect (and don't compare to 't' if it's a boolean field...) > > SELECT b_date FROM test WHERE active AND id=(SELECT min(id) FROM test) LIMIT > 1; It'a a shame for me that I could not think of using subselects :-( Anyway, t

Re: [SQL] rowtype and ecpg

2002-06-24 Thread Christoph Haller
What exactly is your problem? Calling a plpgsql function from within a C program or retrieving varchar data within a C program? Regards, Christoph > > I have a function that takes as a parameter ROWTYPE: > > create or replace function test_func(test_table) > returns varchar as ' > declare