IWETHEY v. 0.3.0 | TODO
1,095 registered users | 0 active users | 0 LpH | Statistics
Login | Create New User
IWETHEY Banner

Welcome to IWETHEY!

New How to fake oracle ROWNUM in postgres?
Here's my function - it relies on rownum - a synthetic column in oracle. Why it wants rownum =1 I have no idea - someone could explain to me what the point of doing something like this is as well as how to work around it and I would be very grateful:

\nCREATE OR REPLACE FUNCTION getAgeReduction(integer, timestamptz) RETURNS numeric AS\n\n'   DECLARE\npoId Alias for $1;\nDATEOFBIRTH Alias for $2;\nage integer;\nrows integer;\nminOid integer;\nBEGIN\nage := Age(DATEOFBIRTH);\nSELECT ReductionLifeBenefitPercentage INTO AgeReductionPercentage\nFROM (\nSELECT ReductionLifeBenefitPercentage, ReductionLifeBenefitAge\nFROM(  SELECT ReductionLifeBenefitPercentage, ReductionLifeBenefitAge\nFROM GroupLifeReduction\nWHERE planOptionId = poId\nAND ReductionLifeBenefitAge <= age\nORDER BY ReductionLifeBenefitAge DESC) as Sub2\nWHERE ROWNUM = 1\nUNION\nSELECT ReductionLifeBenefitPercentage, ReductionLifeBenefitAge\nFROM(  SELECT ReductionLifeBenefitPercentage, ReductionLifeBenefitAge\nFROM GroupLifeReduction\nWHERE planOptionId = poId\nAND ReductionLifeBenefitAge >= age\nORDER BY ReductionLifeBenefitAge ASC) AS Sub1\nWHERE ROWNUM = 1\n) AS Sub3 WHERE ROWNUM = 1;\nIF AgeReductionPercentage is null THEN\nreturn 0;\nELSE\nreturn AgeReductionPercentage/100;\nEND IF;\nEND'\nlanguage 'plpgsql';\n



.....To the future or to the past, to a time when thought is free, when men are different from one another and do not live alone -- to a time when truth exists and what is done cannot be undone:
.....From the age of uniformity, from the age of solitude, from the age of Big Brother, from the age of doublethink -- greetings!

     -- George Orwell, 1984
Expand Edited by tuberculosis Feb. 8, 2004, 01:57:14 PM EST
New Looks like the just want the top and bottom
ReductionLifeBenefitAges.

Use LIMIT 1 on your Postgres query to achieve the same effect, I wot.
Regards,

-scott anderson

"Welcome to Rivendell, Mr. Anderson..."
     How to fake oracle ROWNUM in postgres? - (tuberculosis) - (1)
         Looks like the just want the top and bottom - (admin)

I swear, you make people want to jump into a volcano.
42 ms