We're Moving!

The Vertica Forum is moving to a new OpenText Analytics Database (Vertica) Community.

Join us there to post discussion topics, learn about

product releases, share tips, access the blog, and much more.

Create My New Community Account Now


Vertica Function — Vertica Forum

Vertica Function

New to vertica... could someone help...

 

How to create a function that can return the result set of query to a function? Document says, you can only return simple types.

My problem: I have written a complex set of queries ( 200 lines) that produces a max value. I want to expose this as function to python or users and Not give him 200 lines of code to be executed, how to achieve this?

 

PS: this is not a java function, pure Vertica sql 200 lines of queries within queries that produces a result. I want to wrap it up as function or procedure.

 

CREATE OR REPLACE FUNCTION "Schema1"."getMax"(snapShot TimestampTz, pTime Integer)
   RETURN Varchar(?)
   AS
   BEGIN
     
      RETURN ( SELECT max(column1) from ( select abc from table 2) )
   END;

 

(or)

 

CREATE OR REPLACE FUNCTION "Schema1"."getMax"(snapShot TimestampTz, pTime Integer)
   RETURN Varchar(?)
   AS
   BEGIN
      q1 = SELECT max(column1) from ( select abc from table 2) );
      RETURN ( execute(q1) )
   END;

Leave a Comment

BoldItalicStrikethroughOrdered listUnordered list
Emoji
Image
Align leftAlign centerAlign rightToggle HTML viewToggle full pageToggle lights
Drop image/file