Re: Concat and view - Re: [SQL] create view error

2003-07-07 Thread Richard Huxton
and lnaid from the > result? > > create view loco_dets as > select * from locos l > left outer join [snip] Don't do "select *" do "select field_a,field_b..." - the * doesn't just refer to the locos table. -- Richard Huxton --

Re: Concat and view - Re: [SQL] create view error

2003-07-07 Thread Richard Huxton
On Monday 07 Jul 2003 4:10 pm, Gary Stainburn wrote: > On Monday 07 Jul 2003 3:34 pm, Richard Huxton wrote: > > Don't do "select *" do "select field_a,field_b..." - the * doesn't just > > refer to the locos table. > > Sorry if I didn't make

Re: [SQL] Datatype conversion help

2003-07-09 Thread Richard Huxton
;t understand why the extra > space was added after the dash. It just made my life more miserable. > Yasir You are not the only one it makes miserable. I believe it's there to provide compatibility with Oracle/some other db. Their function does it so ours should too. Very strange b

Re: [SQL] Problem with temporary table -- Urgent

2003-07-12 Thread Richard Huxton
..." which gets parsed when the function is run. Note that this problem applies to any table that gets dropped and restored. I try to keep my function code in the same file as the table(s) they rely on, that way I recreate both when I make changes. -- Richard Huxton

[SQL] Database Upgrade scripts (AKA Conditional SQL execution)

2003-07-07 Thread Richard Rowell
type ='U' ) < 1 THEN CREATE TABLE foo() END Can I accomplish this with postgresql without involving an external process (like say perl)? I guess I could put the upgrade stuff into PL/SQL functions and just drop the functions when I'm done, but I was hoping for something

[SQL] NOT and AND problem

2003-07-17 Thread Richard Jones
Can anyone help me understand what is going on? Any suggestions gratefully received. Cheers Richard Richard Jones --- Systems Developer Theses Alive! - www.thesesalive.ac.uk Edinburgh University Library [EMAIL PROTECTED] 0131 651 1611

Re: [SQL] NOT and AND problem

2003-07-17 Thread Richard Jones
WHERE workspace_item_id = eulepersongroup2workspaceitem.workspace_item_id ) OR NOT EXISTS ( SELECT 1 FROM epersongroup WHERE eperson_group_id = eulepersongroup2workspaceitem.eperson_group_id ); Thanks very much for your help. Regards Richard Richard Jones --- Systems Deve

Re: [SQL] unique value - trigger?

2003-07-17 Thread Richard Poole
if you just add a new row with lncurrent set to true, it Does The Right Thing. In this particular example, the trigger will work perfectly well as a BEFORE, also. If you can't or don't want to install PL/PgSQL (or some other procedural language), you can do it with rules. It's more

Re: [SQL] Table Partitioning and Rules

2003-07-17 Thread Richard Huxton
Something like: CREATE RULE ... ON INSERT TO Contact WHERE NEW.LastName>='A' AND NEW.LastName<'H' DO INSTEAD ...insert into correct table here... You'll want to read the chapter on the rule system in the "Server Programming" section of the manual. -- Richard

Re: [SQL] Table Partitioning and Rules

2003-07-18 Thread Richard Huxton
r the hardware. Or remind your users that patience is a virtue ;-) -- Richard Huxton ---(end of broadcast)--- TIP 9: the planner will ignore your desire to choose an index scan if your joining column's datatypes do not match

Re: [SQL] (trigger function) -> ERROR: NEW used in non-rule query

2003-07-18 Thread Richard Huxton
V[3])); > or this > idval := NEW.(TG_ARGV[3]); I'll give you the short answer - no you can't do this (in plpgsql). Which isn't to say it'll never be possible, but not at the moment. Can you afford to look at an alternative language? I'd suggest looking at TCL, although

Re: [SQL] (trigger function) -> ERROR: NEW used in non-rule query

2003-07-18 Thread Richard Huxton
a working installation). Not sure if you can write triggers in perl, and I think python is going untrusted only (which means you need to be an admin to create functions). - Richard Huxton ---(end of broadcast)--- TIP 1: subscribe and unsubscribe commands go to [EMAIL PROTECTED]

Re: [SQL] How to determine the currently logged on username

