Skip to main content

Posts

Parse Property values from Oracle Profile Provider Schema

Recently we had the need to pull user profile information independent of the Microsoft provider framework. The property values are stored in a table that contains a "PropertyNames" field with meta information on the start position and length of the property value being stored. This self-describing storage method is pretty slick but attempting to use the built in wrapped function for retrieving the property values proved to be more challenging than simply writing our own parser. There are two SQL functions. They are used in this way: SELECT p.USERID, m.EMAIL, GETPROFILEELEMENT('FirstName', PropertyNames, PropertyValuesString) AS FirstName, GETPROFILEELEMENT('LastName', PropertyNames, PropertyValuesString) AS LastName FROM ora_aspnet_profile p, ora_aspnet_membership m WHERE p.USERID = m.USERID Here are the functions: CREATE OR REPLACE FUNCTION ASPNET_DB_USER."GETPROFILEELEMENT" ( fieldName IN VARCHAR2, ...

Example of an Oracle script using a cursor

SET SERVEROUTPUT ON; declare cursor myCursor is (select auth_code, lastname, dob, driverlicensenumber, driverlicensestate from snap_driver_record where auth_date >= sysdate - 13 and auth_sequence=0); vAuthCode snap_driver_record.auth_code%type; vLastName snap_driver_record.lastname%type; vDob snap_driver_record.dob%type; vLicenseNumber snap_driver_record.driverlicensenumber%type; vLicenseState snap_driver_record.driverlicensestate%type; vCrashCount integer; vInspCount integer; vCrashTot integer; vInspTot integer; vDirCount integer; begin select count(*) into vDirCount from snap_driver_record where auth_date >= sysdate - 13 and auth_sequence=0; open myCursor; loop fetch myCursor into vAuthCode, vLastName, vDob, vLicenseNumber, vLicenseState; EXIT WHEN myCursor%NOTFOUND; -- get crash record count select count(*) into vCrashCount from crash_driver cd ...

Sorting an ICollection

Have you ever wanted to sort an ICollection? It took me awhile to figure this one out so I thought I should blog it. I originally posted this quite awhile ago. Since then I have discovered a much easier way to sort a collection. Here's an update on sorting collections using LINQ. Much simpler: var orderedList = customer.Users .OrderBy(x => x.UserType) .ToList(); And here is my original post on the subject. You decide which one looks easier. private IList<EventReqFormSection> GetSections() { ICollection<EventReqFormSection> sections = EventReqFormSection.GetByEventReqFormId(_businessObject.Id, ObjectManager); // sort by Display Sequence List<EventReqFormSection> sortedValues = new List<EventReqFormSection>(sections); sortedValues.Sort(new EventReqFormSection.DisplaySequenceSort()); return sortedValues; } The above function retrieves an ICollection puts it into a List object and calls the sort method usin...