Re: [SQL] Explicite typecasting of functions

2002-08-14 Thread Andreas Tille
On Wed, 14 Aug 2002, Tom Lane wrote: > I concur with Richard that Andreas needs to solve a different problem, > but just for the record, the way you could do it is > > CREATE TABLE without mentioning the default > > CREATE FUNCTION > > ALTER TABLE ... SET DEFAULT > > Note howeve

Re: [SQL] Explicite typecasting of functions

2002-08-14 Thread Andreas Tille
On Wed, 14 Aug 2002 Richard Huxton wrote: > > CREATE TABLE Items ( > > Idint DEFAULT NextItem() > > > CREATE FUNCTION NextItem() RETURNS INT4 > > AS 'select max(Id)+1 from Items where Id < 100;' > > LANGUAGE 'sql'; > > >ERROR: Relation "items" does not exist > > > > Any hin

Re: [SQL] Need Help for select

2002-08-14 Thread Masaru Sugawara
On Wed, 14 Aug 2002 16:04:21 +0200 Andre Schubert <[EMAIL PROTECTED]> wrote: > I want to compare if a tuple in c exist in b for each c.d_id and b.a_id. > In c exists 3 tuples: (1,2), (3,4), (5) > and want to find these tuples in b. Probably I would think I have reached the correct query. Table

[SQL] DISTINCT peformance differences

2002-08-14 Thread Christopher Kings-Lynne
If art_id is the primary key of the la table, is the latter faster? SELECT DISTINCT la.* FROM ... or SELECT DISTINCT ON (la.art_id) la.* FROM ... ie. Does this offer a performance improvement by only doing the distinct on the primary key or not? Thanks, Chris ---(

Re: [SQL] Need Help for select

2002-08-14 Thread Masaru Sugawara
On Wed, 14 Aug 2002 16:04:21 +0200 Andre Schubert <[EMAIL PROTECTED]> wrote: > > > > > > If this mention implies that the tuple of (1, 1) in the c is supposed ^^ b > > to t

Re: [SQL] concurrent connections is worse than serialization?

2002-08-14 Thread Richard Huxton
On Wednesday 14 Aug 2002 4:29 pm, Wei Weng wrote: > > [30 connections is much slower than 1 connection 30 times] > > Yeah, but the problem is, say I have 20 users using select on the > database at the same time, and each select takes 10 seconds to finish. I > really can't queue them up (or the las

Re: [SQL] sql function examples requested (! select)

2002-08-14 Thread Tom Lane
Sue Humphrey <[EMAIL PROTECTED]> writes: > I would like examples of functions using update, insert and > delete, where LANGUAGE 'SQL', both how to write them and how to > use them. Have you read the documentation? http://www.ca.postgresql.org/users-lounge/docs/7.2/postgres/xfunc-sql.html The fi

Re: [SQL] concurrent connections is worse than serialization?

2002-08-14 Thread Tom Lane
Wei Weng <[EMAIL PROTECTED]> writes: > On Wed, 2002-08-14 at 10:49, Richard Huxton wrote: >> If it's not CPU, is the system going into swap or are you seeing a >> lot of disk activity? > I did hear a lot of disk noise when I ran the test. How do I tell if the > "system is going into swap"? Try r

[SQL] sql function examples requested (! select)

2002-08-14 Thread Sue Humphrey
I would like examples of functions using update, insert and delete, where LANGUAGE 'SQL', both how to write them and how to use them. I've got examples of functions as selects coming out of my ears, and PL/pgsql examples of more complex needs, but I just need to run a simple UPDATE. And I forsee

Re: [SQL] concurrent connections is worse than serialization?

2002-08-14 Thread Wei Weng
On Wed, 2002-08-14 at 10:49, Richard Huxton wrote: > On Wednesday 14 Aug 2002 3:20 pm, Wei Weng wrote: > > On Wed, 2002-08-14 at 05:18, Richard Huxton wrote: > > > On Tuesday 13 Aug 2002 9:39 pm, Wei Weng wrote: > > [30 connections is much slower than 1 connection 30 times] Yeah, but the problem

Re: [SQL] Explicite typecasting of functions

2002-08-14 Thread Tom Lane
Richard Huxton <[EMAIL PROTECTED]> writes: > On Wednesday 14 Aug 2002 10:30 am, Andreas Tille wrote: >> Any hint to solve this kind of chicken-egg-problem? > Your solution is not safe anyway - you could end up with two processes trying > to insert the next value. I concur with Richard that Andre

Re: [SQL] concurrent connections is worse than serialization?

2002-08-14 Thread Richard Huxton
On Wednesday 14 Aug 2002 3:20 pm, Wei Weng wrote: > On Wed, 2002-08-14 at 05:18, Richard Huxton wrote: > > On Tuesday 13 Aug 2002 9:39 pm, Wei Weng wrote: [30 connections is much slower than 1 connection 30 times] > > What was the limiting factor during the test? Was the CPU maxed, memory, > > d

Re: [SQL] pgsql-sql@postgresql.org

2002-08-14 Thread philip johnson
thanks very much -Message d'origine- De : Stephan Szabo [mailto:[EMAIL PROTECTED]] Envoye : mercredi 14 aout 2002 16:36 A : philip johnson Cc : [EMAIL PROTECTED] Objet : Re: [SQL] [EMAIL PROTECTED] On Wed, 14 Aug 2002, philip johnson wrote: > I've a stored procedure I'd like to migrate

Re: [SQL] pgsql-sql@postgresql.org

2002-08-14 Thread Stephan Szabo
On Wed, 14 Aug 2002, philip johnson wrote: > I've a stored procedure I'd like to migrate from MS SqlServer > to Postgresql 7.2.1. How can I do ? > here is the stored procedure > CREATE PROCEDURE ws_doc_tree_new > @parent_node_id int, > @label varchar(50), > @publication varchar(32) Here, y

Re: [SQL] Few Queries

2002-08-14 Thread Tom Lane
"Sugandha Shah" <[EMAIL PROTECTED]> writes: > CREATE FUNCTION del_old_history() RETURNS bool AS ' > declare >var_history_age_limit int4; >set_timedatetime; > BEGIN > select into var_history_age_limit history_age_limit from database_info; > IF (var_history_age_limit is not null) THEN

Re: [SQL] concurrent connections is worse than serialization?

2002-08-14 Thread Wei Weng
On Wed, 2002-08-14 at 05:18, Richard Huxton wrote: > On Tuesday 13 Aug 2002 9:39 pm, Wei Weng wrote: > > I have a testing program that uses 30 concurrent connections > > (max_connections = 32 in my postgresql.conf) and each does 100 > > insertions to a simple table with index. > > > > It took me a

Re: [SQL] Need Help for select

2002-08-14 Thread Andre Schubert
On Wed, 14 Aug 2002 21:57:02 +0900 "Masaru Sugawara" <[EMAIL PROTECTED]> wrote: > On Wed, 14 Aug 2002 09:10:53 +0200 > Andre Schubert <[EMAIL PROTECTED]> wrote: > > > The ride side as follows. > > Table d contains information about subitems. > > Table c holds information about subitems and items

Re: [SQL] Few Queries

2002-08-14 Thread Richard Huxton
On Wednesday 14 Aug 2002 1:29 pm, Sugandha Shah wrote: > Hi , > > No luck . Even with Select Into . Please if any body has faced similar > problem and knows a solution. You don't need select into here - the sample below deletes everything older than one day. You should be able to adapt it to yo

Re: [SQL] parser: parse error at or near "$1"

2002-08-14 Thread Masaru Sugawara
On Wed, 14 Aug 2002 17:56:16 +0530 "Sugandha Shah" <[EMAIL PROTECTED]> wrote: > -- check for the exact same status string reported > -- previously and skip it if found > > select into last_status top 1 status, last_code status_code from >status_log where sched

Re: [SQL] Few Queries

2002-08-14 Thread Oliver Elphick
On Wed, 2002-08-14 at 13:29, Sugandha Shah wrote: > Hi , > > No luck . Even with Select Into . Please if any body has faced similar problem and >knows a solution. > > CREATE FUNCTION del_old_history() RETURNS int4 AS ' ^ > declare >var_hist

Re: [SQL] parser: parse error at or near "$1"

2002-08-14 Thread Oliver Elphick
On Wed, 2002-08-14 at 13:26, Sugandha Shah wrote: > Hi , > I'm getting this error : > > Error occurred while executing PL/pgSQL function ins_schedule_status > line 42 at SQL statement > parser: parse error at or near "$1" > > Unable to locate the cause. Please any hint or clue will be of great

Re: [SQL] Need Help for select

2002-08-14 Thread Masaru Sugawara
On Wed, 14 Aug 2002 09:10:53 +0200 Andre Schubert <[EMAIL PROTECTED]> wrote: > The ride side as follows. > Table d contains information about subitems. > Table c holds information about subitems and items of type bar. > Each subitem can have 0..n items bar selected. > > What i want is that a sub

Re: [SQL] Few Queries

2002-08-14 Thread Sugandha Shah
Hi ,   No luck  . Even with Select Into . Please if any body has faced similar problem and knows a solution.   CREATE FUNCTION del_old_history() RETURNS int4 AS 'declare   var_history_age_limit int4;   set_time    datetime;   BEGIN select into var_history_age_limit history_age_limit from dat

[SQL] parser: parse error at or near "$1"

2002-08-14 Thread Sugandha Shah
Hi , I'm getting this  error :   Error occurred while executing PL/pgSQL function ins_schedule_status line 42 at SQL statementparser: parse error at or near "$1"   Unable to locate the cause. Please any hint or clue will be of great help.   Below is the function     CREATE FUNCTION ins_sched

Re: [SQL] Explicite typecasting of functions

2002-08-14 Thread Richard Huxton
On Wednesday 14 Aug 2002 10:30 am, Andreas Tille wrote: > Hello, > > I want to insert new data into a table with increasing data set ids. > The table has two separate "regions" of data: Those with Ids below > 100 and other. If I want to create a new Id in the "lower region" > I tried the foll

Re: [SQL] concurrent connections is worse than serialization?

2002-08-14 Thread Richard Huxton
On Tuesday 13 Aug 2002 9:39 pm, Wei Weng wrote: > I have a testing program that uses 30 concurrent connections > (max_connections = 32 in my postgresql.conf) and each does 100 > insertions to a simple table with index. > > It took me approximately 2 minutes to finish all of them. > > But under the

[SQL] Explicite typecasting of functions

2002-08-14 Thread Andreas Tille
Hello, I want to insert new data into a table with increasing data set ids. The table has two separate "regions" of data: Those with Ids below 100 and other. If I want to create a new Id in the "lower region" I tried the following (simplified example): CREATE TABLE Items ( Idint DEFA

Re: [SQL] pgsql-sql@postgresql.org

2002-08-14 Thread philip johnson
because I'm a new to stored procedure I gave only one store procedure, and I've 10 more to convert an example would help me -Message d'origine- De : [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]De la part de Christopher Kings-Lynne Envoyé : mercredi 14 août 2002 10:43 À : philip johnson; [

Re: [SQL] pgsql-sql@postgresql.org

2002-08-14 Thread Christopher Kings-Lynne
Why not spend 5 minutes reading the documentation and trying to do it yourself before asking us to do your job for you? http://www.us.postgresql.org/users-lounge/docs/7.2/postgres/plpgsql.html Chris > -Original Message- > From: [EMAIL PROTECTED] > [mailto:[EMAIL PROTECTED]]On Behalf Of

[SQL] pgsql-sql@postgresql.org

2002-08-14 Thread philip johnson
I've a stored procedure I'd like to migrate from MS SqlServer to Postgresql 7.2.1. How can I do ? here is the stored procedure CREATE PROCEDURE ws_doc_tree_new @parent_node_id int, @label varchar(50), @publication varchar(32) AS DECLARE @doc_exists int, @new_node_id int, @pare