[SQL] Escaping the $1 parameter in stored procedures

2003-10-14 Thread robert
I'm running Postgres 7.3.2 in Redhat 9.0. I'm trying to execute a function below defined as a stored procedure ALTER TABLE tms_schedule DROP CONSTRAINT "$1"; However, postgres thinks the "$1" is a parameter value. How do I tell postgres to treat it

Re: [SQL] Escaping the $1 parameter in stored procedures

2003-10-15 Thread robert
ALTER TABLE $tName ADD FOREIGN KEY(key2) REFERENCES table2; END IF; RETURN ''OK''; END;' LANGUAGE plpgsql;" [EMAIL PROTECTED] (robert) wrote in message news:<[EMAIL PROTECTE

[SQL] Re: BLOB HOWTO??

2001-02-05 Thread robert gravsjo
Maybe the functions lo_import and lo_export is what you're looking for? regards, robert gravsjo Olivier PRENANT wrote: > Hi, > > Beeing very impressed by TOAST, I wonder how I can insert BLOB from a flat > file. > > It seems quite easy with php; But how can I do it from psql?? > > TIA >

[SQL] Newbie ex-Oracle person's question: Oracle ROWID = PSQL OID, Oracle ROWNUM = PSQL ???

2001-05-11 Thread Robert Beer
Oracle has a ROWNUM pseudo column that works like this ... TEST>select callid, rownum from cs_calls where rownum < 5; CALLID ROWNUM -- -- 7806 1 7807 2 7809 3 6443 4 4 rows selected. ... which can be quite handy

Re: [SQL] how do i import my sql query result to a file

2002-07-18 Thread Robert Treat
not sure I understand the question, but from inside psql you can do: \o FILENAMEsend all query results to file or |pipe Robert Treat On Thu, 2002-07-18 at 17:47, Joseph Syjuco wrote: > how do i import results of my select query to a file >

Re: [SQL] [GENERAL] No command history in psql

2002-07-23 Thread Robert Treat
they are supposed to be. Robert Treat On Tue, 2002-07-23 at 10:53, Carmen Wai wrote: > Hello: > > I am upgrading to postgresql version 7.2.1. I found that the psql has not > included the readline library automatically and doesn't have any readline > and history command func

Re: [SQL] how do I change regional setting for dates?

2002-07-25 Thread Robert Treat
re, but if you check out http://www.postgresql.org/idocs/index.php?sql-set.html and http://www.postgresql.org/idocs/index.php?timezones.html it will explain how to update your internal timezone as needed. Robert Treat On Wed, 2002-07-24 at 15:38, Ligia Pimentel wrote: > I live in Guatemala, and our timezone i

Re: [SQL] Is this valid?

2002-08-12 Thread Robert Treat
I'm going to ask the crazy question of what language/interface are you using to interact with postgres? Based on my interpretation of your question I'd say that won't break (though one of your queries might fail) but then again I may be totally misreading what you wrote... Rober

Re: [SQL] Event recurrence - in database or in application code ????

2002-08-21 Thread Robert Treat
recurrence). My question to those of > > you that are > > more experienced in postgresql is whether you would implement this > > functionality in the > > database level using triggers or at the application code level (PHP). > > > > > > Any suggestions, etc

Re: [SQL] Preventing DELETEs

2002-09-26 Thread Robert Treat
In psuedo-code : create rule on mytable on delete return null Robert Treat On Thu, 2002-09-26 at 15:00, Rajesh Kumar Mallah. wrote: > Hi , > > I have a created a database and a table in it, > > I want to prevent "DELETES" on the table in this > database by everyo

[SQL] celko nested set functions

2002-10-02 Thread Robert Treat
s, but not moving. I'm hoping to find something postgresql specific but if not that's ok. Thanks in advance, Robert Treat ---(end of broadcast)--- TIP 1: subscribe and unsubscribe commands go to [EMAIL PROTECTED]

Re: [SQL] psql history

2002-10-31 Thread Robert Treat
ives (probably the general list would be more fruitful) as this comes up quite often. Robert Treat ---(end of broadcast)--- TIP 4: Don't 'kill -9' the postmaster

Re: [SQL] HA PostgreSQL

2002-11-01 Thread Robert Treat
in advance, > If you haven't looked at dbbalancer yet, you might want to. Someone mentioned it just a few days ago in a very similar thread on the general list (iirc) Robert Treat ---(end of broadcast)--- TIP 1: subscribe and unsubscribe commands go to [EMAIL PROTECTED]

Re: [GENERAL] [SQL] Database Design tool

