Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6952589
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T14:22:07+00:00 2026-05-27T14:22:07+00:00

I have a table with two relevant columns, an ID and a VARRAY of

  • 0

I have a table with two relevant columns, an ID and a VARRAY of doubles representing coordinates like this: (x1, y1, x2, y2, x3, y3, …). The length of this array varies from four to dozens.

I need to write a view that takes all of these rows and expands each of them into several rows with an order field, like this:

ID order  X   Y
 1   1    x1  y1
 1   2    x2  y2
 1   3    x3  y3
 2   1    x1  y1
 2   2    x2  y2
 2   3    x3  y3

Google is no help, and being someone only mediocre at SQL (and mostly in PostgreSQL), the Oracle documentation is impossible to find advanced things in.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T14:22:08+00:00Added an answer on May 27, 2026 at 2:22 pm

    I for myself like piplined tables, heres a solution that uses it:

    create or replace type my_res_typ as object
    (
      v_id    number,
      v_order number,
      x       number,
      y       number
    )
    ;
    /
    
    CREATE OR REPLACE TYPE my_res_tab AS TABLE OF my_res_typ;
    /
    
    create or replace function get_coordinates return my_res_tab
      pipelined is
    
      Result my_res_typ := my_res_typ(null, null, null, null);
      seq    number;
      i      integer;
    begin
    
      for r in (select * from my_table) loop
        seq := 1;
    
        i := r.coordinates.first;
        while i < r.coordinates.last loop
          Result.v_id    := r.id;
          Result.v_order := seq;
          Result.x       := r.coordinates(i);
          Result.y       := r.coordinates(i + 1);
    
          pipe row(Result);
          seq := seq + 1;
          i   := i + 2;
        end loop;
    
      end loop;
    
      return;
    end get_coordinates;
    /
    

    now you can query it like this:

    select * from table(get_coordinates);
    

    I used

    my_table

    as the table name

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have two table like this table_CN (_id, name, phone, favorite, title) table_EN (_id,
I have a table in my database representing releases of software; the relevant columns
I have two tables (well, two relevant for this question) : Bets (holds the
I have a table with two decimal(18,0) fields. I am inserting into this table,
I have a table with two columns and one row, and 100% width across
I have a table with two columns: column A column B 1 2 1
I have a table with two columns, GroupId and ParentId (both are GUIDS). The
I have two tables like these: CREATE TABLE people ( id INT NOT NULL,
UPDATE This problem is not relevant anymore for data.table versions 1.8.0 and higher. From
I have to render a complex table with variable number of columns. In this

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.