[SQL] SQL Date help

2001-03-26 Thread waheed_rahuman
Hi, I am a newbie to SQL and postgresql too. please guide me in the following... 1.How i can create date while i am inserting into the table ,in which the field is date data type.(date should not be a current date and its should be created as in java date(int,int,int) 2. How i can compare th

Calling Java from psql (was Re: [SQL] requesting help)

2001-03-26 Thread Mathijs Brands
On Mon, Mar 26, 2001 at 09:53:52AM +0200, Poul L. Christiansen allegedly wrote: > Log into PostgreSQL using psql and run the help command: > "\h create trigger". > > See also: > http://www.postgresql.org/users-lounge/docs/6.5/postgres/sql-createtrigger.htm > > HTH, > Poul L. Christiansen > > On

Re: [SQL] SQL Date help

2001-03-26 Thread Karel Zak
On Mon, Mar 26, 2001 at 12:24:07PM +0400, waheed_rahuman wrote: > > > Hi, > > I am a newbie to SQL and postgresql too. > please guide me in the following... Any problem with documentation? > 1.How i can create date while i am inserting into the table ,in which the > field is date data type.(

[SQL] Functions and Triggers

2001-03-26 Thread Norbert Schollum
Hello there! here is what i want to realize: a trigger, that puts a now() in the last_updated field, on any update of that table. i read the manual but i wasnt able to make a working function. what is the return value here? is there any or is it void? has somebody a example for me that is simi

[SQL] Still don't know how to build this string ?

2001-03-26 Thread juerg . rietmann
Hello there I have still the same problem. Any help would really be appreciated ! Thanks ... jr Is it possible (and I think it is) to do the following : I have a table with diameters and types. I need to build a comma separated string. typ diam 01800 01840 01870 0

Re: [SQL] Still don't know how to build this string ?

2001-03-26 Thread Richard Huxton
From: <[EMAIL PROTECTED]> > I have a table with diameters and types. I need to build a comma separated > string. > > typ diam > 01800 [snip] > > select diam from zylinder where typ='01' > > should produce the string "800,840,870,1120" Try the following as a starting point: CREATE

Re: [SQL] Functions and Triggers

2001-03-26 Thread Richard Huxton
From: "Norbert Schollum" <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]> Sent: Monday, March 26, 2001 10:24 AM Subject: [SQL] Functions and Triggers > Hello there! > > here is what i want to realize: > > a trigger, that puts a now() in the last_updated field, on any update of > that table. > > i rea

[SQL] Help

2001-03-26 Thread Mohamed ebrahim
Hi, Thanks for your valuable information. I tried the cron. i typed cron -e and entereed into the input area. but i don't know how to save the cron file. I pressed ctrl+z and came out from cron. but i edit the cron file i found nothing on it.(i.e using pico filename.) Please tell me some de

Re: [SQL] Still don't know how to build this string ?

2001-03-26 Thread Michael Fork
The following function will convert a given list into a comma delimited string (the argument should be the typ): CREATE FUNCTION dima_list(int4) RETURNS text AS ' DECLARE recrecord; list text; BEGIN list :=

[SQL] is it me or trigger side effects

2001-03-26 Thread Najm Hashmi
Hi all, I have written a trigger to update a table called categories whenever a tuple is either deleted or inserted in tables articles, media, and links. It works fine for inserts but "pukes" on deletes :). I am using two auxiliary addcount(varchar) and delecount (varchar) I am getting the follow

Re: [SQL] Functions and Triggers

2001-03-26 Thread Cedar Cox
CREATE FUNCTION lastupdated() RETURNS opaque AS ' begin new.last_updated := CURRENT_TIMESTAMP; return new; end; ' LANGUAGE 'plpgsql'; CREATE TRIGGER trigname BEFORE INSERT OR UPDATE on tblname FOR EACH ROW EXECUTE PROCEDURE lastupdated(); Note: you could use now() instead of CURRENT_TIMES

Re: [SQL] Help

2001-03-26 Thread Joe Conway
> Thanks for your valuable information. I tried the > cron. i typed >cron -e > and entereed into the input area. but i don't know how > to save the cron file. I pressed ctrl+z and came out > from cron. but i edit the cron file i found nothing on > it.(i.e using pico filename.) Please tell me

[SQL] RE: Still don't know how to build this string ?

2001-03-26 Thread Jeff Eckermann
Still learning this stuff, so please be gentle... jeff=# select * from test_it; typ | diam -+-- 01 | 800 01 | 840 01 | 870 01 | 1120 02 | 760 02 | 780 02 | 800 02 | 900 03 | 1200 03 | 1234 03 | 1352 (11 rows) jeff=# \! cat test_it drop function test_it_too(text);

Re: [SQL] is it me or trigger side effects

2001-03-26 Thread Stephan Szabo
> create function updateCat() returns opaque as ' > declare > rec record; > rename new to cat; > rename old to ct; > maxlen integer; > > begin > if tg_op = ''INSERT'' and cat.category is null then > raise exception ''You are missing entry for category field'';

[SQL] paging

2001-03-26 Thread A. Van Hook
I have a simple script to automate sql statements: q " select * from tablename" where q is an alias to echo "$@ ; " | psql imdb Turning on security breaks this script since is need s password. the new one works a before: q "select *..." passwd where q is now an expect script: #!/usr/bin/

Re: [SQL] paging