2002-11-05 Thread Robert Treat
There are actually two sections on the techdocs site now relating to this at http://techdocs.postgresql.org/oresources.php look under the sections ERD Tools and Database Design Not that I'm not looking forward to your article Josh ;-) Robert Treat On Tue, 2002-11-05 at 11:33, Josh Berkus

Re: [GENERAL] [SQL] Database Design tool

2002-11-05 Thread Robert Treat
. Instead I decided to use Case Studio 2.x, which is a pretty good replacement imo. (For the record though, it is neither free nor does it run on linux). Robert Treat On Tue, 2002-11-05 at 15:16, Kaare Rasmussen wrote: > > Thanks. This gives me a few more tools to look at. Boy, do we h

Re: [SQL] changing numeric into int

2002-11-08 Thread Robert Treat
add a rule to always set the old columns to NULL. Robert Treat On Fri, 2002-11-08 at 02:41, Huub wrote: > Hi, > > I want to change 2 columns in the same table from numeric into int. Can > I do this without deleting the old table and creating a new one? Data > stays the sam

Re: [SQL] Permission on insert rules

2002-11-11 Thread Robert Treat
o do updateable rules and give only permissions to the view for the caller. (Though maybe you have to use triggers rather than rules to do this?) Does that sound right? Robert Treat ---(end of broadcast)--- TIP 5: Have you checked our extensive FAQ? http://www.postgresql.org/users-lounge/docs/faq.html

Re: [SQL] Permission on insert rules

2002-11-12 Thread Robert Treat
om parent; select * from child; insert into child (4,'four'); select * from parent; create user mellymel; grant select on child to mellymel; grant insert on child to mellymel; ** reconnect as mellymel ** select * from parent; (generates error) select * from child; insert into child

Re: [SQL] RE: [SQL] System´s database table

2002-11-14 Thread Robert Treat
There's no sense waiting as 7.3 is about to go RC1, and only the most improbable circumstances would lead to a system catalog change at this point. (If you do make a diagram, please post it to the group ) Robert Treat On Wed, 2002-11-13 at 16:28, Jean-Luc Lachance wrote: > Thanks, I kn

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

2002-11-26 Thread Robert Treat
o=t_newparent INTO newparentrgt, newparentuid, newparenttid; I think it's more readable and probably a little more efficient since you are doing less variable assignment. Robert Treat On Tue, 2002-11-26 at 00:13, Martin Crundall wrote: > I'm not sure that keying off lft is safe

Re: [SQL] Ran out of connections

2002-12-04 Thread Robert Treat
Once your done scoping other things out, you might also want to look at increasing the number of allowed connections (in postgresql.conf). The defaults can be low for high traffic systems. Robert Treat On Wed, 2002-12-04 at 17:29, Steve Crawford wrote: > You probably didn't need to re

[SQL] working around setQuerySnapshot limitations in functions

2002-12-16 Thread Robert Treat
Does anyone see another work-around? Robert Treat ---(end of broadcast)--- TIP 2: you can get off all lists at once with the unregister command (send "unregister YourEmailAddressHere" to [EMAIL PROTECTED])

Re: [SQL] unsubscribe

2002-12-19 Thread Robert Treat
If you just want to take a break, your better off sending "set ALL nomail-14d" to majordomo. Robert Treat On Thu, 2002-12-19 at 07:39, Christoph Haller wrote: > > David and all others on the list, > who want to turn off mailing over xmas and new year, > please se

Re: [SQL] Sorry, to many clients already

2003-01-06 Thread Robert Treat
ons that are allowed. This might be an indication of other problems, but if you simply want to raise the limit you'll need to modify max_connections in the postgresql.conf Robert Treat ---(end of broadcast)--- TIP 2: you can get off all lists a

Re: [SQL] Postgresql Bug List?

2003-01-09 Thread Robert Treat
One could subscribe to pgsql-bugs if you wanted to look into any new bugs that come down the pipe. Robert Treat On Wed, 2003-01-08 at 23:30, Bruce Momjian wrote: > > No bugzilla, but do have a TODO list. See the develope

Re: [SQL] SQL function parse error ?

2003-01-09 Thread Robert Treat
ample put forth. The problem is that foo>$1 doesn't work, which by comparison would be SELECT* which would also not work. Robert Treat ---(end of broadcast)--- TIP 5: Have you checked our extensive FAQ? http://www.postgresql.org/users-lounge/docs/faq.html

Re: [SQL] SQL function parse error ?

