Results 1 to 3 of 3

Thread: Function

  1. #1
    Join Date
    Dec 2016

    Unanswered: Function


    I mostly use database for data storage, and do all the evaluating and manipulating in whatever language I'm programing in. The project I'm currently working on, I'd like to move as many operations as I can into database functions.

    I've done some pl/sql in the past, but mostly updating. Today, I am trting to grab values, store them for math operations and return those values.

    What I have in my table are objects with x,y,z coordinates, and would like to choose 2,3,4 or more and calculate a cumulative distance between the selected objects. I'm ok to start with just two for now.

    So in my function, I know I will need two SELECT queries, like SELECT x,y,z from my_items where id =''. That's easy, but how do I drop the result into a variable so I can later perform the math? The only thing I found so far, is something like:

    out1 := SELECT x,y,z from my_items where id ='a'
    out2 := SELECT x,y,z from my_items where id ='b'

    But that doesn't work; apperently SELECT isn't recognized in that situation. Not a lot of examples on the postgres implementation of pl/sql.

    Any hints would be appreciated!

  2. #2
    Join Date
    Nov 2003
    Provided Answers: 23
    I will not read nor answer questions where the SQL code is messy and not formatted properly using [code] tags:

    Tips for good questions:

  3. #3
    Join Date
    Dec 2016
    Thank you shammat!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts