[SQL] Index Problem

2001-02-09 Thread Kim Yunhan
I want to query this... --> SELECT * FROM bbs ORDER BY ref desc, step ASC LIMIT 12; this query doesn't refer the index that made by this query. --> CREATE INDEX idx_bbs ON bbs (ref, step); but, i change the query that "ref desc" to "ref asc". then query refer the index, and i can see a result v

[SQL] pgsql and cursor

2001-02-09 Thread Najm Hashmi
Hi all, I am not sure If it is allowed to use cursor inside pgsql functions. If it is possible, please someone could send exact synatx how it is used. If it is not allowed is there a way arround it? I need to do some calculations and then return this value as text. Thanks in advance for all your

[SQL] What's wrong with this function

2001-02-09 Thread Najm Hashmi
Hi all, Here is a plpgsql function: flipr'#create function test_cur() returns text as' flipr'# declare flipr'# mycur cursor for select title from songs where song_id=10; flipr'# usrrecord; flipr'# resultstext; flipr'# begin flipr'# open mycur; flipr'# fetch next from mycur into

Re: [SQL] pgsql and cursor

2001-02-09 Thread Jie Liang
I just know you can use implict cursor inside the plpgsql e.g declare rec record; begin FOR rec IN select_clause LOOP statements END LOOP; end; Jie LIANG St. Bernard Software Internet Products Inc. 10350 Science Center Drive Suite 100, San Diego, CA 92121 Office:(858)320-4873 [EMAIL PRO

Re: [SQL] What's wrong with this function

2001-02-09 Thread Jie Liang
I just know you can use implict cursor inside the plpgsql e.g declare rec record; begin FOR rec IN select_clause LOOP statements END LOOP; end; Jie LIANG St Bernard Software Internet Products Inc. 10350 Science Center Drive Suite 100, San Diego, CA 92121 Office:(858)320-4873 [EMAIL PRO

[SQL] PL/PGSQL Cook Book

2001-02-09 Thread plpgsql
I've just spent the last day or two trying to get to grips with plpgsql and can't believe how abysmal the documetentation and examples are. I've been trawling through the mailist lists and I notice there was talk back in 1999 abouta PLPGSQL Cook Book - did anything come of this? If no one is ma

[SQL] Recusrive Functions in 7.0.3

2001-02-09 Thread plpgsql
Are recursive functions allowed in in 7.0.3 as I seem to be unable to get them to work in plpgsql, it just freezes and I have to do ctrl-alt-c. ie calling the same function name from within some form of loop, possible to 4 or 5 levels? Also is it possible to output any debugging info, all I rea

Re: [SQL] What's wrong with this function

2001-02-09 Thread Najm Hashmi
Jie Liang wrote: > I just know you can use implict cursor inside the plpgsql > e.g > declare result text; tcount int4; > > rec record; > begin > FOR rec IN select_clause LOOP > statements > END LOOP; > end; > Thank you Jie for your help. I am bit confused about how it works. I want for ea

[SQL] String Concatnation

2001-02-09 Thread Najm Hashmi
Hi, How can I concatnate two varialbles, seperated by a |, that are type text together? v, v1 text; some work then res:= v ||''|''|| v1; this syntex does not work in plpgsql?? Any ideas how to do it ??? Thanks. Najm

Re: [SQL] What's wrong with this function

2001-02-09 Thread plpgsql
the select query returns the first row to rec. You can then access its values with: rec.field_name at END LOOP it jumps back to FOR checks to see if there any more rows and if so moves to the next row and repeats the loop. It also looks like your missing a LOOP keyword at the end of the FOR line

Re: [SQL] String Concatnation

2001-02-09 Thread Brett W. McCoy
On Sat, 10 Feb 2001, Najm Hashmi wrote: > How can I concatnate two varialbles, seperated by a |, that are type text > together? > v, v1 text; > some work > then > res:= v ||''|''|| v1; What error is it giving? Do you need to be using two single quotes in the statement? -- Brett

Re: [SQL] String Concatnation

2001-02-09 Thread Stephan Szabo
I was able to do a function that took two arguments and did that under 7.1beta3 with no trouble. What message are you getting? On Sat, 10 Feb 2001, Najm Hashmi wrote: > Hi, > How can I concatnate two varialbles, seperated by a |, that are type text > together? > v, v1 text; > some work > th

Re: [SQL] pgsql and cursor

2001-02-09 Thread Ian Lance Taylor
Najm Hashmi <[EMAIL PROTECTED]> writes: > Hi all, I am not sure If it is allowed to use cursor inside pgsql functions. > If it is possible, please someone could send exact synatx how it is used. If > it is not allowed is there a way arround it? I need to do some calculations > and then return t

Re: [SQL] What's wrong with this function

2001-02-09 Thread Jie Liang
Try: create function foo(text) returns int4 as ' delcare tcount int4:=0; begin for rec IN select title, dcount from songs where artist=$1 LOOP tcount:= tcount+rec.dcount; END LOOP; return tcount; end; ' language 'plpgsql'; call it by: db> select foo('Najm Hashmi'); it will return how

Re: [SQL] String Concatnation

2001-02-09 Thread Jie Liang
Hi, You can use every sql function and operator in plpgsql, so v||''|''||v2 is OK. however, you cannot do: declare v,v2 text; you should do: v text; v2 text; also you initialize like: v text:=; Jie LIANG St. Bernard Software Internet Products Inc. 10350 Science Center Drive Suite 100, San

[SQL] Re: PL/PGSQL Cook Book

2001-02-09 Thread ender
On Friday 09 February 2001 12:23, [EMAIL PROTECTED] wrote: > I've just spent the last day or two trying to get to grips with plpgsql and > can't believe how abysmal the documetentation and examples are. I've been > trawling through the mailist lists and I notice there was talk back in 1999 > about

Re: [SQL] Re: PL/PGSQL Cook Book

2001-02-09 Thread Bruce Momjian
[ Charset ISO-8859-1 unsupported, converting... ] > On Friday 09 February 2001 12:23, [EMAIL PROTECTED] wrote: > > I've just spent the last day or two trying to get to grips with plpgsql and > > can't believe how abysmal the documetentation and examples are. I've been > > trawling through the mail

[SQL] how to download postgresql 7.1 beta

2001-02-09 Thread guard
thanks

Re: [SQL] Recusrive Functions in 7.0.3

2001-02-09 Thread Tom Lane
<[EMAIL PROTECTED]> writes: > Are recursive functions allowed in in 7.0.3 Sure. play=> create function myfactorial(int) returns int as ' play'> begin play'> if $1 > 1 then play'> return $1 * myfactorial($1 - 1); play'> end if; play'> return $1; play'> end;' language 'plpgsql'; CREATE p