2003-01-10 Thread Robert Treat
On Fri, 2003-01-10 at 04:13, Radu-Adrian Popescu wrote: > > Robert, my dear fellow... > > How about checking your facts before contradicting anyone ? Shame on you ! > Have you actually tried to do a SELECT* from foo ? Pathetic ! At least you started out all nice and flowery... &

Re: [SQL] postmaster -i & establishes three connections why?

2003-02-14 Thread Robert Treat
22922504 1960 con 500 17:43:36 /usr/bin > Are you sure those are connections. On server start you should get three process going, the main postmaster, the stats collector, and the stats buffer Robert Treat ---(end of broadcast)--- TIP 4: Don't 'kill -9' the postmaster

Re: [SQL] How to increase Column width of table

2003-03-25 Thread Robert Treat
http://fts.postgresql.org/db/mw/msg.html?mid=1071582 On Tue, 2003-03-25 at 10:18, Christoph Haller wrote: > > > > Atul here, i have one table and i would like to increase the length > of > > existing column and the sql statement is > > > >Exisiting Column is "vehicle_make" varchar(30)

Re: [SQL] [ADMIN] Perl Book

2003-05-29 Thread Robert Treat
is, but oreilly has a number of bio-informatics books, several of which deal specifically with perl. Robert Treat ---(end of broadcast)--- TIP 1: subscribe and unsubscribe commands go to [EMAIL PROTECTED]

[SQL] control structures in plpgsql

2003-06-12 Thread Robert Treat
Does anyone know if there is support for "IF x OR y THEN" syntax in plpgsql? The docs just say IF [boolean expression] then. which loosely interpreted could allow for an OR, but I couldn't seem to get it to work. TIA, Robert Treat -- Build A Brighter Lamp :: Linux Apache {middlew

Re: [SQL] control structures in plpgsql

2003-06-12 Thread Robert Treat
On Thu, 2003-06-12 at 10:24, Stephan Szabo wrote: > > On 12 Jun 2003, Robert Treat wrote: > > > Does anyone know if there is support for "IF x OR y THEN" syntax in > > plpgsql? The docs just say IF [boolean expression] then. which loosely > > interpreted

[SQL] help with "delete joins"

2003-06-30 Thread Robert Treat
+---+---+--- 1 | 2 | 4 | A 4 | 5 | 6 | b (2 rows) but thats not valid sql, is there some way to accomplish this? Robert Treat ---(end of broadcast)--- TIP 5: Have you checked our extensive FAQ? http://www.postgresql.org/docs/faqs/FAQ.html

Re: [SQL] help with "delete joins"

2003-06-30 Thread Robert Treat
On Mon, 2003-06-30 at 18:26, Robert Treat wrote: > create table foo (a int, b int, c int, d text); > > create table bar (a int, b int, c int); > > insert into foo values (1,2,3,'a'); > insert into foo values (1,2,4,'A'); > insert into foo values (4,5,6

Re: [SQL] help with "delete joins"

2003-07-01 Thread Robert Treat
On Mon, 2003-06-30 at 20:35, Josh Berkus wrote: > Robert, > > > delete * from foo where not (foo.a = bar.a and foo.b=bar.b and > > foo.c=bar.c) ; > > > > so i end up with > > > > postgres=# select * from foo; > > a | b | c | d > > ---+--

Re: [SQL] Immutable attributes?

2003-07-01 Thread Robert Treat
27;s "better", but this is one of the things people find the RULE system really handy for. Check the docs, I believe there are examples of this. Robert Treat -- Build A Brighter Lamp :: Linux Apache {middleware} PostgreSQL ---(end of broadcast)--- TIP 4: Don't 'kill -9' the postmaster

[SQL] obtuse plpgsql function needs

2003-07-22 Thread Robert Treat
; || f3) as x from t1; or select f,concat() as info from t2; returns equivalent select f,('f4:' || f4 || ' - f5:' || f5 || ' - f6:' || f6) as x from t2; I'm starting to believe this is not possible, has anyone already done it? :-) Robert T

Re: [SQL] obtuse plpgsql function needs

2003-07-23 Thread Robert Treat
at I need the function to be generic so that I don't have to pass the values down to the function, it just grabs the values automagically based on the table it's being called against. Robert Treat > elein > > On Tue, Jul 22, 2003 at 06:31:52PM -0400, Robert Treat wrote:

Re: [SQL] obtuse plpgsql function needs

2003-07-23 Thread Robert Treat
On Wed, 2003-07-23 at 09:06, Robert Treat wrote: > On Tue, 2003-07-22 at 19:33, elein wrote: > > You'll need to pass the values down to your > > concat function (which I suggest you don't call concat) > > and have it return a text type. > > > > What

