I have created several Livereports and run them just fine. I needed to get the full path for containers for a client report. I found a UDF in the knowledge base to do this. I keyed in the code into the LiveReport SQL area using "Create Function..." I now want to call that function, but I cannot seem to get it to wor. I am guessing it is a LiveReport newbie issue, but i cannot find the problem.
Here is my SQL from the LiveReport. I am only putting on one node to verifry the function works:
CREATE FUNCTION getFullPath (@DataID INT)
RETURNS varChar(8000) AS
BEGIN
DECLARE @TmpParentID int
DECLARE @FullPath varChar(8000)
DECLARE @Name varChar(255)
DECLARE @TmpName varChar(255)
IF @dataID <> 0
BEGIN
WHILE @DataID <> -1
BEGIN
SELECT @TmpParentID = ParentID FROM dtree WHERE dataID = @DataID
@rowcount = 0
BREAK
IF @dataID < -1 AND @TmpParentID = -1
BEGIN
SET @DataID = ABS(@DataID)
END
ELSE
BEGIN
SET @DataID = @TmpParentID
END
SET @TmpName = @Name
SELECT @Name=Name FROM dtree WHERE dataID = @DataID
if @FullPath IS NULL
BEGIN
Set @FullPath = @Name
END
ELSE
BEGIN
IF @TMPName <> @Name
BEGIN
SET @FullPath = @Name + ':' + @FullPath
END
END
END
END
RETURN @FullPath
END
SELECT a.* FROM dtree AS a WHERE a.dataid = 1529215
This is the error I receive once I added the last SELECT after the function:
[[Microsoft][ODBC SQL Server Driver][SQL Server]Incorrect syntax near the keyword 'select'
Any guidance would be appreciated.