the creation of this query spiff works now. Will add instantiation code. Note that srminterface.h should belong to SRM instead of postgres. Will decide on how to elegantly include this header.