onea
asked on
Can't get my function to work on MySql
I try to create following function. When i try to execute this script, I get syntax errors.
CREATE FUNCTION GetPartnerFieldValue(partnerId BIGINT, fieldCode VARCHAR(255))
RETURNS VARCHAR(255)
DETERMINISTIC
BEGIN
DECLARE sReturnString VARCHAR(255);
SELECT * FROM (
SELECT
f.value
INTO
sReturnString
FROM
PARTNERFIELD f,
PARTNERFIELDTYPE ft
WHERE
f.partner_id = @partnerId
AND f.partnerFieldType_id = ft.id
AND ft.code = @fieldCode
) result;
RETURN sReturnString;
END;
ASKER
Same problem:
Error at line 5, error in sql syntax.
Undeclared variable sReturnString.
Syntax error on the return line;
Error at line 5, error in sql syntax.
Undeclared variable sReturnString.
Syntax error on the return line;
How about this?
CREATE FUNCTION GetPartnerFieldValue(partnerId BIGINT, fieldCode VARCHAR(255))
RETURNS VARCHAR(255)
DETERMINISTIC
BEGIN
DECLARE sReturnString VARCHAR(255);
SELECT * INTO
sReturnString FROM
(
SELECT
f.value
FROM
PARTNERFIELD f,
PARTNERFIELDTYPE ft
WHERE
f.partner_id = @partnerId
AND f.partnerFieldType_id = ft.id
AND ft.code = @fieldCode
) result;
RETURN sReturnString;
END;
ASKER
Still the same.
It looks to me that the DECLARE function isn't working.
I get the first error when declaring the sReturnString variable.
And I think this causes the errors for rest of the script.
It looks to me that the DECLARE function isn't working.
I get the first error when declaring the sReturnString variable.
And I think this causes the errors for rest of the script.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Open in new window