Skip to Main Content

Oracle Database Express Edition (XE)

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

My code shows error and I am not able to understand the errror

User_HZ8OJSep 16 2021

CREATE TABLE credit(
cust_name varchar2(100),
credit_limit NUMBER(10,3),
cust_id NUMBER);
INSERT INTO credit VALUES('Arnab Deb',999990.000,100);
INSERT INTO credit VALUES('Pampita Bhowmik',999991.000,150);
INSERT INTO credit VALUES('Ankur Kumar Das',999992.000,102);
DECLARE
l_credit_lmt credit.credit_limit%TYPE;
l_average_cred l_credit_lmt%TYPE;
l_max_cred l_credit_lmt%TYPE;
l_min_cred l_credit_lmt%TYPE;
BEGIN
SELECT
MIN(credit_limit);
MAX(credit_limit);
AVG(credit_limit);
INTO
l_min_cred,
l_max_cred,
l_average_cred,
FROM
credit;

SELECT
credit_limit;
INTO
l_credit_lmt;
FROM
credit;
WHERE
cust_id = 100;
DBMS_OUTPUT.PUT_LINE('Minim-Credit:-'|| l_min_cred);
DBMS_OUTPUT.PUT_LINE('Maximum-Credit:-'|| l_max_cred);
DBMS_OUTPUT.PUT_LINE('Avg-Credit:-'|| l_average_cred);
DBMS_OUTPUT.PUT_LINE('Cust-Credit:-'|| l_credit_lmt);

END;
The error it shows is :-
ORA-06550: line 3, column 20:
PL/SQL: ORA-00923: FROM keyword not found where expected

Comments

Kamal Kishore
Try adding the PRAGMA to the function.
FUNCTION function_name(...) RETURN VARCHAR2 ;
    PRAGMA RESTRICT_REFERENCES(function_name, WNDS, RNDS, WNPS,RNPS);
APC
There are a number of things it could be.

My #1 candidate is, we can only use functions in SQL statements that are public i.e. declared in a package spec. This is the case even for SQL statements executed within the same Package Body. The reson is that SQL statements are executed by a different engine which can only see publicly declared functions.

Cheers, APC
32685
Hi Andrew

That's exactly it! I moved the functions back to the original package, published them in the spec and it worked. Excellent!

Cheers

David
446518
Great!!

Helped me a lot

Though the message - function XX may not be used in SQL, is not relevent.

Krishna
564378
Wow, that cost me some time.
Thanks a lot, it saved my day.
450441
My god, users who search the forum before posting.

Surely it's a sign of the End of Days.
Amritpal
Thanks a lot, I just Googled the error PLS-00231, the very first link brought me here, and you were spot on. Declare the functions in the Package Spec to make them Global, and that solved the issue.

Thanks.
Amrit
659130
I also have this problem.

Making the function public helps ... but I can not make the function public. This violates the design.

The PRAGMA also says that it must be right behind the function definition AND in the package specification.


Is there a other - a private - way?

(Oracle 8i / PLSQL 8.1.7.4.0)



I also can not split the call from the SQL Statement, because it is part of a cursor loop:
FOR a IN (SELECT asd,
                         asaa,
                         asdasda,
                         h.sssde,
                         HLP_FNC_GET_BLABLUBB(j.adasdassss) dasdasssss
                  FROM   T_fhexxxsadfast h,
                         t_FFasee112w_SA   j
                  WHERE  h.soasde = j.soasde) 
        LOOP
anonymized code.

Edited by: user5828099 on 10.09.2008 07:57

Edited by: user5828099 on 10.09.2008 08:02
1 - 8

Post Details

Added on Sep 16 2021
3 comments
104 views