posts - 7, comments - 24, trackbacks - 0

My Links

News

Archives

April 2011 Entries

PL/SQL: get the id if a value exists in a look up table, insert and get the id if it doesn't
I ran into this one because I was working with some tables in a normalized database and I needed to quickly check to see if an id existed, and if it didn't, I needed to insert and then get the id. This is what I came up with in the end: inside your PL/SQL block, you can have any number of sub blocks, like this (here I am using 2 PL/SQL variables: thisVehicleFuelTypeId and thisVehicleFuelType): BEGIN ---------- sub-block begins SELECT FUEL_TYPEID INTO thisVehicleFuelTypeId FROM TBL_FUEL_TYPE WHERE...

Posted On Tuesday, April 05, 2011 10:12 AM | Feedback (2) |

Powered by: