Re: [SQL] Using a compound primary key

2003-07-27 Thread Tom Lane
"David Witham" <[EMAIL PROTECTED]> writes: > select * from tariff > where tariff_type = 'UIA' > and prefix in ('44','441','4412','44123','441234','4412345','44123456') > order by prefix desc limit 1; > The query doesn't use the primary key index as I might expect: Flip the index column order ---

Re: [SQL] Can a table have a reference to itself?

2003-07-27 Thread Tom Lane
Oliver Duke-Williams <[EMAIL PROTECTED]> writes: > So far so good, but what I'd like to do is to be able to change a value > of a, and have this cascaded to b; however this gives an integrity > violation error: >> update foo set a = 5 where a = 2; > ERROR: chk_a referential integrity violation

[SQL] Using a compound primary key

2003-07-27 Thread David Witham
Hi all, I have a table containing tariff information. It has a primary key (and therefore unique index) of (tariff_type varchar(5),prefix varchar(12)) where tariff_type is a set of rates assigned to dialling prefixes. e.g. tariff_type prefix rate abc 44 $x abc 4

Re: [SQL] Can a table have a reference to itself?

2003-07-27 Thread Stephan Szabo
On Wed, 23 Jul 2003, Oliver Duke-Williams wrote: > I'd like to have a table in which one column has an integrity reference > to another column within the same table, and for updates to the primary > column to be cascaded. The former aspect seems to work OK, but the > latter does not. I think yo

[SQL] Function index qeustion

2003-07-27 Thread Jonathan Bartlett
Questions: 1) If you have an index on a cacheable function, does PostgreSQL use the index instead of calculating the results? 2) How does PostgreSQL know when to recompute the function? Jon On Fri, 25 Jul 2003, Elielson Fontanezi wrote: > Thanks a lot! > > The complete solution is here! > > 1s

Re: [SQL] [OT] SUMMERY Frontend recommendations

2003-07-27 Thread R. van Twisk
SUMMERY Question: > Hey postgresql gurus, > > I was just wondering, what kind of frontend do you recommend in 'bills > (windows...)' environment? > Is it better to use a tool like Qt from trolltech or is it better to use > something like Omnis or Access??? > > What are you opinions ANSWERS

[SQL] PostgreSQL or pl/psSQL equivalent to MS SQL Server's xp_cmdshell?

2003-07-27 Thread Trent . Mera
Title: PostgreSQL or pl/psSQL equivalent to MS SQL Server's xp_cmdshell? Does anyone know of the PostgreSQL or pl/psSQL equivalent to MS SQL Server's xp_cmdshell?   This is the command that allows you issue command-line statements from within SQL, e.g., you would do xp_cmdshell 'dir c:\' if yo

[SQL] Problem using Subselect results

2003-07-27 Thread oheinz
I want to use the result of a subselect as condition of another one. CREATE VIEW my_view AS SELECT b,c (SELECT a, b FROM table2 WHERE b=1) my_ab, (SELECT c FROM table3, my_ab WHERE table3.a=my_ab.a) my_c; does return "relation my_ab unknown". it is not just a problem of execution order - if i t

[SQL] Can a table have a reference to itself?

2003-07-27 Thread Oliver Duke-Williams
Hi, I'd like to have a table in which one column has an integrity reference to another column within the same table, and for updates to the primary column to be cascaded. The former aspect seems to work OK, but the latter does not. For example: > create table foo (a int primary key, b int co

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

2003-07-27 Thread Roberto Mello
On Sun, Jul 27, 2003 at 11:49:10AM -0400, Tom Lane wrote: > > I put up a proposal in pgsql-hackers to change this behavior: > http://archives.postgresql.org/pgsql-hackers/2003-07/msg00818.php > If we made that change then the "wrong" way of defining the default > would fail in an obvious fashion -

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

2003-07-27 Thread Tom Lane
Denis Zaitsev <[EMAIL PROTECTED]> writes: > On Sat, Jul 26, 2003 at 10:31:44AM -0400, Tom Lane wrote: >> That's a dangerous way to define the default --- 'now' is taken as a >> literal of type timestamp, which means it will be reduced to a timestamp >> constant as soon as a statement that requires

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

2003-07-27 Thread Denis Zaitsev
On Sun, Jul 27, 2003 at 08:47:16AM +0100, Richard Huxton wrote: > > No- 'now',now() and CURRENT_TIMESTAMP all stay fixed during a transaction. > The one that changes is timeofday() I think. See the "Functions and > Operators" section for details. Yes, indeed... Documentation describes this. And

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 mentioned in the manuals somewhere, but it's not >> su