2003-07-18 Thread Richard Huxton
l only > take a varchar() argument and needs to look up the username of the > currently logged in user. How do I do this? Any ideas? select CURRENT_USER; -- Richard Huxton Archonet Ltd ---(end of broadcast)--- TIP 7: don't forget to in

Re: [SQL] unique value - trigger?

2003-07-19 Thread Richard Poole
that if you just add a new row with lncurrent set to true, it Does The Right Thing. In this particular example, the trigger will work perfectly well as a BEFORE, also. If you can't or don't want to install PL/PgSQL (or some other procedural language), you can do it with rules. It's m

Re: [SQL] How to write this query!

2003-07-21 Thread Richard Huxton
e_b as b WHERE a.pid=b.pid1 OR a.pid=b.pid2 OR a.pid=b.pid3; -- Richard Huxton Archonet Ltd ---(end of broadcast)--- TIP 7: don't forget to increase your free space map settings

Re: [SQL] Why their is a limit in Postgresql (psql) Parameters..?

2003-07-21 Thread Richard Huxton
enough people saying "I need more parameters". -- Richard Huxton Archonet Ltd ---(end of broadcast)--- TIP 8: explain analyze is your friend

Re: [SQL] Equivalent to sql%rowcount or @@rowcount

2003-07-25 Thread Richard Huxton
t. You can do this sort of thing inside a plpgsql function - see ch 19.5.5 "Obtaining result status" in the programmers manual. GET DIAGNOSTICS my_var = ROW_COUNT; Oh - and _please_ don't post html-only messages to the list. -- Richard Huxton Archonet Ltd --

Re: [SQL] [OT] Frontend recommendations

2003-07-25 Thread Richard Huxton
mething like Omnis or Access??? I've always felt there's nowt wrong with Access as a way of building forms/reports etc. -- Richard Huxton Archonet Ltd ---(end of broadcast)--- TIP 2: you can get off all lists at once with the un

Re: [SQL] Very strange 'now' behaviour in nested triggers.

2003-07-26 Thread Richard Huxton
er function, what happens is the plan for that insert gets compiled the first time the function is called and 'now' gets frozen. Solution: make the default now() or CURRENT_TIMESTAMP and all will be as you expect. PS - I think this is mentioned in the manuals somewhere, but it&#

Re: [SQL] Very strange 'now' behaviour in nested triggers.

2003-07-27 Thread Richard Huxton
> On Sat, Jul 26, 2003 at 03:14:16PM +0100, Richard Huxton wrote: >> On Saturday 26 July 2003 14:39, Denis Zaitsev wrote: > >> Solution: make the default now() or CURRENT_TIMESTAMP and all will be as >> you >> expect. >> >> PS - I think this is mentio

Re: [SQL] Fwd: Bad Join moment - how is this happening?

2003-07-30 Thread Richard Huxton
n > d_addenda with a documents_id that matches the id field in documents. I think this is the "adding a table into the FROM" feature of PG. You're referring to documents.xxx in the select and d.id in the FROM. PG tries to help out by adding the table into the FROM fo

Re: [SQL] One to many query question

2003-07-30 Thread Richard Huxton
E "rock" and subtract that set from the set of all CDs. You could use: SELECT id,artist,title FROM cd WHERE NOT EXIST (SELECT 1 FROM cd_genres WHERE cd_id=id AND genre='Rock'); or SELECT id,artist,title,cd_id FROM cd LEFT JOIN (SELECT cd_id FROM cd_genres WHERE genre='

Re: [SQL] problem in database backup

2003-07-31 Thread Richard Huxton
ch one does it show (probably /usr/bin). Now do "pg_dump --version" and see what version it is. My guess is you want the one in /usr/local/... and the one in /usr/bin is from old RPMs -- Richard Huxton Archonet Ltd ---(end of broadcast)---

Re: [SQL] One to many query question

2003-07-31 Thread Richard Poole
re = 'Rock' ); will do what you want. Your co-worker is perhaps used to certain lesser databases which don't support subselects... Richard ---(end of broadcast)--- TIP 9: the planner will ignore your desire to choose an index scan if your joining column's datatypes do not match

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

2003-08-01 Thread Richard Poole
guely similar to what we do; they call it "EXECUTE IMMEDIATE" and the concept is described as "Dynamic SQL". http://download-west.oracle.com/docs/cd/A87860_01/doc/appdev.817/a77069/10_dynam.htm#4376 Richard ---(end of broadcast)---

