函式最後傳回一個拼接的字串如下:
......
RETURN p_field CLIPPED, "=", l_result CLIPPED, "; export ", p_field CLIPPED
END FUNCTION
另一個函式則會在編譯時發生錯誤如下,也是相同意思:
../42m/xxx.4gl:117:1:121:12:error:(-6611) Function 'concat_string': unexpected number of returned values.
The compilation was not successful. Errors found: 1.
在函式先宣告STRING型態變數。
FUNCTION concat_string()
# 宣告要回傳的STRING型態變數
DEFINE l_result STRING
......
在最後回傳時先將結果寫入這個變數即可。
......
# 拼接字串先寫入這個變數
LET l_result = p_field CLIPPED, "=", l_result CLIPPED, "; export ", p_field CLIPPED
# 回傳這個變數
RETURN l_result
END FUNCTION
或改用||拼接字串。(但如果其中一個字串為NULL,則會直接回傳NULL。)
tiptop — 2026年4月27日
Made with ❤ and at Taiwan.