[SQL] SQL report

2009-07-29 Thread wkipjohn
I have the following senario. I have a tracking system. The system will record the status of an object regularly, all the status records are stored in one table. And it will keep a history of maximum 1000 status record for each object it tracks. The maximum objects the system will track is

[SQL] Foreign keys and fixed values...

2009-07-29 Thread Kjell Rune Skaaraas
Hello, I'm having a problem using foreign keys, or at least in a way i find good. Basicly I have a table I wish to use as a foreign key with lookup "id" and "code", like: 1,a 1,b 1,c 2,a 2,d I have of course an UNIQUE on (id,code). However, in the table I want the key to apply to, I only hav

Re: [SQL] Tweak sql result set... ?

2009-07-29 Thread Axe
> > Any ideas on how to achieve this? I would like to let the original sql > > code stay original. I can prepare postgres before executing the sql if > > this makes it easier to acheive the goal > > Have a look at CREATE RULE. > > Tim > Ok, you mean I could create a rule for the table, then I let

WG: WG: [SQL] sql-porting-problem oracle to postgresql with UPDAT E/IS NOT NULL

2009-07-29 Thread Gau, Hans-Jürgen
it runs without alias t1. before fieldname id after SET, so: UPDATE table1 t1 SET id = (SELECT t3.id FROM table2 t2,table3 t3, table1 t1 WHERE t3.field = t2.field AND t2.id = t1.id AND t1.id <> t3.id)

Re: [SQL] sql-porting-problem oracle to postgresql with UPDATE/IS NOT NULL

2009-07-29 Thread Daryl Richter
On Jul 28, 2009, at 5:10 PM, nha wrote: Hello, Le 28/07/09 14:25, Daryl Richter a écrit : On Jul 28, 2009, at 5:58 AM, Gau, Hans-Jürgen wrote: hello list, i have some problems with an sql-statement which runs on oracle but not on postgresql (i want update only if result of SELECT is not emp

Re: [SQL] Tweak sql result set... ?

2009-07-29 Thread Jasen Betts
On 2009-07-28, Axe wrote: > I have a problem where I want to tweak a simple select in an > "unobtrusive way". Imagine I have the following select statement: > "SELECT name FROM customer LIMIT 1" and I get a normal result set from > this. But, could I,maybe by defining some other function or simila

Re: WG: [SQL] sql-porting-problem oracle to postgresql with UPDATE/IS NOT NULL

2009-07-29 Thread nha
Hello again, Le 29/07/09 12:21, nha a écrit : > Hello, > > Le 29/07/09 11:48, Gau, Hans-Jürgen a écrit : >> Sorry, it's a lapse by copying and simplification the original version. that >> is correct: >> >> UPDATE table1 t1 >> SET (t1.id) = >> (SELECT t3.id FROM table2 t2,table

Re: WG: [SQL] sql-porting-problem oracle to postgresql with UPDATE/IS NOT NULL

2009-07-29 Thread nha
Hello, Le 29/07/09 11:48, Gau, Hans-Jürgen a écrit : > Sorry, it's a lapse by copying and simplification the original version. that > is correct: > > UPDATE table1 t1 > SET (t1.id) = > (SELECT t3.id FROM table2 t2,table3 t3, table1 t1 > WHERE t3.field = t2.fie

WG: [SQL] sql-porting-problem oracle to postgresql with UPDATE/IS NOT NULL

2009-07-29 Thread Gau, Hans-Jürgen
Sorry, it's a lapse by copying and simplification the original version. that is correct: UPDATE table1 t1 SET (t1.id) = (SELECT t3.id FROM table2 t2,table3 t3, table1 t1 WHERE t3.field = t2.field AND t2.id = t1.id