Re: [SQL] [PERFORM] EXTERNAL storage and substring on long strings

2003-08-04 Thread Richard Huxton
d PGs backend to give you peak performance. You'll have to test. 2. If you want to search for a sequence you'll need to deal with the case where it starts in one chunk and ends in another. -- Richard Huxton Archonet Ltd ---(end of broadcast)--- TIP 2: you can get off all lists at once with the unregister command (send "unregister YourEmailAddressHere" to [EMAIL PROTECTED])

[SQL] Expression transformation curiosity

2003-08-17 Thread Richard Huxton
ssed that way? You could see how testing "a" twice could be expensive in some situations. Oh, btw - 7.3.2 on this box, I'll be looking at 7.3.3/4 later today. -- Richard Huxton Archonet Ltd ---(end of broadcast)--- TIP 7: don&

Re: [SQL] Expression transformation curiosity

2003-08-17 Thread Richard Huxton
On Sunday 17 August 2003 16:39, Alexander M. Pravking wrote: > On Sun, Aug 17, 2003 at 11:32:58AM +0100, Richard Huxton wrote: > > Boiling the problem down, I've looked at a clause of the form: > > a OR (b AND c) > > which PG converts to: > > (a OR b) AND (a

[SQL] link toward pgsql-sql is missing on the left menu athttp://archives.postgresql.org/

2003-08-20 Thread Richard NAGY
Hello, I have noticed that the link toward pgsql-sql is missing on the left menu at http://archives.postgresql.org/. Is that normal? -- *** Richard NAGY Nameshield 46, rue Jean BODIN F-49000 Angers Tél : +33 2 41 18 28 28

Re: [SQL] [Newbie] migrating a stored procedure from MSSQL to postgresql

2003-08-20 Thread Richard Hall
As declared, your function returns TEXT, i.e. unlimited characters. >>  CREATE FUNCTION UpdateOrder(INTEGER) RETURNS TEXT AS Since your variable >>  r_SKUPrice RECORD; contains a number of columns >>  SELECT SKU, Price INTO r_SKUPrice you could create a composite TYPE that matches those columns a

Re: [SQL] Bug on parameter bigint in PL/PGSQL

2003-08-22 Thread Richard Huxton
SELECT my_bigint_test(2::int8); my_bigint_test 3 (1 row) Can you provide an actual example? -- Richard Huxton Archonet Ltd ---(end of broadcast)--- TIP 6: Have you searched our list archives? http://archives.postgresql.org

[SQL] Eliminating duplicate lists

2003-08-26 Thread Richard Huxton
a somewhat ugly procedural hack, and 2 isn't going to be a simple query and is probably going to be slow. Anyone got any better ideas? -- Richard Huxton Archonet Ltd ---(end of broadcast)--- TIP 3: if posting/reading through Usenet, please

Re: [SQL] One-2-many relation - need distinct counts

2003-08-28 Thread Richard Huxton
ute of your problem. If you want the first try something like SELECT account_no, min(account_type) FROM B GROUP BY account_no -- Richard Huxton Archonet Ltd ---(end of broadcast)--- TIP 7: don't forget to increase your free space map settings

Re: [SQL] How to return a record set from function.

2003-08-28 Thread Richard Huxton
ORD You probably want to return "setof t1" and then do: SELECT * FROM sel_t1(); -- Richard Huxton Archonet Ltd ---(end of broadcast)--- TIP 8: explain analyze is your friend

Re: [SQL] Change column data type

2003-09-05 Thread Richard Huxton
on along with whatever supporting updates you need. -- Richard Huxton Archonet Ltd ---(end of broadcast)--- TIP 9: the planner will ignore your desire to choose an index scan if your joining column's datatypes do not match

Re: [SQL] Fw: Transactions ID

2003-09-05 Thread Richard Huxton
On Friday 05 September 2003 08:10, Yaroslav Ulyanov wrote: > Hello. > > You may prompt me, what get the identifier to transactions? Not entirely sure what you're after, but does chapter 2.2 of the manuals - "System Columns" help you? -- Richa

Re: [SQL] Porting from Oracl to Postgres

