Skip to content

Instantly share code, notes, and snippets.

@mhulse
Last active August 29, 2015 14:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mhulse/633f47c79ce671aae1b5 to your computer and use it in GitHub Desktop.
Save mhulse/633f47c79ce671aae1b5 to your computer and use it in GitHub Desktop.
Caché 2009.1 - NEWSCYCLE Solutions: DTI Lighting 7.7.x: Get sub/category name CSP methods.
<csp:comment>
/// @param: Category/subcategory id. Required.
/// @return: Category/subcategory name.
</csp:comment>
<script language="cache" method="catName" arguments='id:%String=""' returntype="%String" procedureblock="1">
//----------------------------------
// Initialize:
//----------------------------------
set return = ""
if ($length(id)) {
//----------------------------------
// Subcategory?
//----------------------------------
&sql(select subCategoryName into :return from dbo.SubCategory SC where sc.subCategoryId = :id)
if (( ' $length(return)) || (return = "-") || ($zconvert(return, "U") = "NONE")) { // Should I check SQLCODE also?
//----------------------------------
// Category?
//----------------------------------
&sql(select categoryName into :return from dbo.Category C where C.categoryId = :id)
} else {
//----------------------------------
// RG-specific category name fixes:
//----------------------------------
set return = ..fix(return)
}
}
//----------------------------------
// Return:
//----------------------------------
quit return
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment