Column names dynamically in Dynamic SQL

Hi All,
We can use Table Name dynamically in Dynamic SQL.
Can we use column names dynamically?
Thanks,
Umasankar

Hi Todd Barry,
Thanks lot for your immediate response.
Could you please tell me, how can we use column name dynamically?
I tried but, I didnt get the correct result.
Here is my coding.
Declare
SQL_String Varchar2(2000);
Category varchar2(50):= 'ELECTRO_PLATING_413';
Type ConstCurTyp is REF CURSOR;
Const_Cv ConstCurTyp;
vLab_name varchar2(80);
Begin
Execute Immediate 'Truncate table tto_lab_names';
dbms_output.put_line(category);
dbms_output.put_line(' ');
SQL_String := 'Select lab_name from tto_constituents where :category is not null';
Open Const_cv for SQL_String using category;
Loop
Fetch Const_Cv into vLab_Name;
Exit When Const_Cv%NotFound;
Insert into lab_names values(vLab_name);
End Loop;
Commit;
Close Const_Cv;
End;
I am getting all the lab_names as result.
Thanks,
Umasankar
null

Similar Messages

  • HTML DB Chang column name dynamically

    Can I change the column name dynamically. for instance
    Today run my apply it will display the title of the columns this
    Column title: Wed Thu Fri
    04/22/05 04/23/05 04/24/05
    Data 45 34 34
    54 56 23
    Next week
    Column title: Wed Thu Fri
    05/03/05 05/04/05 05/05/05
    45 34 34
    54 56 23
    The date Change Dynamically?

    Go to your report and open report atributes. There you can choose the options for column names. Click on the pl/sql function and type this in:
    DECLARE v varchar2(20);
    begin
    v := to_char(SYSDATE, 'dd.mm.yy')||':'||to_char(SYSDATE+1, 'dd.mm.yy');
    RETURN v;
    END;
    This will set the first two columns to the specified dates. You can use this as one option.
    If the case is more complicated than you can do the following:
    1. create a number of items on your page - hidden
    2. compute the items with values once the page is loaded
    3. use item substitute string &ITEM. in the column name, which will use the item value as a name for the column.
    This way you are more flexible since you can use the item values for some columns only and have the other columns hardcoded.
    Denes Kubicek

  • Execute immediate with using clause to pass column name dynamically

    Hai,
    Is there any way using execute immeidate to pass the column name dynamically. I used to pass the column value as dynamic with the help of "Using clause" . But if i use to pass column name, it is giving numberic error at run time. Eg,. for testing has been given below.
    1. Column value as dynamic, which is working correctly.
    create or replace function testexeimm (acctnum char)
    return number as
    acctbal number;
    begin
    execute immediate 'select balance from acct_master where acct_no=:a' into acctbal using acctnum;
    return acctbal;
    end;
    2. Column name as dynamic which is not working
    create or replace function testexeimm (colnam char)
    return char as
    acctbal char;
    begin
    execute immediate 'select :a from ch_acct_mast where rownum=1' into acctbal using colnam;
    return acctbal;
    end;
    Any help in this regard will be highly appericated.
    Regards
    Sridhar

    So the variable has to be numeric too:
    create or replace function testexeimm (colnam char)
    return number as
    acctbal number;
    begin
    execute immediate 'select '|||colnam||' from ch_acct_mast where rownum=1' into acctbal;
    return acctbal;
    end;Max
    http://oracleitalia.wordpress.com

  • Getting the column names dynamically

    hi gurus,
    i have list item populated with many table names from a schema.
    i have grid in oracle forms 10g and i want to fill the grid with the data that should come at least four/more columns.
    i want to fire the list change trigger when each time any one table name is selected/changed.
    how can i get the column names dynamically
    please give me the step by step process
    for filling the grid..

    hi ,
    by getting column names dynamically i am creating a record group
    using this below query
    SELECT COLUMN_NAME, DATA_TYPE FROM USER_TAB_COLUMNS WHERE TABLE_NAME = <table_name>
    but when timestamp datatype is there then it is showing error cannot create group groupname
    but the record group is running successful on varchar2,number,date dayatypes
    if any alternative is there i mean to say without using record group then tell me or where is the problem

  • Pass column names dynamically in report

    Hello experts,
    I am creating an ALV report where i need to pass the column names dynamically. if the current month is March and year is 2009. the column names should be as below
    March 2009 April 2009 May 2009 June 2009 ..............till Feb 2010 (total columns are 12)
    if the current month is June and year is 2010 it shoud be displayed as
    June 2010 July 2010 Aug 2010................till May2011
    I am actually calculating the forecast qty for each month and displaying in a report from the current month.
    How to write field catelog for this requirement?
    Thanks in Advance.
    Rajesh.

    I think in the fieldcat, at the time of declearation, you can alter the field description depending on the present month.
    If present_month = January
    wa_fieldcat-reptext_ddic = 'January'.       " Field description
    elseif present month = February.
    wa_fieldcat-reptext_ddic = 'February'.       " Field description
    on so on.....................
    Kuntal

  • Using column names dynamically in Trigger

    Hello Everyone,
    I want to use a trigger for my application in which column names will be provided dynamically rather than hard coded. i.e. for ex. I want to have foll. code
    Execute Immediate
    'Begin
    dbms_output.put_line'' ' &#0124; &#0124; :new.col_name &#0124; &#0124; ' ''); End; ';
    where in ":new.col_name" col_name will be replaced dynamically. so if any of you can tell me how to achive this I will be thankful to you. Hoping for the best.
    Regards
    -Heena

    My advise will be to think about using dynamic PL/SQL.

  • Referring to Cursor Row and Column in Dynamic SQL

    I have a procedure that dynamically reads a schema name and table name from an input table. The code then needs to loop through all rows and columns of each table and output the data. I'm 95% done with what I want to accomplish, but there is one small bug. The line dbms_output.put(*col.column_name* || '',''); ' ||
    should refer to something like rec.col.column_name so that it gets the column of the current record. Right now it just displays the column name for each record instead of the actual value. Can anyone help me tweak the code to get the actual value?
    CREATE OR REPLACE PACKAGE BODY some_proc IS
    -- Function and procedure implementations
    PROCEDURE create_files IS
    CURSOR c_tbls IS
    SELECT * FROM tbl_list;
    l_sql VARCHAR2(4000);
    BEGIN
    --Loop through all tables
    FOR tbl IN c_tbls LOOP
    l_sql := 'DECLARE ' || ' CURSOR c_tbl_recs IS ' || ' SELECT * ' ||
    ' FROM ' || tbl.schema_name || '.' || tbl.table_name || '; ' ||
    ' t_tbl_rowtype c_tbl_recs%ROWTYPE; ' || 'BEGIN ' ||
    ' FOR rec IN c_tbl_recs LOOP ' ||
    ' FOR col IN (SELECT column_name ' ||
    ' FROM dba_tab_cols ' ||
    ' WHERE owner = ''' || tbl.schema_name || '''' ||
    ' AND table_name = ''' || tbl.table_name || '''' ||
    ' ORDER BY column_id) LOOP ' ||
    *' dbms_output.put(col.column_name || '',''); ' ||* ' END LOOP; dbms_output.put_line(''''); END LOOP; ' ||
    'END; ';
    --dbms_output.put_line(l_sql);
    EXECUTE IMMEDIATE l_sql;
    END LOOP;
    EXCEPTION
    WHEN OTHERS THEN
    dbms_output.put_line(SQLERRM);
    END;
    END;

    Is it this what you are looking for?
    (it took some minutes)
    create or replace
    package some_proc is
    procedure create_files;
    end;
    CREATE OR REPLACE
    PACKAGE BODY some_proc
    IS
      -- Function and procedure implementations
    PROCEDURE create_files
    IS
      CURSOR c_tbls
      IS
        SELECT * FROM tbl_list;
      CURSOR c_cols (p_table_owner VARCHAR2, p_table_name VARCHAR2)
      IS
        SELECT column_name
        FROM all_tab_columns
        WHERE owner   =p_table_owner
        AND table_name=p_table_name
        ORDER BY all_tab_columns.column_id;
      l_sql     VARCHAR2(32000);
      separator VARCHAR2(1):=';';
    BEGIN
      --Loop through all tables
      FOR tbl IN c_tbls
      LOOP
        dbms_output.put_line('TABLE: '||tbl.schema_name||'.'||tbl.table_name);
        l_sql := 'DECLARE ' ;
        l_sql := l_sql|| '  CURSOR c_tbl_recs IS ' ;
        l_sql := l_sql||'    SELECT * FROM ' || tbl.schema_name || '.' || tbl.table_name || '; ' ;
        l_sql := l_sql||'    linenr number:=1; ';
        l_sql := l_sql||'BEGIN ' ;
        l_sql := l_sql|| ' FOR rec IN c_tbl_recs LOOP ';
        FOR c IN c_cols(tbl.schema_name,tbl.table_name)
        LOOP
          l_sql:=l_sql ||' if linenr=1 then  dbms_output.put('''||c.column_name||''||separator||'''); end if; ' ;
        END LOOP;
        l_sql :=l_sql||'  dbms_output.put_line(''''); linenr:=linenr+1; ';
        FOR c IN c_cols(tbl.schema_name,tbl.table_name)
        LOOP
          l_sql:=l_sql ||' dbms_output.put(rec.'||c.column_name||'||'''||separator||'''); ' ;
        END LOOP;
        l_sql:=l_sql||'  end loop; ';
        l_sql:=l_sql||'  dbms_output.put_line(''''); ';
        l_sql:=l_sql||'  dbms_output.put_line(''''); ';
        l_sql:=l_sql||'end;';
        EXECUTE IMMEDIATE l_sql;
      END LOOP;
    EXCEPTION
    WHEN OTHERS THEN
      dbms_output.put_line(SQLERRM);
    END;
    END;
    /

  • Script task to read the column names dynamically and create a table in database based on excel column structure

    Hello,
    Can anyone help me out to write a vb.net script.
    I need to read the column names from excel and based on that column names I need to create a table in database(I have more than one sheet in excel).
    For each sheet columns will be changing and should create a table dynamically for each sheet.
    Any help would be appreciated.

    Refer the below script to read columns in each sheet.
    Dim excelfile As String = Dts.Variables("ExcelPath").Value.ToString
    Dim connectionstring As String = "Provider=Microsoft.Jet.OLEDB.4.0;" +
    "Data Source=" + excelfile + ";Extended Properties=Excel 8.0"
    Dim oledbcon As New OleDb.OleDbConnection(connectionstring)
    oledbcon.Open()
    Dim dt As DataTable
    Dim schemaTable As DataTable
    Dim OLEDBCMD As New OleDb.OleDbCommand
    Dim oledbdatareader As OleDb.OleDbDataReader
    Dim columns As String = ""
    dt = oledbcon.GetSchema("Tables")
    Dim TABCOMMAND(20) As String
    Dim TABCOUNT As Integer = 0
    For Each row As DataRow In dt.Rows
    TABCOMMAND(TABCOUNT) = "SELECT * FROM [" & row.Item("TABLE_NAME").ToString & "]"
    OLEDBCMD.CommandText = TABCOMMAND(TABCOUNT)
    OLEDBCMD.Connection = oledbcon
    oledbdatareader = OLEDBCMD.ExecuteReader(CommandBehavior.KeyInfo)
    schemaTable = oledbdatareader.GetSchemaTable()
    For Each myfield As DataRow In schemaTable.Rows
    For Each myproperty As DataColumn In schemaTable.Columns
    If myproperty.ColumnName = "ColumnName" Then
    columns = columns & myfield(myproperty).ToString & ","
    MsgBox(myfield(myproperty).ToString)
    End If
    Next
    Next
    oledbdatareader.Close()
    OLEDBCMD.Dispose()
    Next
    oledbcon.Close()
    Regards, RSingh

  • Why do I get a class conflict between the Prepare SQL.vi and the Get Column Name.vi with the SQL Toolkit compatibility vis from the Database Connectivity Toolkit?

    I have done extensive programming with the SQL Toolkit with LabVIEW versions through 6.1. My customer now wants to upgrade to Windows 7, so I am trying to upgrade to LabVIEW 2009 (my latest purchased version) using the Database Connectivity Toolkit, and the SQL Toolkit Compatibility vis. Everything seemed to be going okay with the higher level SQL operations, but I ran into trouble with the Get Column Name.vi. 
    The pictures below show the problem. The original SQL Toolkit connected the Prepare SQL.vi with the Get Column Name.vi with a cluster of two references, one for connection, and one for sql. The new compatibility vis have a class conflict in the wire because the Prepare SQL.vi contains a cluster with connection, and command references, but the Get Column Name.vi expects a cluster with connection and recordset references. 
    How do I resolve this conflict?
    Thank You.
    Dan

    I've never worked with the old version of the toolkit, so I don't know how it did things, but looking inside the SQL prep VI, it only generates a command, and the the column name VI wants a recordset. I'm not super familiar with all the internals of ADO, but my understanding is that is standard - you only have the columns after you execute the command and get the recordset back. What you can apparently do here is insert the Execute Prepared SQL VI in the middle and that will return what you need.
    I'm not sure why it worked before. Maybe the execute was hidden inside the prep VI or maybe you can get the column names out of the command object before execution. In general, I would recommend considering switching to the newer VIs.
    Try to take over the world!

  • Column name in link on sql report?

    Hey guys -
    Is there some way to put the column name of a report in a link?
    When you define a link on a column you have the ability to use a substition string for the VALUE of a particular column... but I want to somehow pass the string value of the column.... anyone know how to do this?
    Thanks

    Not the value of the column.. I want the actual column name...
    i.e.
    Items on page to set:
    txtbox1
    txtbox2
    Query:
    Channel          INS1     INS2     INS3     INS4
    Retail          13     1     333     55
    Wholesale     4234     23     1     44Okay, so I want to make a link on the values in the query (the #'s) to set the values of the txtboxes...
    example would be if I click on 333 I want it to set txtbox1="Retail" and txtbox2="INS3"
    The channel one is fine I just use the substition string of #COL1# in the link and it replaces the value... but nothing that I can find on how ot set txtbox2="INS3"
    Edited by: nferreri on May 15, 2009 9:51 AM

  • Help needed in making table name and column name dynamic

    please check the below query? in the below message
    Message was edited by:
    460425
    Message was edited by:
    460425

    thanks Dmytro,
    below is the script i was looking for it got it..any way thanks.
    just need to replace dbms_output.put_line with utl_file.put_line
    to put the code on server directory.
    and execute as and when required.
    Reg.
    AAK
    CREATE OR REPLACE PROCEDURE p_ad_log
    IS
         CURSOR tbl_cursor IS
              SELECT table_name FROM user_tables WHERE table_name IN('EMP','EMP1') ;
         CURSOR col_cursor( cp_table_name varchar2) IS
              SELECT column_name FROM user_tab_columns WHERE table_name=cp_table_name;
         --v_file_handle      utl_file.file_type;
         --v_file_dir          varchar2(30)      :=     'DIRECTORY PATH'     ';
         --v_file_name     varchar2(30)       :=       'AD_TRIGGER_TEXT.TXT';
         tbl_cursor_value     tbl_cursor%ROWTYPE;
         col_cursor_value     col_cursor%ROWTYPE;
         v_string          varchar2(4000);
         v_string_val     varchar2(4000);
    BEGIN
         DELETE audit_triggers_status;
         COMMIT;
         --v_file_handle := utl_file.fopen(v_file_dir,v_file_name,'W',32000);
         OPEN tbl_cursor;
         LOOP
              FETCH tbl_cursor into tbl_cursor_value;
              EXIT WHEN tbl_cursor%NOTFOUND;
              OPEN col_cursor(tbl_cursor_value.table_name);
              DBMS_OUTPUT.PUT_LINE( 'CREATE OR REPLACE TRIGGER' ||' ad_'||tbl_cursor_value.table_name); -- short name for audit trigger coz table name will be appended to it and result should not exceed 30 char
              DBMS_OUTPUT.PUT_LINE( 'BEFORE INSERT OR UPDATE OR DELETE ON '||tbl_cursor_value.table_name);
              DBMS_OUTPUT.PUT_LINE( 'FOR EACH ROW');
              DBMS_OUTPUT.PUT_LINE( 'BEGIN');
              v_string:='INSERT INTO'||' ad_'||tbl_cursor_value.table_name||'(';
              v_string_val:='values(';
              INSERT INTO audit_triggers_status( table_name,trigger_name,audit_flag) VALUES (tbl_cursor_value.table_name,' ad_'||tbl_cursor_value.table_name,'Y');
                   LOOP
                        FETCH col_cursor into col_cursor_value;
                        EXIT WHEN col_cursor%NOTFOUND;
                        v_string:=v_string||col_cursor_value.column_name||',';
                        v_string_val:=v_string_val||':new.'||col_cursor_value.column_name||',';
                   END LOOP;
                   CLOSE COL_CURSOR;
              v_string:=substr(v_string,1,length(v_string)-1);
              v_string_val:=substr(v_string_val,1,length(v_string_val)-1);
              v_string:=v_string||') ';
              v_string_val:=v_string_val||');';
              --DBMS_OUTPUT.PUT_LINE(v_string||v_string_val);
              DBMS_OUTPUT.PUT_LINE('IF INSERTING THEN');
              DBMS_OUTPUT.PUT_LINE('     '||v_string||v_string_val);
              DBMS_OUTPUT.PUT_LINE('END IF;');
              DBMS_OUTPUT.PUT_LINE('IF UPDATING THEN');
              DBMS_OUTPUT.PUT_LINE('     '||v_string||v_string_val);
              DBMS_OUTPUT.PUT_LINE('END IF;');
              DBMS_OUTPUT.PUT_LINE('IF DELETING THEN');
              --DBMS_OUTPUT.PUT_LINE('     '||v_string||REPLACE(v_string_val,':new.',':old.');
              V_STRING_VAL:=REPLACE(v_string_val,':new.',':old.');
              DBMS_OUTPUT.PUT_LINE('     '||v_string||v_string_val);
              DBMS_OUTPUT.PUT_LINE('END IF;');
              DBMS_OUTPUT.PUT_LINE('END '||' ad_'||tbl_cursor_value.table_name||';');
              DBMS_OUTPUT.PUT_LINE(' ');
         END LOOP;
         CLOSE TBL_CURSOR;
         COMMIT;
    END;

  • Need to return dynamic column names for a function returning nested table

    I am having a pl/sql function which is returning a nested table.
    For this i have defined an object which is having 4 attributes- 1 number type, 3 varchar2 type -p1,p2,p3.
    My function is taking input parameter v1,v2,v3 all of varchar2 type.Inside the function body,i am using these (v1,v2,v3) to filter data from an sql query and i am also
    using pivot function in this sql query.
    At the end my function is returning the object as defined in the starting .
    When i am excuting this function,thru select statement :
    select * from table(f1_test('A','B','C'));
    i am geting p1,p2,p3 as column name ,which are names used when i had defined object type.Instead i want column name to be dynamic (wotever i am passing in function as
    parameter while executing the function ,here A,B,C)
    Please help me in geting column names dynamic as passed in input parameter (i.e A,B,C for this case )
    Sample code for the problem:
    create or replace TYPE obj1 AS OBJECT
    ( id number(5,0)
    ,p1 varchar2(10),
    ,p2 varchar2(10)
    ,p3 varchar2(10)
    create or replace TYPE tt1 AS TABLE OF OBJ1;
    create or replace
    function f1_test (v1 varchar2,v2 varchar2,v3 varchar2)
    return tt1 as
    v_return tt1 ;
    v_str varchar2(30000);
    begin
    v_str:='
    select
    cast(
    multiset(
    select * from
    select
    aa.report_id
    ,cc.name
    ,e.amount
    from
    aa,cc,e
    where
    <join conditions>
    and cc.name in ('''||v1||''','''||v2||''','''||v3||''')
    pivot (sum (amount) for name in ('''||v1||''' as '||v1||','''||v2||''' as '||v2||','''||v3||''' as '||v3||'))
    as tt1)
    from
    dual';
    dbms_output.put_line(v_str);
    execute immediate v_str
    into
    v_return ;
    return v_return;
    end;
    Edited by: 845831 on 20 Mar, 2011 12:15 PM

    select id,p1 A,p2 B,p3 C from table(f1_test('A','B','C'));
    drop function f1_test;
    drop type tt1;
    drop type obj1;
    create or replace TYPE obj1 AS OBJECT
    ( id number(5,0)
    ,p1 varchar2(10)
    ,p2 varchar2(10)
    ,p3 varchar2(10)
    create or replace TYPE tt1 AS TABLE OF OBJ1;
    CREATE OR REPLACE
      FUNCTION f1_test(
          v1 VARCHAR2,
          v2 VARCHAR2,
          v3 VARCHAR2)
        RETURN tt1
      AS
        v_return tt1 ;
        v_str VARCHAR2(30000);
      BEGIN
        v_str:='select cast(multiset(select 1,''20'',''30'',''40'' from dual) as tt1) from dual';
        dbms_output.put_line(v_str);
        EXECUTE immediate v_str INTO v_return ;
        RETURN v_return;
      END;
    /

  • Dynamic column name

    hi experts,
      DATA: temp(20) VALUE 'DATA',
            i TYPE I VALUE 1,
            J(2) type c.
            LOOP AT l_t_tsi.
                     J = I.
                    CONCATENATE TEMP J INTO COLNAME.
                    itab-(COLNAME) = l_t_tsi-time_series_value.
                    i = i + 1.
          ENDLOOP.
    My internal table (itab) has fields data1(20), data2(20), data3(20)...
    I want to generate the column names dynamically only.
    The above code gives an error at this line -
                    itab-(COLNAME) = l_t_tsi-time_series_value.
    Thanks in advance,
    Bijal

    Hi,
    If your aim is to refer to a internal table field dynamically you can do it.
    Look at the code segment below -
    DATA: temp(20) VALUE 'DATA',
    i TYPE I VALUE 1,
    J(2) type c.
    FIELD-SYMBOLS: <ls_data>.
    LOOP AT l_t_tsi.
    J = I.
    CONCATENATE TEMP J INTO COLNAME.
    <b>ASSIGN COMPONENT colname OF itab TO <ls_data>.
    <ls_data> = l_t_tsi-time_series_value.</b>
    *itab-(COLNAME) = l_t_tsi-time_series_value.
    i = i + 1.
    ENDLOOP.
    Regards,
    Manish Joshi
    If it solves your problem, close the thread.
    Don't clutter-up forum by leaving open threads.

  • Dynamic SQL Pivoting(Converting Row to Columns)

    Hi All,
    I am using Oracle 9i (Oracle9i Enterprise Edition Release 9.2.0.1.0 - Production)
    and also 10g version
    I am facing difficulties to find out the logic for
    converting the set of values in one of the columns into the column headings for the entire query.
    create TABLE my_tab ( deptno VARCHAR2(5), job VARCHAR2(50), sal NUMBER);
    insert into my_tab ( deptno,JOB, sal) values ( 10, 'ANALYST', 23000);
    insert into my_tab ( deptno,JOB, sal) values ( 10, 'SALESMAN', 1500);
    insert into my_tab ( deptno,JOB, sal) values ( 10, 'CLERK', 3550);
    insert into my_tab ( deptno,JOB, sal) values ( 20, 'SALESMAN', 700);
    insert into my_tab ( deptno,JOB, sal) values ( 20, 'ANALYST', 4200);
    insert into my_tab ( deptno,JOB, sal) values ( 30, 'SALESMAN', 5600);
    insert into my_tab ( deptno,JOB, sal) values ( 30, 'CLERK', 12000);
    insert into my_tab ( deptno,JOB, sal) values ( 30, 'ANALYST', 19000);
    COMMIT;
    SELECT * FROM my_tab
    DEPTNO ______ JOB ________ SAL
    10 ______ ANALYST ________ 23000
    10 ______ SALESMAN     ________     1500
    10     _______ CLERK     ________     3550
    20     _______     SALESMAN ________     700
    20     _______     ANALYST     ________ 4200
    30     _______     SALESMAN ________     5600
    30     _______     CLERK     _______          12000
    30     _______ ANALYST     _______     19000
    --And I wish to convert it into this structure:
    DEPTNO ________ ANALYST ________ SALESMAN _________ CLERK
    10      ________     23000 ________     1500     _________     3550
    20     ________ 4200 ________     700     _________     NULL
    30     ________ 19000 ________     5600     _________     12000
    It may be dynamic. i.e Later i inserted more two records into My_tab.
    insert into my_tab ( deptno,JOB, sal) values ( 20, 'CLERK', 3400);
    insert into my_tab ( deptno,JOB, sal) values ( 30, 'MANAGER', 48000);
    So it should be dynamic.
    output is like this.
    DEPTNO ________ ANALYST ______ SALESMAN ______ CLERK ______ MANAMGER
    10           ________ 23000     ______ 1500     ______ 3550     ______     NULL
    20          ________ 4200     ______ 700     ______ 3400     ______     NULL
    30          ________ 19000     ______ 5600     ______ 12000     ______     48000
    Please help me regarding this.
    With warm regards,
    Prasanta

    Hi, Prasanta,
    Displaying one column from many rows as many columns on one row is called Pivoting . The following thread shows the basics of how to pivot:
    Help for a query to add columns
    That example uses the aggregate COUNT function; you'll want SUM (or possibly MIN or MAX) instead.
    Getting a dynamic number of columns requires Dynamic SQL . As a simpler alternative to pivoting and dynamic SQL, you might consider String Aggregation , where you concatenate a column from many rows into one big string, to be displayed on one row.
    See the following thread for more about string aggregation and other options on pivoting into a variable number of columns:
    Re: Report count and sum from many rows into many columns

  • RE: Dynamic SQL

    We are in fact using the back end of Express for database access with
    good success. We have built our own frameworks for the user interface
    and business policy.
    From:
    [email protected][SMTP:[email protected]]
    Sent: Tuesday, July 15, 1997 8:06 AM
    To: [email protected]
    Subject: Re: Dynamic SQL
    Mr. GB Khor <[email protected]> writes:
    Can I have a dynamic SQL which able to have dynamic column name,
    dynamic binding variable object, dynamic table name and dynamic
    where clause, e.g.
    select dynamic_field1, dynamic_field2 ... into
    :DynamicArrayOfObject from DynamicTableName where
    DynamicWhereClause
    Is that posible? Yes, in general. The main issue is that the dynamic select
    returns the data in a DBDataSet, and it's up to you to unpack it
    into the object(s) of your choice. The "Accessing Database"
    manual is reasonably clear on this, except that placeholders
    are covered under "insert", not "select". See pages 69-80 in the
    2.0 version of the manual (the sections titled "Using Forte
    Classes for Dynamic SQL", "Executing Prepared Select
    Statements", and "Executing Prepared Insert, Update, and Delete
    Statements").
    We're still wrestling with the best way to handle dynamic SQL. A
    class to do the unloading is pretty easy (details on request;
    it's probably too much to go into here). But managing the
    placeholders is (to me!) a bit more complicated. Forte Express
    has a whole slew of classes dedicated to dynamic SQL; we are
    told that if you have an adequate Express license that there is
    no legal reason why you can't use the Express dynamic SQL
    classes all by themselves. Whether this is practical is another
    matter.
    Tom Wyant

    To achieve something similar we have done the following:
    1. Dynamically create an SQL text string in memory and use the
    prepare(), openCursor(), fetchCursor(), closeCursor() methods on the
    DBSession object to execute this SQL text. OR
    2. If you wish to execute dynamically named stored procedures use the
    internal class qqdb_ProcDesc to execute different stored procedures with
    different arguments. To get a full description of how this is done you
    should ask Forte tech support for Tech Note # 10687 (Calling an Oracle
    Procedure Using a dynamic name).
    Hope this helps.
    Sanjay Murthi
    Indus Consultancy Services
    From: "Mr. GB Khor"
    Sent: Thursday, July 17, 1997 1:52 PM
    To: forte users
    Cc: murthis; thyagarajm; thyagarm; vasasm; chandraa
    Subject: Dynamic SQL
    MCI Mail date/time: Mon Jul 14, 1997 4:21 am EST
    Source date/time: Mon, 14 Jul 1997 16:41:03 -0800
    Can I have a dynamic SQL which able to have dynamic column name, dynamic
    binding variable object, dynamic table name and dynamic where clause
    e.g.
    select dynamic_field1, dynamic_field2 ... into :DynamicArrayOfObject
    from DynamicTableName where DynamicWhereClause
    Is that posibble?
    TQ
    My URL http://www.geocities.com/Hollywood/Lot/3985/
    BASS Consulting Sdn. Bhd.
    8th Floor, Menara SMI,
    6 Lorong P. Ramlee,
    50250 Kuala Lumpur,
    West Malaysia.
    Tel. (603) 2305588 ext 995
    Fax. (603) 2019403

Maybe you are looking for

  • My HP C309A all in one printer wireless radio is not functioning? It says contact HP support.

    using XP SP2 on computer that I want to hook up for wireless printing.  It was working but has stopped working. Wireless network test report says the wireless radio is not funcitoning.  Contact HP support. 

  • Problems with Mac OS X 10.5.4

    I started to use Macbook recently. I found three annoying problems with Leopard 10.5.4. 1) cannot shut down. I have to press the power button to shut down the machine. 2) cannot wake from sleep. After enter password in the login window, the screen be

  • Event trapping when the active document changes

    Hi all, Apologies if this question has been asked / answered before. I don't get out much. Is there any way, in ExtendScript, to get an event when the user brings a different document to the front? Something similar to the "beforeOpen" event, but whi

  • Get report of Automated jobs in mail

    Hi to all, How can I Get report of Automated jobs in mail.Like particular datafile is out of space.

  • Error loadjava xmlparserv2 pl/sql

    Ich versuchte den XMLParser (XML/PLSQL) xmlparserv2 sowie xmlplsql.jar in den JServer zu laden. Das Laden lief ohne Fehler ab, jedoch beim "resolven" der Klassen erhielt ich folgende Fehlermeldung: Referenziertes Object Scott.oracle/xml/parser/v2/XML