Re: [SQL] time delay function

2003-07-23 Thread Robert Treat
(1 row) wait -- t (1 row) now --- 2003-07-23 15:45:51.758621-04 (1 row) 21343=# 21343=# select now(); select wait(10); select now(); now --- 2003-07-23 15:45:58.713646-04 (1 row) wait -- t (1 row)

Re: [SQL] obtuse plpgsql function needs

2003-07-23 Thread Robert Treat
talog lookups, but is pltcl inherently faster anyways? thanks for the input so far. Robert Treat On Wed, 2003-07-23 at 15:38, [EMAIL PROTECTED] wrote: > SELECT a,b,c,msgmaker('t1',ctid) FROM t1 WHERE a=b; > > > CREATE OR REPLACE FUNCTION msgmaker(text,tid) RET

TODO item for plpgsql Was Re: [SQL] obtuse plpgsql function needs

2003-07-23 Thread Robert Treat
On Wed, 2003-07-23 at 15:38, [EMAIL PROTECTED] wrote: > FOR myrec IN EXECUTE myinfo LOOP > biglist := myrec.info; > END LOOP; > One other thing, I hate when I have to do things like the above, can we get a TODO like: allow 'EXECUTE var INTO record' in plpgsql Ro

Re: TODO item for plpgsql Was Re: [SQL] obtuse plpgsql function needs

2003-07-23 Thread Robert Treat
On Wednesday 23 July 2003 19:06, Bruce Momjian wrote: > Robert Treat wrote: > > On Wed, 2003-07-23 at 15:38, [EMAIL PROTECTED] wrote: > > > FOR myrec IN EXECUTE myinfo LOOP > > > biglist := myrec.info; > > > END LOOP; > > > > One other thing

Re: TODO item for plpgsql Was Re: [SQL] obtuse plpgsql function needs

2003-08-01 Thread Robert Treat
I don't seem to have any plsql specfic documentation, and the rest of my oracle documentation isn't specfific enough. Anyone else? Robert Treat On Thursday 31 July 2003 00:12, Bruce Momjian wrote: > Does Oracle have a sy

Re: [SQL] [GENERAL] Postgresql slow on XEON 2.4ghz/1gb ram

2003-08-08 Thread Robert Treat
If you went from a dual processor box running windows to a single processor box running windows, I wouldn't be surprised to see a slow down. I'd recommend switching from Windows to Linux/BSD over a hardware upgrade any day. Robert Treat On Wed, 2003-08-06 at 18:04, Maksim Likharev wro

Re: [SQL] createlang plpgsql failing on redhatlinux7.2

2003-09-12 Thread Robert Treat
rather do an rpm -qa | grep post to see if postgresql-pl-7.3.4-2PGDG is installed, it is the rpm for procedural languages in 7.3.* and didn't exist in the 7.2.* rpmset. Robert Treat On Fri, 2003-09-12 at 10:12, Richard Huxton wrote: > Please don't post html-only messages to the l

Re: [SQL] createlang plpgsql failing on redhatlinux7.2

2003-09-13 Thread Robert Treat
On Friday 12 September 2003 12:18, Richard Huxton wrote: > On Friday 12 September 2003 16:49, Robert Treat wrote: > > rather do an rpm -qa | grep post to see if postgresql-pl-7.3.4-2PGDG is > > installed, it is the rpm for procedural languages in 7.3.* and didn't > >

Re: [SQL] off subject - pg web hosting

2003-11-08 Thread Robert Creager
http://www.iniquinet.com When grilled further on (Thu, 6 Nov 2003 16:39:14 -0800 (PST)), chester c young <[EMAIL PROTECTED]> confessed: > can anybody recomend web hosting that provides postgresql? I have > found a couple, but their pricing is several times the going rate using mySql. > -- 1

Re: [SQL] Help converting Oracle instead of triggers to PostgreSQL

2003-12-06 Thread Robert Treat
Generally speaking you can send articles to me or to [EMAIL PROTECTED] for inclusion on the techdocs site. I'll try to update the links you mentioned below as well. thanks. Robert Treat On Thursday 04 December 2003 12:52, Clint Stotesbery wrote: > Hi Christoph, > Thanks for the li

Re: [SQL] Help converting Oracle instead of triggers to PostgreSQL

2003-12-13 Thread Robert Treat
Just to follow up I managed to track down these missing articles and have updated the links on the website. Robert Treat On Thursday 04 December 2003 12:52, Clint Stotesbery wrote: > Hi Christoph, > Thanks for the links but the techdoc links for converting from Oracle to > Postgre