2001-03-26 Thread Peter Eisentraut
A. Van Hook writes: > #!/usr/bin/expect > > set query [lindex $argv 0] > set query [lindex $argv 1] > > spawn psql imdb -U hook -n > expect "Password: "; > send "$passwd\n "; > expect "imdb=# "; > send "$query;\r"; > expect "imdb=# "; >

Re: Calling Java from psql (was Re: [SQL] requesting help)

2001-03-26 Thread Peter Eisentraut
Mathijs Brands writes: > Has anybody ever tried calling Java code from a pgsql trigger written > in C? Shouldn't this be possible using JNI? I have, and given the current Java implementations it's a desaster. -- Peter Eisentraut [EMAIL PROTECTED] http://yi.org/peter-e/ ---

Re: Calling Java from psql (was Re: [SQL] requesting help)

2001-03-26 Thread Mathijs Brands
On Mon, Mar 26, 2001 at 07:00:43PM +0200, Peter Eisentraut allegedly wrote: > Mathijs Brands writes: > > > Has anybody ever tried calling Java code from a pgsql trigger written > > in C? Shouldn't this be possible using JNI? > > I have, and given the current Java implementations it's a desaster.

Re: [SQL] Help

2001-03-26 Thread selkovjr
> Instead of "ctrl+z", press ":wq" (colon for command mode, w for write, q for > quit). If you are still mystified, "ctrl+z" stops a process running on a terminal, so it's likely that your vi is still running idle. Type 'fg' on the same terminal to bring it back. For more details on job control,

[SQL] pl/pgsql and returning rows

2001-03-26 Thread wade
Here is the senario... I have a table defined as create table details ( field1 field2 . . . ); and a function: create function get_details(int4) returns details as ' declare ret details%ROWTYPE; site_recrecord; cntct contacts%ROWTYPE; begin select

[SQL] Function Vanished

2001-03-26 Thread Josh Berkus
Tom, Jan, I've already contacted PGSQL Inc. support about this, but I thought that you might have some immediate insight. I'm using 7.1 Beta 3, which has been pretty stable up until now. This morning, I went to export a function I spent 5 hours debugging on on Friday to text so

[SQL] Implicit/Explicit casting of the unknown type

2001-03-26 Thread Stephen Jackson
Hi, I am new to this list. I have browsed the list archives and tried a search, but haven't found anything about my problem. I am porting several applications to PostgreSQL and have come across a number of instances where a string literal does not work without an explicit cast to some character

Re: [SQL] Help

2001-03-26 Thread Cedar Cox
> > Thanks for your valuable information. I tried the > > cron. i typed > >cron -e > > and entereed into the input area. but i don't know how > > to save the cron file. I pressed ctrl+z and came out > > from cron. but i edit the cron file i found nothing on > > it.(i.e using pico filename.)

Re: [SQL] is it me or trigger side effects

2001-03-26 Thread Cedar Cox
On Mon, 26 Mar 2001, Stephan Szabo wrote: > > > create function updateCat() returns opaque as ' > > declare > > rec record; > > rename new to cat; > > rename old to ct; > > maxlen integer; > > > > begin > > if tg_op = ''INSERT'' and cat.category is null then > >

Re: [SQL] Function Vanished

2001-03-26 Thread Tom Lane
"Josh Berkus" <[EMAIL PROTECTED]> writes: > I'm using 7.1 Beta 3, which has been pretty stable up until now. This > morning, I went to export a function I spent 5 hours debugging on on > Friday to text so that I could have a copy of the final version. To my > horror, the function was GONE

Re: [SQL] Function Vanished

2001-03-26 Thread Josh Berkus
Tom, > Ick. Were you maybe working on it inside a transaction that you > forgot > to commit? Nope. Friday was debugging work; the function had already been saved as a buggy version. I can even find the last buggy call to the function, on Friday, in the logs. I do have a copy of the buggy ver

[SQL] serial type; race conditions

2001-03-26 Thread jkakar
Hi, I'm using serial fields to generate IDs for almost all object in my database. I insert an empty row, get the CURRVAL() of the sequence and then update to that value. I had understood (and now, I can't find the reference to back this up) that serial is implemented in such a way that race con

Re: [SQL] Function Vanished

2001-03-26 Thread Tom Lane
"Josh Berkus" <[EMAIL PROTECTED]> writes: >> Should still be there in the table, if you haven't vacuumed. Getting >> it out again is another story though. If it was a small enough >> function, >> good ol' "strings" would do to extract the function body, which is >> probably all that you really n

Re: [SQL] serial type; race conditions

2001-03-26 Thread Bruce Momjian
> Hi, > > I'm using serial fields to generate IDs for almost all object in my > database. I insert an empty row, get the CURRVAL() of the sequence > and then update to that value. > > I had understood (and now, I can't find the reference to back this up) > that serial is implemented in such a w

[SQL] ÁY¼gªº§t¸q

2001-03-26 Thread S.F. Lee
--- Tom Lane <[EMAIL PROTECTED]> wrote: > > I'm using 7.1 Beta 3, which has been pretty > stable up until now. This > > morning, I went to export a function I spent 5 > hours debugging on on > > Friday to text so that I could have a copy of the > final version. To my > > horror, the functio

Re: [SQL] Function Vanished

2001-03-26 Thread Justin Clift
Hi would it work to do a pg_dump -d or a pgdumpall, then look through the dumped sql file? I do that to retrieve PL/pgSQL functions from the database when I've accidentally wiped or modified the source (not often, but it happens). Regards and best wishes, Justin Clift Tom Lane wrote: > > "Jos