Accessing an array element from a function

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Mike Nolan

    Accessing an array element from a function

    This may be mostly a documention issue:

    I have a function with two parameters that returns an array: text[].

    I want to access just the first element of that array within
    my SQL statement.

    This doesn't work:

    select myfunc(1,2)[1];

    This does work:
    select (myfunc(1,2)[1];

    If that's how it's supposed to work, is that documented somewhere?
    --
    Mike Nolan

    ---------------------------(end of broadcast)---------------------------
    TIP 2: you can get off all lists at once with the unregister command
    (send "unregister YourEmailAddres sHere" to majordomo@postg resql.org)

  • Tom Lane

    #2
    Re: Accessing an array element from a function

    Mike Nolan <nolan@gw.tssi. com> writes:[color=blue]
    > This doesn't work:
    > select myfunc(1,2)[1];[/color]
    [color=blue]
    > This does work:
    > select (myfunc(1,2)[1];[/color]

    I suppose you meant

    select (myfunc(1,2))[1];
    [color=blue]
    > If that's how it's supposed to work, is that documented somewhere?[/color]



    regards, tom lane

    ---------------------------(end of broadcast)---------------------------
    TIP 6: Have you searched our list archives?



    Comment

    Working...