Is it possible to fill a table with the result of the active query?

I try to get the content of the cursor c in the ap variable and the code I use is as follows:

BEGIN
DECLARE
TYPE cur_typ IS REF CURSOR;
c cur_typ;
query_str VARCHAR2 (1000);
work VARCHAR2 (1000);
AP varchar2 (30000);
to the varchar2 (30000);
query varchar2 (30000);
BEGIN
query_str: = ' select ent_cod, ent_nom from grh_funcionarios where rownum < 10';
query: = 'CURSOR c IS' |' select ent_cod, ent_nom from grh_funcionarios where rownum < 10';
IMMEDIATE EXECUTION of the query;

C OPEN FOR query_str;
for ap loop query_str
LOOP
Fetch c ap;
EXIT WHEN c % NOTFOUND;
DBMS_OUTPUT. Put_line(àles);
END LOOP;
C CLOSE;
END;
END;

I'll show you a basic approach to the dynamic approach refcursor. But you have to do a lot of work in order to customize it to your needs.

Here is a demonstration of basic->

satyaki>
satyaki>select * from v$version;

BANNER
----------------------------------------------------------------
Oracle Database 10g Enterprise Edition Release 10.2.0.3.0 - Prod
PL/SQL Release 10.2.0.3.0 - Production
CORE    10.2.0.3.0      Production
TNS for 32-bit Windows: Version 10.2.0.3.0 - Production
NLSRTL Version 10.2.0.3.0 - Production

Elapsed: 00:00:00.22
satyaki>
satyaki>
satyaki>DECLARE
  2     str         VARCHAR2 (30000);
  3
  4     cursor c1
  5     is
  6       select column_name
  7       from all_tab_columns
  8       where table_name = upper('&tab_nm')
  9       and   column_name = 'ENAME';
 10
 11     r1 c1%rowtype;
 12  BEGIN
 13     str := ' declare '||
 14            '   TYPE cur_typ IS ref cursor; '||
 15            '   c           cur_typ; '||
 16            '   query_str   VARCHAR2 (1000); '||
 17            '   gen_rec '||upper('&tab_nam')||'%rowtype; '||
 18            ' begin '||
 19            '  query_str := '||chr(39)||'select * from emp where rownum < 10'||chr(39)||'; '||
 20            '  OPEN c FOR query_str; '||
 21            '  LOOP '||
 22            '    FETCH c INTO gen_rec; '||
 23            '     EXIT WHEN c%NOTFOUND; ';
 24            for r1 in c1
 25            loop
 26      str := str||'   DBMS_OUTPUT.put_line (gen_rec.'||r1.column_name||'); ';
 27            end loop;
 28      str := str||'  END LOOP; '||
 29            '  CLOSE c; '||
 30            ' end; ';
 31
 32     execute immediate(str);
 33     --dbms_output.put_line(str);
 34  END;
 35  /
Enter value for tab_nm: emp
old   8:      where table_name = upper('&tab_nm')
new   8:      where table_name = upper('emp')
Enter value for tab_nam: emp
old  17:           '   gen_rec '||upper('&tab_nam')||'%rowtype; '||
new  17:           '   gen_rec '||upper('emp')||'%rowtype; '||
SATYAKI
SOURAV
WARD
JONES
MARTIN
BLAKE
CLARK
SCOTT
KING

PL/SQL procedure successfully completed.

Elapsed: 00:00:00.16

Hope this will give you a basic idea.

Kind regards.

LOULOU.

Tags: Database