2003-09-05 Thread Richard Huxton
days'::interval; SELECT now() + '3 months':: interval; See the data-types section of the manual for details. -- Richard Huxton Archonet Ltd ---(end of broadcast)--- TIP 6: Have you searched our list archives? http://archives.postgresql.org

Re: [SQL] Unique constraints for a list

2003-08-29 Thread Richard Huxton
hey were duplicates. The query wasn't as bad as I first feared, but it definitely helped to build it up one step at a time. Testing showed that the second method was too slow for my particular need (bursty updates) but it might work for you. -- Richard Huxton Archonet Ltd

Re: [SQL] plpgsql doesn't coerce boolean expressions to boolean

2003-09-09 Thread Richard Hall
Define the language! If it breaks code, so be it. 2. Throw an error if the _expression_ doesn't return boolean. Yes, yes, absolutely. By definition "an IF, WHILE, or EXIT statement is a boolean _expression_" SO     if "some stupid piece of text" THEN should not compile, there is no BOOLEAN _expre

Re: [SQL] [GENERAL] plPGSQL bug in function creation

2003-09-08 Thread Richard Huxton
B (1 row) richardh=# select version(); version - PostgreSQL 7.3.2 on i686-pc-linux-gnu, compiled by GCC 2.96 Not sure whether this is because of the change 7.3.1->7.3.2 or cygwin vs linux. Don&

Re: [SQL] [GENERAL] MD5 function is not available ?

2003-09-11 Thread Richard Huxton
ackage of your binary distro. -- Richard Huxton Archonet Ltd ---(end of broadcast)--- TIP 4: Don't 'kill -9' the postmaster

Re: [SQL] How do I replace select ... into commands?

2003-09-12 Thread Richard Huxton
2000 > select "max"(seq_val) as m into lastrsn from fseqkeys where seq_key = tbl; Slight change of syntax needed: select into recordvar max(seq_val) from ... - Richard Huxton ---(end of broadcast)--- TIP 5: Have you checked our extensive FAQ? http://www.postgresql.org/docs/faqs/FAQ.html

Re: [SQL] how to call a function with row-type arg

2003-09-12 Thread Richard Hall
DECLARE     I INTEGER; BEGIN     SELECT *   INTO I   FROM foo( ) That part is easy, but I don't understand what you are using as a function parameter. Rick sad wrote: hi  how to call a function with a row_type arg ??  that is the question CREATE FUNCTION foo(tablename) returns

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

2003-09-12 Thread Richard Huxton
tried again to create a language. > this time i got an error like 'Load of file > /usr/lib/pgsql/plpgsql.so failed :/lib/i686/libc.so.6: version GLIB_2.3 not > found (required by /usr/lib/pgsql/plpgsql.so). RedHat changed their version of glibc between 7.2

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

2003-09-12 Thread Richard Huxton
27;m guessing plpgsql is considered "core"). $ rpm -qif /usr/lib/pgsql/plpgsql.so Name: postgresql-serverRelocations: (not relocateable) Version : 7.3.4 Vendor: (none) ... -- Richard Huxton Archonet Ltd --

Re: [SQL] Plz, what is the most "correct" method

2003-09-15 Thread Richard Huxton
day, after you posted Wednesday). All you need to do is join the two tables and order by the required field SELECT t1.id, t1.txt FROM table1 as t1, table2 as t2 WHERE t1.table2id=t2.id ORDER BY t2.order -- Richard Huxton Archonet Ltd ---(end of broadcast)-

Re: [SQL] Copy Command Error

2003-09-15 Thread Richard Huxton
On Monday 15 September 2003 09:57, Richard Sydney-Smith wrote: > I am outputting the following rows from a SYBASE database on W2000 > The problem is that each string is imported with the inverted commas. > > eg field ID = ''RK'' instead of 'RK' > &g

Re: [SQL] Sort order with spaces?

2003-09-17 Thread Richard Huxton
different. I'm guessing you expect "C" style sorting. Check the end of your postgresql.conf file to see what settings you currently have. See the manuals (Localization section) and list archives for plenty of details. -- Richard Huxton Archonet Ltd ---

[SQL] Trigger order problems

2003-09-17 Thread Richard Huxton
;t have any transactions to back up the summary. I'm going with #2 at the moment, but it seems wasteful to recalculate more than I need to. Anyone got any smart ideas? -- Richard Huxton Archonet Ltd ---(end of broadcast)--- TIP 1: subscri

