Oracle to PGSQL -- need help

From: "Randall Barber" <rdb55(at)email(dot)byu(dot)edu>
To: pgsql-general(at)postgresql(dot)org
Subject: Oracle to PGSQL -- need help
Date: 2002-07-17 18:29:27
Message-ID: ah4cpe$2gte$1@news.hub.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Hi there--

I'm trying to restrict some of my programming logic to the database. I have
a table that has a one to many relationship with its data.
Specifically, I could have group 1 with 5 tie ins, like so (this table also
has a closed path which is used to find the left column):

1,2
1,5
1,200
1,4356
1,483

Given an insert request, I want the trigger to find out which # is used on
the left, and then randomly select one of the resultant rows and insert the
randomly picked row's PKEY value along with the original insertion info.
into a third table.

Here is how to do it in Oracle (non-trigger, but not hard to do). Can
someone tell me how to make it work in PGSQL???

SELECT * FROM
(SELECT XL.*, ROW_NUMBER() OVER (PARTITION BY 'Q' ORDER BY JOBID) AS N
FROM XEROXLOGENTRIES XL) X
WHERE X.N = ABS(MOD(DBMS_RANDOM.RANDOM, 100))

Aprpeciate it very much!
RDB
Randall Barber
Brigham Young University
rdb55(at)email(dot)byu(dot)edu

Responses

Browse pgsql-general by date

  From Date Subject
Next Message User 2002-07-17 18:54:28 SQL If-Then Logic in Query
Previous Message Jan Wieck 2002-07-17 18:01:29 Re: table size growing out of control