Missing Keyword when trying to Select into

anonuser1234

So I have a function to return an Average of a column such as

CREATE OR REPLACE FUNCTION avgCol
RETURN DEC IS avgNum DEC;
BEGIN
  SELECT AVG(myCol)
  INTO avgNum
  FROM MyTable;
  RETURN avgNum;
END;
/

While trying to test the results, i have the following

SELECT avgCol
INTO RESULT
FROM DUAL;

but it gives me the error

ORA-00905: missing keyword
00905. 00000 -  "missing keyword"
*Cause:    
*Action:
Error at Line: 175 Column: 6

Where line 175 is INTO RESULT. As far as I know, this is a scalar function and I'm trying to return a signal variable so it should work right? What keyword am I missing here? Also I know I can just use AVG(), but I am learning how to create a scalar function. this is strictly for learning purposes.

guthy

While testing your code (which should be ok), you need

SELECT avgCol AS result FROM DUAL;

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

How to resolve missing SELECT keyword error when trying to insert select

Oracle: missing SELECT keyword, when using CTE

ORA-00928: missing SELECT keyword when using with clause

Missing select keyword when inserting Xml data into table

INSERT … SELECT : missing SELECT keyword

Getting missing select keyword error when I do have select keyword

Missing keyword error in SELECT INTO statement

Select Case Oracle Missing Expression or Missing Keyword

ORA-00928: missing SELECT keyword when i tried to insert multiple rows in Oracle database table

ORA-00905: missing keyword for select into

DatabaseError: ORA-00928: missing SELECT keyword

Select 3 rows in SQL missing keyword

Missing Keyword when using Case in Where clause

Missing keyword in nested CASE WHEN statement

java.sql.SQLException: ORA-00928: missing SELECT keyword. when inserting record to DB using JDBC

Getting ORA-00928: missing SELECT keyword error

ORA-00928: missing SELECT keyword: update using with

Missing Keyword in EXECUTE IMMEDIATE SELECT INTO Statement - Oracle PL/SQL

Missing nodes when trying to parse xml in php

Part of the string is missing when trying to replace

Missing variable when trying to write to file

Root element is missing when trying to Publish

Missing header files when trying to build Skia

Getting DATABASE MISSING when trying to create a database

Stack with an error when trying to replace missing data

the `async` keyword is missing from the function declaration when compile rust project

Getting error: "Missing keyword" when using case in where clause

Dynamic keyword throwing RunTimebinderException when trying to set native property

I am trying to create a table in sql, but im missing a keyword, cant find out how to fix it