- Как определить функцию f ниже в SQL или T-SQL?
CREATE TABLE tableNames (tName varchar(100))
INSERT INTO tableNames VALUES ('someTableName')
SELECT * FROM f(tableNames)
Где я хочу определить f следующим образом:
f :: { {tName :: varchar(100)} } -> varchar(100)
f(tableNames) =
if tableNames has no records, then return 'defaultTableName'
else if tableNames has more than one record, return 'duplicatesTableName'
else return the value of the tName attribute of the single tuple in tableNames.