Results 1 to 5 of 5

Thread: How to???

  1. #1
    Join Date
    Oct 2003
    Location
    Mumbai,India.
    Posts
    36

    Question Unanswered: How to???

    Hi friends,
    How can i get the a column's values of one table as column headings of another table?

    i.e :
    Table a is like this,

    A1 A2 A3
    -----------
    X1 Y1 Z1
    X2 Y2 Z2
    X3 Y3 Z3

    Then,table b should have like this,

    Y1 Y2 Y3
    ----------

    Please help me to resolve this.
    Thanks for your time and efforts.

  2. #2
    Join Date
    Oct 2003
    Posts
    26

    Re: How to???

    Do you want to create a table b with its columns as Y1, Y2, Y3 ?

  3. #3
    Join Date
    Oct 2003
    Location
    Mumbai,India.
    Posts
    36
    Ya exactly

  4. #4
    Join Date
    Oct 2003
    Location
    Mumbai,India.
    Posts
    36
    Is it possible to write a PL/SQL block for this?

  5. #5
    Join Date
    Oct 2003
    Location
    Mumbai,India.
    Posts
    36
    Is it possible to implement this by following method?

    CREATE OR REPLACE PROCEDURE {procedure name}
    ( {argument} IN {datatype} )
    IS

    v_A1 A.A1%TYPE;
    v_A2 A.A2%TYPE;
    v_A3 A.A3%TYPE;

    BEGIN

    --Start (see my comments below)
    -- Select the column values of the table A into variables v_A1,v_A2,v_A3
    SELECT A1, A2, A3 INTO v_A1,v_A2,v_A3 FROM A;

    --Use these variables into create table syntax
    CREATE TABLE "<schema name>".B (v_A1 <DEFINE your data type>,
    v_A2 <DEFINE your data type>,
    v_A3 <DEFINE your data type> );
    --End (see my comments below)

    END {procedure name};


    The code between --Start and --End has to be done for all the rows in table A. So fetch all the records of the rows into a cursor and fetch one by one and execute select and create statements for them.

    please...

Posting Permissions

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