Re: [SQL] grouping by date

2004-01-08 Thread Robert Creager
When grilled further on (Mon, 05 Jan 2004 17:14:26 +), teknokrat <[EMAIL PROTECTED]> confessed: > How can I group by date given a timestamp column? > I just found this out this weekend. Try 'date_trunc'. Look at secion 9.8.2 of the documentation. I'm using something like: SELECT date_tru

[SQL] Problem with NOT IN portion of query.

2004-01-11 Thread Robert Creager
Hey All, Probably doing something stupid, and I'm too tired to see what. The query I'm trying to execute is: SELECT date_trunc( 'hour', "when" )::timestamp AS period FROM readings WHERE period NOT IN (SELECT "time" FROM hour.summary_period) GROUP BY period ORDER BY period; Where the table defi

Re: [SQL] Problem with NOT IN portion of query.

2004-01-12 Thread Robert Creager
When grilled further on (Mon, 12 Jan 2004 07:28:09 +0100), Tomasz Myrta <[EMAIL PROTECTED]> confessed: > Dnia 2004-01-12 05:04, U¿ytkownik Robert Creager napisa³: > > > > SELECT date_trunc( 'hour', "when" )::timestamp AS > > period FROM r

[SQL] How can I get the last element out of GROUP BY sets?

2004-01-18 Thread Robert Creager
I'm trying to produce summary data from a table (using PGSQL 7.4.1): CREATE TABLE readings( "when" timestamp, value integer ); The summary will be based on various time periods. I've been using date_trunc( 'hour', "when" ) and GROUP BY for the min/max/average readings with no problems. But, one

Re: [SQL] How can I get the last element out of GROUP BY sets?

2004-01-19 Thread Robert Creager
When grilled further on (Mon, 19 Jan 2004 00:44:30 -0500), Tom Lane <[EMAIL PROTECTED]> confessed: > Robert Creager <[EMAIL PROTECTED]> writes: > > ... one piece of data I need is the last value for each GROUP BY > > period. Alas, I cannot figure out how to do th

Re: [SQL] Implementation of a bag pattern using rules

2004-02-09 Thread Robert Creager
When grilled further on (Mon, 09 Feb 2004 13:49:17 +), Mark Gibson <[EMAIL PROTECTED]> confessed: > I probably didn't make this clear enough: > Nah. After re-reading your e-mail, I say what I missed the first time. 'Bout 1 hour before my normal thinking time... Cheers, Rob -- 20:20:54

Re: [SQL] max timestamp

2004-02-15 Thread Robert Creager
When grilled further on (10 Feb 2004 10:14:04 -0800), [EMAIL PROTECTED] (Michael Sterling) confessed: > i'm trying to get the max time stamp, from each day, of a range of > dates, not just the max time stamp for the complete range dates but > for each day. > Well, one gross and ugly way is: SE

Re: [SQL] umlimited arguments on function

2004-02-15 Thread Robert Treat
d method in 7.3 where its much more challenging.) HTH, Robert Treat -- Build A Brighter Lamp :: Linux Apache {middleware} PostgreSQL ---(end of broadcast)--- TIP 9: the planner will ignore your desire to choose an index scan if your joining

Re: [SQL] Getting the week of a date

2004-02-16 Thread Robert Creager
When grilled further on (Mon, 16 Feb 2004 17:40:08 +0530), "Kumar" <[EMAIL PROTECTED]> confessed: > Dear Friends, > > Postgres 7.3.4 on RH Linux7.2. > > While this works for month and why not for week > date_trunc (obviously) doesn't support week. I ran into this a while ago, and came up with

Re: [HACKERS] [SQL] Materialized View Summary

2004-02-24 Thread Robert Treat
to > from techdocs. Done. :-) > > If you could identify candidate keys on a view, you could conceivably automate > the process even more. That's got to be possible in some cases, but I'm not > sure how difficult it is to do in all cases. > it seems somewhere be

Re: [PERFORM] [HACKERS] [SQL] Materialized View Summary

2004-02-25 Thread Robert Treat
On Wed, 2004-02-25 at 03:19, Jonathan M. Gardner wrote: > -BEGIN PGP SIGNED MESSAGE- > Hash: SHA1 > > I'm not sure if my original reply made it through. Ignore the last one if > it did. But I liked the last one :-) > > On Tuesday 24 February 2004 1:48 pm,

Re: [SQL] designer tool connect to PostgreSQL

2004-03-10 Thread Robert Treat
take a look at http://techdocs.postgresql.org/guides/GUITools Robert Treat On Tue, 2004-03-09 at 02:53, BenLaKnet wrote: > > Rekall ... > http://www.totalrekall.co.uk/ <http://www.totalrekall.co.uk/> > (commercial website) > http://www.reka

