1

​I have a function that is defined as: ​Where XXXXX is my schema YYYYY is my package.

PROCEDURE "XXXXX"."YYYYY.SPATIAL::SP_GA_PT_PATH_DISTANCE" (IN PID NVarChar(36)) 
LANGUAGE SQLScript
SQL SECURITY INVOKER 
--DEFAULT SCHEMA <default_schema_name>
AS
BEGIN

I want to call a function and assign the result to a variable, I have tried the following two ways:

intIntersect := XXXXX.YYYYY.SPATIAL::GA_INTERSECT (32.925148, -117.020051, 
                                                   32.924672, -117.019454,
                                                   32.924488, -117.020322,
                                                   32.924849, -117.019759);

​SELECT XXXXX.YYYYY.SPATIAL::GA_INTERSECT (32.925148, -117.020051, 
                                      32.924672, -117.019454,
                                      32.924488, -117.020322,
                                      32.924849, -117.019759) INTO intIntersect FROM DUMMY;

​I have played with different permutations of this, but nothing works.

Any ideas?

Thanks.

1 Answer 1

1

What you describe as a FUNCTION is really a PROCEDURE in your code example.

These differ in the ways you can call either of them. Procedures need to be called via the CALL statement.

Functions can either be used as scalar function in all places where you can use expressions (i.e. the projection list of a SELECT-statement) or, for table-typed functions, like a table in the WHERE condition.

The parameters handed over to the procedure seem to be a list of data items. The general way to pass "lists" of parameters is to use a table-type parameter:

CREATE FUNCTION "XXXXX"."YYYYY.SPATIAL::SP_GA_PT_PATH_DISTANCE" 
              (IN_PIDS TABLE (PID NVARCHAR(36)) )
       RETURNS TABLE (DISTANCES DECIMAL)
AS
BEGIN

   SELECT * FROM :IN_PIDS;
...

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.