1

You might not believe it but I searched the questions on stackoverflow to find an answer for the following question:

I can compile this function

create or replace function cart_distance(x1 in number,x2 in number,y1 in number,y2 in number)
return number is
begin
   return sqrt((x2-x1)*(x2-x1) + (y2-y1)*(y2-y1));
end;

But if I want to test it the compiler gives the following error "Encountered the symbol SELECT"

SELECT cart_distance(2,3,4,5) FROM DUAL;

The function and the query are written in the SQL worksheet and I press the "Run statement" option. (I'm very unexperienced with the program)

3
  • It should be: SELECT dbo.cart_distance(2,3,4,5) FROM DUAL; assuming it's assigned to the dbo schema, and you're using SQL Server. Commented Sep 28, 2015 at 19:23
  • 1
    This looks like oracle. select statement looks correct. Highlight just the select statement and execute that. Commented Sep 28, 2015 at 19:24
  • @rono: the syntax is clearly PL/SQL and not T-SQL. And Oracle does not require user defined functions to be prefixed with the schema (owner). Commented Sep 28, 2015 at 19:53

1 Answer 1

4

Try Selecting the query text and pressing the "Run" button. From the error which you have posted, I understand that it is executing the function compilation in the same Run as executing the query. Or better - try in a separate worksheet. Make sure your connection is correct.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.