Re: [SQL] inverse of "day of year"

2004-03-19 Thread Robert Creager
When grilled further on (Fri, 19 Mar 2004 09:06:17 -0300), Martin Marques <[EMAIL PROTECTED]> confessed: > Is there a function that would give me the date for a given day of year? > > Something like the inverse of "EXTRACT(doy FROM date)"? > Something like: select date_trunc( 'year', now() ) +

[SQL] partial unique constraint

2004-04-06 Thread Robert Treat
n external trigger, but am wondering about a constraint oriented approach Robert Treat -- Build A Brighter Lamp :: Linux Apache {middleware} PostgreSQL ---(end of broadcast)--- TIP 7: don't forget to increase your free space map settings

Re: [SQL] partial unique constraint

2004-04-06 Thread Robert Treat
On Tue, 2004-04-06 at 11:17, Tom Lane wrote: > Robert Treat <[EMAIL PROTECTED]> writes: > > Trying to come up with the proper syntax to meet the following criteria: > > create table foo (bar integer, baz boolean UNIQUE (bar, baz = true)); > > The correct way to do i

[SQL] explain analyze results are different for each iteration

2004-09-14 Thread Robert Davis
I'm trying to benchmark some complex sql queries. One query, in particular, is causing problems -- its cost values can vary from 228 to 907, its Total Runtimes from 60 ms to 5176 ms. The query plans show that the optimizer is choosing different plans for different iterations of the same query

Re: [SQL] Query from different Database

2004-10-07 Thread Robert Creager
When grilled further on (Thu, 7 Oct 2004 16:52:38 +0800 (MYT)), Abdul Wahab Dahalan <[EMAIL PROTECTED]> confessed: > I'm looking for a solution to make a query from two different databases. If > anybody has an experience or know how to solve it, please help me. Thanks. > I believe that the co

Re: [SQL] diff databases

2004-12-28 Thread Robert Treat
ee thier website for details. -- Robert Treat Build A Brighter Lamp :: Linux Apache {middleware} PostgreSQL ---(end of broadcast)--- TIP 6: Have you searched our list archives? http://archives.postgresql.org

[SQL] Single row tables

2005-01-11 Thread KÖPFERL Robert
Hi, with what constraint or how can I ensure that one of my tables has exact one record or 0..1 records? ---(end of broadcast)--- TIP 7: don't forget to increase your free space map settings

[SQL] Implementing queue semantics (novice)

2005-01-12 Thread KÖPFERL Robert
Hi, since I am new to writing stored procedures I'd like to ask first bevore I do a mistake. I want to implement some kind of queue (fifo). There are n users/processes that add new records to a table and there are m consumers that take out these records and process them. It's however possible for

[SQL] Syntax error while altering col-type

2005-01-12 Thread KÖPFERL Robert
Hi, I am perplexed. I tried to change the type of a column using the syntax I found in the [ALTER TABLE] section: ALTER TABLE "Mailboxes" ALTER COLUMN "Status" TYPE int4; This shuld be no problem since the current type acutally is int4 and the names are copy'n'pasted. The server responds as follo

Re: [SQL] Syntax error while altering col-type

2005-01-13 Thread KÖPFERL Robert
> -Original Message- > > That's exactly the error you'd get on a pre-8.0 system that doesn't > support altering a column's type. Are you looking at 8.0 > documentation > but running a 7.x server? What does "SELECT version();" show? Yes, that's it. I am looking into an 8.0 doc while

Re: [SQL] Syntax error while altering col-type

2005-01-13 Thread KÖPFERL Robert
> > It really is. In fact, the feature was (IIRC) somewhat > controversial, because there are all sorts of decisions that need to > be made about what to do with incompatible types. What if you change > from int8 to int4? What about varchar(4) to char(4)? Just to name > two simple-minded exa

[SQL] Column with recycled sequence value

2005-01-13 Thread KÖPFERL Robert
Hi, suppose I have a let's say heavy used table. There's a column containing UNIQUE in4 values. The data type musn't exceed 32-Bit. Since however the table is heavy used 2^32 will be reached soon and then? There are far less than 4G-records saved thus these values may be reused. How can this be ac

[SQL] Inserting or Deleting conditionally

2005-01-17 Thread KÖPFERL Robert
Hi, coming from imperative programming paradigma, I'm currently trying to express something like that in _SQL_: It should be atomic and like an API for a user. I'm therefore writing functions: CRETE FUNC... c := SELECT x,y,z FROM table_a WHERE... IF COUNT(c)=1 then INSERT / DELETE ... W

