I think I've nearly got it but not quite, I'm trying to return a DOPL value within my function but can't figure out the problem (thanks in advance).
CREATE OR REPLACE FUNCTION GET_CUST_STRING_FROM_DB (pcustid NUMBER) RETURN
VARCHAR2 AS
vCustname VARCHAR2(100);
vStatus VARCHAR2(7);
vSalesYTD NUMBER;
vStr VARCHAR2(100);
BEGIN
SELECT CUSTNAME, SALES_YTD, STATUS INTO vCustname, vStatus, vSalesYTD FROM
Customer
WHERE pcustid = CUSTID;
vStr := DBMS_OUTPUT.PUT_LINE('Custid: ' || pcustid || ' Name: ' || vCustname
|| ' Status: ' || vStatus || ' SalesYTD: ' || vSalesYTD);
RETURN vStr;
EXCEPTION
WHEN NO_DATA_FOUND THEN
RAISE_APPLICATION_ERROR(-20021, 'Customer ID not found');
WHEN OTHERS THEN
RAISE_APPLICATION_ERROR(-20000, SQLERRM);
END;
/
Just replace below mentioned line to
vStr := 'Custid: ' || pcustid || ' Name: ' || vCustname
|| ' Status: ' || vStatus || ' SalesYTD: ' || vSalesYTD;
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.