LabKey SQL provides the function extensions covered in this topic to help Java module developers and others writing custom LabKey queries access various properties.
moduleProperty(MODULE_NAME, PROPERTY_NAME)
Returns a module property, based on the module and property names. Arguments are strings, so use single quotes not double.
moduleProperty values can be used in place of a string literal in a query, or to supply a container path for
Queries Across Folders.
ExamplesmoduleProperty('EHR','EHRStudyContainer')
You can use the virtual "Site" schema to specify a full container path, such as '/home/someSubfolder' or '/Shared':
SELECT *
FROM Site.{substitutePath moduleProperty('EHR','EHRStudyContainer')}.study.myQuery
The virtual "Project." schema similarly specifies the name of the current project.
javaConstant(FULLY_QUALIFIED_CLASS_AND_FIELD_NAME)
Provides access to public static final variable values. The argument value should be a string.
Fields must be either be on classes in the java.lang package, or tagged with the org.labkey.api.query.Queryable annotation to indicate they allow access through this mechanism. All values will be returned as if they are of type VARCHAR, and will be coerced as needed. Other fields types are not supported.
ExamplesjavaConstant('java.lang.Integer.MAX_VALUE')
javaConstant('org.labkey.mymodule.MyConstants.MYFIELD')
To allow access to MYFIELD, tag the field with the annotation @Queryable:
public class MyConstants
{
@Queryable
public static final String MYFIELD = "some value";
}
Related Topics