[SQL] Returning a bool on DELETE in a proc.

2005-01-18 Thread KÖPFERL Robert
Hi, I'm currently writing a function which encapsulates a delete and should return a bool as indicator for success. I tried: DELETE FROM "TariffDetails" WHERE "TariffId"=$1 and "BNumberPrefix"=$2; SELECT TRUE; but this makes me not happy. How can I distingruish wehter DELETE affected

[SQL] Looking for examples of S/P

2005-01-19 Thread KÖPFERL Robert
In order to learn SQL-Stored Procedure techniqes I'm looking for a series of examples. Where can I find examples of SQL and PL/pgSQL based stored procedures? Or any of you who wants to donate some? ---(end of broadcast)--- TIP 8: explain analyze is y

[SQL] automatic table locking on too many locked records?

2005-01-20 Thread KÖPFERL Robert
Hi all and Michael. An MS-SQL experienced developer warned me that on MS-SQLsvr a whole table gets locked if a certain percentage or amount of records are locked due to an update. And then shortly nothing goes. Does there exist a similar behaviour on pgSQL? Get tables locked if too many records ar

[SQL] returning a record from PL/pgSQL

2005-01-21 Thread KÖPFERL Robert
I just tried hard to return a single record fromout a plpgsql-function. While the (otherwise excelent) documentation didn't give me an answer, I found out that this works: select into ret false, balance, balance; return ret; while ret is a composite type. This construction howeve

[SQL] What's the equivalent in PL/pgSQL

2005-01-27 Thread KÖPFERL Robert
Hi, I'm trying to find an equivalent plpgsql function as this: func x returns SETOF "Tablename" AS ' Select * from "Tablename"; ' language sql How is this accomplished with plpgsql while not using a loop or a second and third temporal table? ---(end of broadcast)

[SQL] Accessing objects over db-borders

2005-02-04 Thread KÖPFERL Robert
Hi, Consider one postmaster that manages multiple databases (logical names) Is it possible (and how) to access a stored procedure or view/Table which resides in DB aaa if your DB-connection has currently the context on DB bbb? So: I login on db bbb as a user who has rights on both DBs (aaa,bbb).

Re: [SQL] How can I use large object on PostgreSQL Linux Version?

