using array data type

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • shoonya
    New Member
    • May 2007
    • 160

    #1

    using array data type

    i am using array as a data type in my db

    [CODE=sql]
    ....
    (
    sequence integer[]
    ) ;
    [/CODE]
    and it stores a value
    let {1,2,3,4,5}

    now if i a selecting the array as
    [CODE=sql]
    select sequence from foo where...
    [/CODE]

    then result which i get is not an array and i want it as an array
    and i don't have to use
    [CODE=sql]select sequence[index][/CODE] option

    shoonya
    Last edited by michaelb; Jun 5 '07, 12:49 PM. Reason: Fixed the CODE tags
  • michaelb
    Recognized Expert Contributor
    • Nov 2006
    • 534

    #2
    Originally posted by shoonya
    ... ... ...
    now if i a selecting the array as
    [CODE=sql]
    select sequence from foo where...
    [/CODE]
    then result which i get is not an array and i want it as an array
    and i don't have to use
    [CODE=sql]select sequence[index][/CODE] option
    What you get back looks like a string representation of an array:
    Code:
    testdb=# SELECT sequence FROM tt2 WHERE x = 1;
      sequence   
    -------------
     {1,2,3,4,5}
    (1 row)
    If what you want is to initialize some local array variable to the result returned by the query, then it is up to you to do it, database has nothing to do with this, although you can obviously format the return value using array functions; for example you can remove the curly braces, change the default delimiter, etc.

    You can find some useful information on arrays here:
    Arrays
    Array Functions and Operators

    If this is not what you're trying to do, then clarify your question.

    Comment

    Working...