Skip to content

Commit

Permalink
updated grammar and description for substing function
Browse files Browse the repository at this point in the history
Ignore-this: 7dbc9778eafa194b3ccb8806ee6dde2f

darcs-hash:20091231000853-b3b23-43ac2e05e9545217ac3de99c2ea34cfcd6addb17.gz
  • Loading branch information
keithshep committed Dec 31, 2009
1 parent 43c3528 commit 2975889
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions Database/TxtSushi/SQLFunctionDefinitions.hs
Expand Up @@ -362,8 +362,10 @@ substringFromFunction = SQLFunction {
minArgCount = 2,
argCountIsFixed = True,
applyFunction = substringFrom . checkArgCount substringFromFunction,
functionGrammar = "SUBSTRING(string_expression FROM start_index)",
functionDescription = "returns the substring going from start_index using 1-based indexing to the end string_expression"}
functionGrammar = "SUBSTRING(string_expression FROM start_index [FOR length_expression])",
functionDescription = "returns substring of string_expression going from " ++
"start_index using 1-based indexing for a length of length_expression " ++
" or to the end of string_expression if the FOR part is omitted"}
where
substringFrom [strExpr, fromExpr] = StringExpression $
drop (coerceInt fromExpr - 1) (coerceString strExpr)
Expand All @@ -375,9 +377,10 @@ substringFromToFunction = SQLFunction {
minArgCount = 3,
argCountIsFixed = True,
applyFunction = substringFromTo . checkArgCount substringFromToFunction,
functionGrammar = "SUBSTRING(string_expression FROM start_expression FOR length_expression)",
functionGrammar = "SUBSTRING(string_expression FROM start_index [FOR length_expression])",
functionDescription = "returns substring of string_expression going from " ++
"start_index using 1-based indexing for a length of length_expression"}
"start_index using 1-based indexing for a length of length_expression " ++
" or to the end of string_expression if the FOR part is omitted"}
where
substringFromTo [strExpr, fromExpr, toExpr] = StringExpression $
take (coerceInt toExpr) (drop (coerceInt fromExpr - 1) (coerceString strExpr))
Expand Down

0 comments on commit 2975889

Please sign in to comment.