Re: [SQL] Sort order with spaces?

2003-09-17 Thread Richard Huxton
On Wednesday 17 September 2003 13:39, Kristian Jörg wrote: > Kristian Jörg wrote: > > Richard Huxton wrote: > >>> > >>>LUNDGREN > >>>M L R > >>>MACDOWELL > >>>MUSCLE > >>> > >>>But in Postgres I get this

Re: [SQL] virus warning

2003-09-19 Thread Richard Huxton
t; viruses: > 1. Empty post with "Undelivered message to..." body > 2. Microsoft "Dear Customer... " based on www.microsoft.com design. > Both mails contains some .exe attachement. I've been getting something similar myself. Roughly 100 per day. -- Richard Huxton

Re: [SQL] auto_increment

2003-09-20 Thread Richard Huxton
e happen when three clients insert rows at the same time and one rolls back. Once you've decided what you want, ask again if you need some help. -- Richard Huxton Archonet Ltd ---(end of broadcast)--- TIP 4: Don't 'kill -9' the postmaster

Re: [SQL] auto_increment

2003-09-20 Thread Richard Huxton
l(), but you'll only need to do this once, to skip the numbers you have already used. Does that make it clearer? -- Richard Huxton Archonet Ltd ---(end of broadcast)--- TIP 5: Have you checked our extensive FAQ? http://www.postgresql.org/docs/faqs/FAQ.html

Re: [SQL] Backup error - Pls help

2003-09-22 Thread Richard Huxton
hich" to help you: "which pg_dump". Almost certainly what you want to do is: /usr/local/pgsql/bin/pg_dump -h ... You probably want to get a book on unix/linux and read up about the various search paths. -- Richard Huxton Archonet Ltd ---(end of broadc

Re: Fw: [SQL] Backup error - Pls help

2003-09-22 Thread Richard Huxton
ld version as pg_dump.alt - this should help to ensure you know which one you are running. HTH -- Richard Huxton Archonet Ltd ---(end of broadcast)--- TIP 7: don't forget to increase your free space map settings

Re: [SQL] GiST and full text search

2003-09-22 Thread Richard Huxton
> describe the details on how to implement full text search with GiST. Have you looked at tsearch / tsearch2 in the contrib/ directory? -- Richard Huxton Archonet Ltd ---(end of broadcast)--- TIP 6: Have you searched our list archives?

Re: [SQL] GiST and full text search

2003-09-22 Thread Richard Huxton
dxupdate before update or insert on titles for each row execute procedure tsearch(titleidx, title1, title2,... ); Perhaps see what 7.3.4's tsearch says - that should be compatible with 7.3.1 -- Richard Huxton Archonet Ltd ---(end of broadcast)--- TIP 8: explain analyze is your friend

Re: [SQL] using plpgsql outside of functions

2003-09-24 Thread Richard Huxton
ways create the function, call it, then drop the function. -- Richard Huxton Archonet Ltd ---(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] Especial delimiters caracter

2003-09-24 Thread Richard Huxton
rl -p -e 's//\\/g;' fakedump.txt C:\Windows\system32\drivers|this\ttabbed\ttext\n As you can see, this only handles \\ not \t=tab. You could also do this in sed: $ sed -e 's//\\/g' fakedump.txt HTH -- Richard Huxton Archonet Ltd ---(end of broadcast)--- TIP 8: explain analyze is your friend

Re: [SQL] Especial delimiters caracter

2003-09-24 Thread Richard Huxton
a file on one machine and then COPY FROM on another. -- Richard Huxton Archonet Ltd ---(end of broadcast)--- TIP 3: if posting/reading through Usenet, please send an appropriate subscribe-nomail command to [EMAIL PROTECTED] so that your m

Re: [SQL] Sequenties in pgSQL 7.3.x

2003-09-25 Thread Richard Huxton
val() function instead. SELECT setval('my_seq', 1234); -- Richard Huxton Archonet Ltd ---(end of broadcast)--- TIP 7: don't forget to increase your free space map settings

Re: [SQL] few questions ..?