Similar Questions

  • Fill a table with the results of the refresh groups

    Hello world

    I need a little help.

    I'm working on an Oracle 10.2.0.4 on windows.

    I have a table I created like this:
    Table name: DIM_REPLICA

    COD_SEZ VCHAR2 (2)
    NOME_SEZ VCHAR2 (20)
    FLAG TANK (1)
    DATE OF D_REPLICA

    This DB I have 210 discount groups running every night. I need fill this table with the results of the refresh groups.

    So when the refresh for example called ROME group runs I need to write on the table the name ROME in the field "NOME_SEZ", a Y or N if the refresh Group has worked in the field of the INDICATOR and LAST_DATE refresh force ran into the field of the D_REPLICA. The COD_SEZ field is a code that I get other things. It is not necessary for the moment. I can add it myself on my own.

    Can someone help me please?

    I was looking on the tables SYS DBA_JOBS and DBA_REFRESH these data, but I don't know what to take and how to fill the table. Trigger? Procedure? Any help will be great!

    Thank you all in advance!

    This forum is for SQL * PLus, questions and your question is about general issues Oracle. You will get a better response by posting your question in another forum - probably the General database instance.

    Please close this thread and start over in another forum.

  • It is possible to have two tables with the same name in Oracle!

    Oracle Version: 10 gr 2

    MS Access 2007, I had to use the 'Export' by which I copy a table (and its data) to an Oracle schema via an ODBC connection. Later, I realized that, during the copy of tables with a mix of lower and upper case names, the table does not copied (exported). But MS Access will give you the message that table obtained export successfully.

    MS-Access mess around Oracle data dictionary.

    When you issue
    SQL>select * from tab;
    
    TNAME                          TABTYPE  CLUSTERID
    ------------------------------ ------- ----------
    AMStates                       TABLE
    Version                        TABLE
    You will see the names of the tables. But when you try to DESCRIBE or SELECT this table, you will
    SQL>desc Version
    ERROR:
    ORA-04043: object Version does not exist
    You can even create another table with the same name in the schema
    SQL>create table VERSION (X NUMBER);
    
    Table created.
    Why this is happening and how can I bring these items 'non-existent '?

    Hello

    Use

    SQL > desc 'Version '.

    Or

    SQL > select * from 'Version '.

    Or

    SQL > drop table 'Version '.

    To overcome the problems of mixed-case.

  • AF:table with the search query present bindvariable name in the filter text field

    I created a simple display with a criterion of the view object. The criteriy defines a group with 4 criteria. Each element of the criteria has a STARTSWITH operator and compare a column to a binding parameter. The binding variable is marked as optional.
    Then I move the data control named on my page and selected criteria "Read - Only ADF filtered table"

    When the page is displayed to the user, I had the table containing the search field in the header.
    Unfortunately, the entry to the filter of the table fields are not empty, but containing the name of the connection variable.

    text in a filter for GebeCode: VarGebeCode *.
    text in a filter for NiedCode: VarNiedCode *.
    ...

    When the user just wants to filter on a property, for example GebeCode, the user must
    (1) type in the GebeCode
    (2) delete the input for other filter box filter: NiedCode,...
    Step 2 is heavy, but if the user does not specify an empty text in the filter, no lines are selected in the query.

    1 question
    How can I get the boxes of entry filter empty the first time the page is loaded?

    2 question
    As see you in the criteria listed below, I put the box "Ignoe box" (-> UpperColumns = '1') to make my case insensitive search.
    How ever, it does not work: it is always case sensitive.

    How can I get the framework to do things?


    It is the resuling query where clause:
     ( ( ( UPPER(MITA_NAME_VORNAME_CODE) LIKE UPPER( :VarMitaNameVornameCode || '%')  )  OR  ( :VarMitaNameVornameCode IS NULL ) ) 
    AND ( ( UPPER(MITA_CODE) LIKE UPPER( :VarMitaCode || '%')  )  OR  ( :VarMitaCode IS NULL ) ) 
    AND ( ( UPPER(GEBE_CODE) LIKE UPPER( :VarGebeCode || '%')  )  OR  ( :VarGebeCode IS NULL ) ) 
    AND ( ( UPPER(NIED_CODE) LIKE UPPER( :VarNiedCode || '%')  )  OR  ( :VarNiedCode IS NULL ) ) ) 
    Code MitarbeiterViewRVOCriteria
      <ViewCriteria
        Name="MitarbeiterViewRVOCriteria"
        ViewObjectName="model.mitarbeiterDetails.view.MitarbeiterViewRVO"
        Conjunction="AND">
        <Properties>
          <CustomProperties>
            <Property
              Name="displayOperators"
              Value="InAdvancedMode"/>
            <Property
              Name="autoExecute"
              Value="false"/>
            <Property
              Name="allowConjunctionOverride"
              Value="true"/>
            <Property
              Name="showInList"
              Value="true"/>
            <Property
              Name="mode"
              Value="Basic"/>
          </CustomProperties>
        </Properties>
        <ViewCriteriaRow
          Name="vcrow12"
          UpperColumns="1">
          <ViewCriteriaItem
            Name="MitaNameVornameCode"
            ViewAttribute="MitaNameVornameCode"
            Operator="STARTSWITH"
            Conjunction="AND"
            Value=":VarMitaNameVornameCode"
            IsBindVarValue="true"
            Required="Optional"
            UpperColumns="1"/>
          <ViewCriteriaItem
            Name="MitarbeiterViewRVOCriteria_vcrow12_MitaCode"
            ViewAttribute="MitaCode"
            Operator="STARTSWITH"
            Conjunction="AND"
            Value=":VarMitaCode"
            IsBindVarValue="true"
            Required="Optional"
            UpperColumns="1"/>
          <ViewCriteriaItem
            Name="MitarbeiterViewRVOCriteria_vcrow12_GebeCode"
            ViewAttribute="GebeCode"
            Operator="STARTSWITH"
            Conjunction="AND"
            Value=":VarGebeCode"
            IsBindVarValue="true"
            Required="Optional"
            UpperColumns="1"/>
          <ViewCriteriaItem
            Name="NiedCode"
            ViewAttribute="NiedCode"
            Operator="STARTSWITH"
            Conjunction="AND"
            Value=":VarNiedCode"
            IsBindVarValue="true"
            Required="Optional"
            UpperColumns="1"/>
        </ViewCriteriaRow>
      </ViewCriteria>
    Edited by: Stefan1979 the 06.11.2009 20:45

    Hello

    the case sensitive search is controlled by the 'filterFeatures' on the af: column. Due to a bug that is fixed in the next Patch set 1 of JDeveloper 11 g R1, that the search is always case-sensitive.

    Frank

  • Possible to Exchange temporary table with composite range-hash partitioned table?

    Hello

    Using oracle 11.2.0.3

    We want to clean up the data in some of our existing partitioned table.

    Afetr updates check spped that is too slow for us.

    Current table is partitioned the inetrval compoiste range-hash table.  Also it is compressed - enabled for compression of basis as well

    An interval of 1 month and 1 partition by month and 4 secondary partitions in the partition of ecah.

    You want to create tenp table with the data of celan and exchange the data in this table in the 'dirty' uisng existing partitions partition exchnage.

    Is this possible?

    The plan is

    1) create temporary table containing data for 1 partition (1 month worth of data)

    (2) clean the data here

    (3) create new temporary table with these specific data which compressed and discovered partitioned with 4 secondary partitions

    (4) table 3 for swap partition dirty using partition excahnge.

    Thaks

    I think that this can be done with a combination of Exchange and Split partition partitions. Prior to Oracle 11 g, only way of redefining tables online was DBMS_REDEFINITION package. Now, you can redefine the use of partitions for Exchange & Split. Check

    http://www.Oracle-base.com/articles/Misc/partitioning-an-existing-table-using-Exchange-partition.php

    Maintenance of Partitions

    Kind regards

  • Fill a table with date values with a fixed increment

    Hello

    I want to fill a table with a date column with the increment of a fixed value date values. The start date is selectable, the increment is selectable and the number of records is adjustable as well.
    For example
    start date is 1905-Jan-02, 15:00 (DD-MON-YYYY, HH24:MI:SS)
    increment is 1 hour and 5 minutes
    None. records is 10
    then the dates in the table must be
    REC 1 1905 - Jan - 02, 15:00
    REC 2 1905 - Jan - 02, 16:05
    REC 3 1905 - Jan - 02, 17:10
    ....
    REC 9 1905 - Jan - 02, 23:40
    REC 10 1905 - Jan - 03, 00:45:00

    We are working on 11 GR 2, the number of records can be between a few hundred and a few million and they must be ordered with Crescent of time (maybe to have a whole id).
    Any ideas how to fill this table (simple and fast?) using sql / plsql are welcome.

    Thanks, Hannes

    Something along the lines of:

    SQL> alter session set nls_date_format = 'YYYY-Mon-DD HH24:MI:SS';
    
    Session altered.
    
    SQL> select trunc(sysdate,'HH')+((rownum-1)*(1/24)*(65/60)) as dt
      2  from dual connect by rownum <= 20;
    
    DT
    --------------------
    2010-Aug-26 16:00:00
    2010-Aug-26 17:05:00
    2010-Aug-26 18:10:00
    2010-Aug-26 19:15:00
    2010-Aug-26 20:20:00
    2010-Aug-26 21:25:00
    2010-Aug-26 22:30:00
    2010-Aug-26 23:35:00
    2010-Aug-27 00:40:00
    2010-Aug-27 01:45:00
    2010-Aug-27 02:50:00
    2010-Aug-27 03:55:00
    2010-Aug-27 05:00:00
    2010-Aug-27 06:05:00
    2010-Aug-27 07:10:00
    2010-Aug-27 08:15:00
    2010-Aug-27 09:20:00
    2010-Aug-27 10:25:00
    2010-Aug-27 11:30:00
    2010-Aug-27 12:35:00
    
    20 rows selected.
    
  • LOV cascading if I don't have only one table with the customer name and the name of the product in the ADF.

    Hi Please help me how to use cascade, if I don't have only one table with the customer name and the name of the product in the ADF... I use Jdeveloper 11.1.

    For the client, I used customer VO with client list to fill but to populate the product that I use bind variable PrODUCT_NAME select distinct from TABLE where client_name =: bindCustomer

    so first of all, I need to set the variable of liaison on behalf of the selected customer.

    Can you please tell me how to set this variable binding in this case.

    After you set the LOV to your product attribute, correspondting VO in the LOV will appear under view accessors.

    Change the accessor of the view, you will see the variable binding. Set its value to the customer field of the parent object.

    Visit this link: https://www.youtube.com/watch?v=nXwL2_RP7AQ

    Kind regards

    Elias.

  • How the values to insert into the table with the command insertion

    Dear all
    can someone tell me how the values to insert into the table with the command insert, I want to say I always use command insert behind my forms on what shutter release button press the button of my save, but today I had a form of 6i, where controls (textbox, combo, etc.) are delineated with directly the table with I guess than the Properties Windows , I created 3 columns in tand 3 text on forms fields, now kindly tell me how to do this fields to fill and do not insert command, I mean directly defined with table column



    Please help me its urgent

    Hello

    If the block is based on your database table, just committed the shape, then changes will be applied to the database.

    François

  • OWB, I need to update the target table with the same field for game/update

    OWb, I try to update the target table with the game and the update on the same ground is this possible. I'm a match merge error indicating that you cannot update and match on the same ground. But in SQl is my selection

    Update table
    define RFID = 0
    where RFID = 1
    and ID_processus = 'TEST '.

    Can HWO I do this in OWB.

    I have check but in the case later (last one) that he warns no error if you can go with it.
    and I tested it it works

    You can check the first case (from where we start) if it has been warned and then try to run.

  • Hello! Pro iPad comes with a specific set of fonts in Keynote? Or is it possible ad fonts, for example with the font book?

    Hello! Pro iPad comes with a specific set of fonts in Keynote? Or is it possible ad fonts, for example with the font book?

    This is a list of the fonts installed in iOS 7, as far as I know, it has not changed for iOS 9.

    iOS 7: List fonts - Apple Support

    Fonts are embedded in the iOS, a few Apps will bring new fonts when loading the application. Keynote will use those that are pre-loaded with iOS. There are third-party fonts that can be installed, but you will need to check that they are working with the speech of the seller of these fonts.

  • kindly tell how to use the unique value of a table with the index 0

    kindly tell how to use the unique value of a table with the index 0

    Hi
     
    Yep, use Index Array as Gerd says. Also, using the context help ( + h) and looking through the array palette will help you get an understanding of what each VI does.
     
    This is fundamental LabVIEW stuff, perhaps you'd be better spending some time going through the basics.
     
    -CC
  • How is it possible to specific your own, with the constant help of string to locate a directory where the NEW

    How is it possible to specific your own, with the constant help of string to locate a directory where the NEW
    created the folder to save?


  • Is it possible to load your phone with the Office using the cord with head phone the ends of both sides?

    Is it possible to load your phone with the Office using the cord with head phone the ends of both sides?

    No, only USB.

    Taken head phones don't have any power.

  • is it possible to syncp a calendar with the calendar app ical surface?

    is it possible to syncp a calendar with the calendar app ical surface?

    Add your Gmail mail or calendar. His how:

    http://Windows.Microsoft.com/en-us/Windows-8/calendar-FAQ

    Kate

  • The Captivate offers the possibility of Visual highlighting, synchronized with the audio text?

    The Captivate offers the possibility of Visual highlighting, synchronized with the audio text?

    I knew what that s what I was asking the first question, not possible sorry!

Maybe you are looking for