2005-02-07 Thread KÖPFERL Robert
Are you using Fedora with SELinux or just SELinux? -Original Message-From: Premsun Choltanwanich [mailto:[EMAIL PROTECTED]Sent: Montag, 07. Februar 2005 05:41To: pgsql-sql@postgresql.orgSubject: [SQL] How can I use large object on PostgreSQL Linux Version? For first inform

[SQL] parsing a string with a hexadecimal notation

2005-02-09 Thread KÖPFERL Robert
I intend to retrieve an int value in an integer variable from a string with a hexadecimal notation of a number. Which function is appropriate to do i int4 i = ???('BEAF') ---(end of broadcast)--- TIP 1: subscribe and unsubscribe commands go to [E

Re: [SQL] parsing a string with a hexadecimal notation

2005-02-10 Thread KÖPFERL Robert
> So it should work to do "SELECT int4($1::bit varying)" and then pass > 'xBEEF' as the string value for the parameter. > > regards, tom lane Thanks, that worked for me ---(end of broadcast)--- TIP 3: if posting/reading thro

[SQL] Constraint doesn't see a currently insertet record

2005-02-11 Thread KÖPFERL Robert
Hi, yes that's my problem. I've got a table and I put lots of contraints on it so that data stays consistent. One constraint calls a fcn to do some kind of count() over that table but it omits the 'to be inserted record'. What to do? concrete problem: Suppose a table i | tel | status | ... ..|

Re: [SQL] More efficient OR

2005-02-16 Thread KÖPFERL Robert
At least for between, I read that pgSQL rewrites it to a (a -Original Message- > From: Keith Worthington [mailto:[EMAIL PROTECTED] > Sent: Mittwoch, 16. Februar 2005 17:36 > To: PostgreSQL SQL > Cc: Sean Davis; Scott Marlowe > Subject: Re: [SQL] More efficient OR > > > > > Hi All, > > >

Re: [SQL] Relation in tables

2005-02-16 Thread KÖPFERL Robert
You may possibly solve the problem with the inheritted tables with the RULE-System of pgsql. But this seems oversized to me. You could rather create several tables, each with its matching rights/privileges and 'connect' them via an 1:1 relation. The 'real' way such thing is normally done is to wri

[SQL] dblink versus schemas. What to use in this case?

2005-02-23 Thread KÖPFERL Robert
Hi all, I have got two database schemas. They're rather independend. Thus they are in two databases. However there is one function that needs access to the other database. As I found out, I have two choices: *Using schemas and put the schemas tighter together (via interdependencies). Dumping dist

Re: [SQL] VIEW / ORDER BY + UNION

2005-02-23 Thread KÖPFERL Robert
Otherwise you can treat this as a subselect and suround it with another select. Like select * from () order by orderno; C:\> -Original Message- C:\> From: Bruno Wolff III [mailto:[EMAIL PROTECTED] C:\> Sent: Mittwoch, 23. Februar 2005 18:20 C:\> To: WeiShang C:\> Cc: pgsql-sql@postgresql

Re: [SQL] Junk queries with variables?

2005-02-24 Thread KÖPFERL Robert
In pgadmins SQL-window SQL is the 'language' of choice. Or it is rather the only language. Thus if you intend to program plTk or PL/pgSQL, there's no way around defining a function. (At first you have to define a new language in your schema) C:\> -Original Message- C:\> From: Steve - DND

[SQL] Maintaining production DBs, making one schema look like the other

2005-03-07 Thread KÖPFERL Robert
OK, the usual thing: There exists a DB-schema. It is on one hand already in production usage. On the other hand it is still being developed as functions and non-structural stuff are concerned. I found out that EMS Database Comparer helps to replicate the schema differences in form of SQL-statement

[SQL] Lambda expressions in SQL

2005-03-07 Thread KÖPFERL Robert
Coming from functional programming, I often wish to write something like that: (LAMDA "expesiveFcn"(x y z) as exfcn update "Tbl5" SET "Column" = exfcn ) In this case "expensiveFcn" is VOLATILE... Is there a way? At least: substituting the lambda by a select doesn't work with update as

[SQL] How does the planner treat a table function.

2005-03-14 Thread KÖPFERL Robert
Hi, we have got some tables (uw?) and functions. One function is defined like get_abc(): SELECT a,b,c from table_x; What happens if I query something like SELECT a,b from get_abc() where a=5; while table_x is rather big? Will PSQL at first query all records of table_x and then apply a where

[SQL] Inserting values in arrays

2005-03-14 Thread Robert . Farrugia
x is giving an error.  How can this be done in postgres ? Postgres version I am using is 7.3.4 Regards Robert

Re: [SQL] Inserting values in arrays

2005-03-15 Thread Robert . Farrugia
Richard, So the solution can be:         (i) either write a function to insert the values into the array one by one         (ii) or else upgrade to 7.4 (or 8) to use the ARRAY syntax. Thanks a lot. Regards Robert Richard Huxton 03/15/2005 09:08 AM To [EMAIL PROTECTED] cc pgsql

[SQL] save me from an unconstrained join

2005-03-30 Thread Robert Treat
ach software is assigned a "class" based on the size of its binary into a predetermined range of classes that are defined as relative filesizes. The above query really does work... but istm I ought to be joining those tables somehow... any ideas? Robert Treat -- Build A Brighter Lamp ::

Re: [SQL] Postgres 7.3 migrate to 8.0 date problems.

2005-03-30 Thread Robert Treat
mbers are both <=12, then you'll get one > "date" and if the wrong one is >12 you'll get another. That can't be > good. > Would it be possible to use a BEFORE trigger to reformat the -DD-MM date to -MM-DD ? The error I see on 7.4 is ERROR:

[SQL] btree and is null in a static expression

2005-04-18 Thread KÖPFERL Robert
Hi, I've written a function but I don't understand the the plan, the planner makes. If variables are replaced, the function looks like that: select a,b,c from "Tbl1" where (a='454') or ('454' is null); a has got an btree-Index. explain verbose tells me that Postgres wants to do a SEQSCAN If th

Re: [SQL] User Defined Functions Errors

2005-04-19 Thread KÖPFERL Robert
Have a try with RAISE NOTE or RAISE EXCEPTION keep in mind that exceptions should be exceptional. So a good idea of whether to use them is to ask 'Do I expect such error' or 'is an explicit error useful for the caller'. I'ts often better to just return an empty relation |-Original Message-

Re: [SQL] can a function return a virtual table?

2005-04-19 Thread KÖPFERL Robert
That was a nice answer - rather compleete. However at least I am questioning myself for a long time about what happens if one does a select from a SRF. The function may return millions of records (i.e. select * from x where a>1). Is this data streamed through the query process or does postgres cre

  1   2   3   >