2003-09-25 Thread Richard Huxton
h tuning even on a standard PC, but the standard config settings are *very* conservative. -- Richard Huxton Archonet Ltd ---(end of broadcast)--- TIP 1: subscribe and unsubscribe commands go to [EMAIL PROTECTED]

Re: [SQL] weird(to me) request

2003-09-25 Thread Richard Huxton
e (acct_num); It's really just a foreign-key to yourself -- Richard Huxton Archonet Ltd ---(end of broadcast)--- TIP 8: explain analyze is your friend

Re: [SQL] Temporary tables

2003-09-27 Thread Richard Huxton
O tempTable ''... This second passes the query string into the parser, so it works just fine for your example. I think some of this is covered in the manuals, you can certainly find plenty on it in the archives. -- Richard Huxton Archonet Ltd ---(end of b

Re: [SQL] SRF Functions don't want to return empty tuple

2003-09-29 Thread Richard Huxton
#x27;') > > CREATE FUNCTION public.liste_agents(int4) RETURNS public.agents AS 'SELECT > * FROM agents WHERE numero_age = $1' LANGUAGE 'sql' VOLATILE; You want "RETURNS SET OF public.agents" -- Richard Huxton Archonet Ltd ---

Re: [SQL] Link Oracle tables in Postgre

2003-10-01 Thread Richard Huxton
hey were working on such a thing. -- Richard Huxton Archonet Ltd ---(end of broadcast)--- TIP 9: the planner will ignore your desire to choose an index scan if your joining column's datatypes do not match

Re: [SQL] output

2003-10-02 Thread Richard Huxton
we can come up with something to help. -- Richard Huxton Archonet Ltd ---(end of broadcast)--- TIP 4: Don't 'kill -9' the postmaster

Re: [SQL] output

2003-10-02 Thread Richard Huxton
dingly and then you can check for a non-fatal error code in your result-code. Never done it myself mind. -- Richard Huxton Archonet Ltd ---(end of broadcast)--- TIP 7: don't forget to increase your free space map settings

Re: [SQL] Converting Query from MS SQL

2003-10-06 Thread Richard Huxton
> > How can I change it for postgres? Something like (in plpgsql): EXECUTE ''UPDATE "Schema1".employee SET ...'' || my_list_var || '')''; See the manuals for more details. -- Richard Huxton Archonet Ltd ---(

Re: [SQL] PG equivalent to Sybase varbinary

2003-10-08 Thread Richard Huxton
t;bytea" to me - or have you rejected that? -- Richard Huxton Archonet Ltd ---(end of broadcast)--- TIP 3: if posting/reading through Usenet, please send an appropriate subscribe-nomail command to [EMAIL PROTECTED] so that your mess

Re: [SQL] Selecting rows as if they were columns?

2003-10-09 Thread Richard Huxton
-page chapter on the topic and explores the methods in > detail. Or see the contrib/tablefunc functions which can do this sort of thing for you. -- Richard Huxton Archonet Ltd ---(end of broadcast)--- TIP 9: the planner will ignore your desire to choose an index scan if your joining column's datatypes do not match

Re: [SQL] PL/PGSQL TUTORIAL

2003-10-11 Thread Richard Huxton
.net/ That's not to say all the projects are high-quality, but you can probably find something that will suit your needs. There's a lot of good information linked from http://techdocs.postgresql.org/ too. -- Richard Huxton Archonet Ltd --

Re: [SQL] PL/PGSQL TUTORIAL

2003-10-11 Thread Richard Huxton
be worth looking at are OpenACS or Bricolage, both web-based content-management systems. -- Richard Huxton Archonet Ltd ---(end of broadcast)--- TIP 9: the planner will ignore your desire to choose an index scan if your joining column&#

Re: [SQL] [GENERAL] SQL query problem (many table in FROM statement and many LEFT JOIN's)

2003-10-10 Thread Richard Huxton
_data.mda_mod_ver _VER ON _VER.ver_id = _CON.ver_id LEFT JOIN db_data.mda_mod_yea _YEA ON _YEA.yea_id = _CON.yea_id which was being parsed as something like: ( (_FUE LEFT JOIN _VER) LEFT JOIN _YEA ), _MOD, _CON, ENG Of course, if it tries to evaluate in this order it can't see _CON

Re: [SQL] sql performance and cache

2003-10-11 Thread Richard Huxton
rows etc. This means the second query shouldn't need to access the disk if the rows it requires are cached. There is a discussion of the postgresql.conf file and how to tune it at: http://www.varlena.com/varlena/GeneralBits/Tidbits/index.php Given the explain attached, 16 secs seems slow. Co

Re: [SQL] sql performance and cache

2003-10-11 Thread Richard Huxton
s chosen to join then filter rather than the other way around. I'd suggest the following: 1. VACUUM FULL on the table in question if you haven't done so since the last update/reload. If you aren't doing this after every bulk upload, you probably should be. 2. VAC

Re: [SQL] Running tally

2003-10-11 Thread Richard Huxton
OF run_tot_type AS... Accumulate your values in a record-type variable and use RETURN NEXT to issue each row. HTH -- Richard Huxton Archonet Ltd ---(end of broadcast)--- TIP 3: if posting/reading through Usenet, please send an appro

Re: [SQL] about postgre SQL download

2003-10-14 Thread Richard Huxton
on and in the documentation on the website. You might also find the techdocs site useful if you are porting from another database: http://techdocs.postgresql.org/ Sorry I can't be more specific, but you didn't say what platform you wanted to run on. -- Richar

Re: [SQL] Create View

2003-10-15 Thread Richard Huxton
s.postgresql.org) 2. A transaction/account page that you keep up to date in exactly the sort of format you want in your view. Triggers can make sure this happens automatically. Unfortunately, if you're stuck with the tables you've shown us then I don'

Re: [SQL] about postgre SQL download

2003-10-15 Thread Richard Huxton
your experience, time available and whether you want to spend any money. HTH -- Richard Huxton Archonet Ltd ---(end of broadcast)--- TIP 4: Don't 'kill -9' the postmaster

Re: [SQL] SQL function to validate money input

2003-10-16 Thread Richard Huxton
level not in my > application code. Well, you can always write your own, but: 1. How were you planning to use it? 2. What were you planning to do if the value provided isn't valid as money? -- Richard Huxton Archonet Ltd ---(end of broadcast)

Re: [SQL] Object description at Client Window

2003-10-17 Thread Richard Huxton
\d mytable and it will show you the SQL it uses to produce the table's details. -- Richard Huxton Archonet Ltd ---(end of broadcast)--- TIP 9: the planner will ignore your desire to choose an index scan if your joining column's datatypes do not match

Re: [SQL] date_trunc for 5 minutes intervals

2003-10-20 Thread Richard Huxton
the SQL ro acheive the desired outcome? I'd probably convert to seconds-since-epoch and then subtract that value modulo 300 and convert back. Might be worth checking the cookbook link on http://techdocs.postgresql.org/ since I can't believe you are the first person to need this. -- R

Re: [SQL] Which is faster SQL or PL/PGSQL

2003-10-20 Thread Richard Huxton
est plan for the first query, but if you have an index on town_name you probably want to use it in the second case. So - gain by not re-planning on every call, but maybe lose because your plan is not so precise. Of course, any queries you build dynamically and run via EXECUTE will have to be pl

Re: [SQL] query or design question

2003-10-20 Thread Richard Huxton
ticularly complex, I'd be tempted to do the hard work in the application. -- Richard Huxton Archonet Ltd ---(end of broadcast)--- TIP 3: if posting/reading through Usenet, please send an appropriate subscribe-nomail command to [EMAIL PROTECTED] so that your message can get through to the mailing list cleanly

Re: [SQL] Scripting only the functions

2003-10-20 Thread Richard Huxton
ion starting with "LANGUAGE" (doesn't seem likely to me). The other options you could use are: 1. To write your own function-dumping script (use psql -E then \df+ to see how to get the function source). 2. Use pgadmin if there aren't too many function

Re: [SQL] Which is faster SQL or PL/PGSQL

2003-10-20 Thread Richard Huxton
On Monday 20 October 2003 18:24, Joe Conway wrote: > Richard Huxton wrote: > > So - gain by not re-planning on every call, but maybe lose because your > > plan is not so precise. > > > > Of course, any queries you build dynamically and run via EXECUTE will >

Re: [SQL] plpgsql related question: intervals and variables

2003-10-21 Thread Richard Huxton
27;'vk days''; > The variable 'heute' is declared as timestamp, > 'vk' as integer! > > What have we done wrong?? Quoted the vk variable. You want something like: ez := heute + (vk || '' days'')::interval; -- Richard Huxton

Re: [SQL] how to create a multi columns return function ?

2003-10-21 Thread Richard Huxton
quot; whereas it's returning whatever your columns are. You'll want to do something like: CREATE TYPE fn_ret_type AS ( column1 int4, column2 text, column3 date, ... ); CREATE FUNCTION function_name(int) RETURNS fn_ret_type ... If it returns multiple rows you want SETOF fn_ret_ty

Re: [SQL] Writing the SQL queries inside Functions and operators

2003-10-21 Thread Richard Huxton
cat('hello', text_concat('there', text_concat('everyone') ) ) -- Richard Huxton Archonet Ltd ---(end of broadcast)--- TIP 5: Have you checked our extensive FAQ? http://www.postgresql.org/docs/faqs/FAQ.html

Re: [SQL] [GENERAL] Alias-Error

2003-10-21 Thread Richard Huxton
u're missing a table name here. It could be PG is reporting the wrong error. > C2.cmc_name='INTERN2000' AND sis_cmca.cmc_mchap=C2.cmc_mchap -- Richard Huxton Archonet Ltd ---(end of broadcast)--- TIP 6: Have you searched our list archives? http://archives.postgresql.org

Re: [SQL] Fw: Error message during compressed backup

2003-10-23 Thread Richard Huxton
192.xxx.x.xxx -p 5432 -v testdb -f > /home/db_repository/testdb20031023.sql.tar.gz -u -F c > > --Error msg > WARNING: owner of function "plpgsql_call_handler" appears to be invalid In psql, do: \df+ plpgsql* This will show you the owner (among other details) - it should

Re: [SQL] Left outer join and sub queries alias

2003-10-23 Thread Richard Huxton
rsonne_id ) where personne_id=57 -- Richard Huxton Archonet Ltd ---(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] Réf. : Re: [SQL] Left outer join

2003-10-23 Thread Richard Huxton
--+---+- 1 | aaa | 1 | fff 2 | bbb | | 3 | ccc | 3 | ggg (3 rows) -- Richard Huxton Archonet Ltd ---(end of broadcast)--- TIP 6: Have you searched our list archives? http://archives.postgresql.org

Re: [SQL] query assistance

2003-11-04 Thread Richard Huxton
dy_name, count(sty_pk) FROM study GROUP BY created_by, study_name HAVING count(sty_pk) > 1; -- Richard Huxton Archonet Ltd ---(end of broadcast)--- TIP 9: the planner will ignore your desire to choose an index scan if your joining c

Re: [SQL] FOR : Structure control pb

2003-11-10 Thread Richard Huxton
arse error at or > near FOR. The FOR loop is a plpgsql block not an SQL one. You'll need to write a plpgsql function if you want to use it. -- Richard Huxton Archonet Ltd ---(end of broadcast)--- TIP 3: if posting/reading t

Re: [SQL] Conversion Problem

2003-11-13 Thread Richard Huxton
f is to use a case: SELECT WHEN 1>2 THEN 1 ELSE 0 END; As to why MSSQL doesn't support booleans, you could try asking their tech support, but I wouldn't get your hopes up. -- Richard Huxton Archonet Ltd ---(end of broadcast)--- TI

Re: [SQL] STRICT function returning a composite type

2003-11-13 Thread Richard Huxton
s section of the manual: RETURNS NULL ON NULL INPUT or STRICT indicates that the function always returns NULL whenever any of its arguments are NULL. If this parameter is specified, the function is not executed when there are NULL arguments; instead a NULL result is assumed automatically. -- Ri

Re: [SQL] ::text problem

2003-11-25 Thread Richard Huxton
#x27;::text ELSE c1::text END as approval_date FROM t1; You need to make sure both options return type text. -- Richard Huxton Archonet Ltd ---(end of broadcast)--- TIP 4: Don't 'kill -9' the postmaster

Re: [SQL] Unsigned numbers

2003-11-26 Thread Richard Huxton
r 7.4, I believe. There aren't any built-in unsigned types, although in theory you could write your own. What I do is format my constraint names in a known way. So, a check on table foo, column bar might be called "foo_bar_positive" - then I can get the information I want fr

<    1   2   3   4   5   6   7   8   9   10   >