Dynamic SQL, dynamic table name with TPCV statement including the date

Hello

I just wanted to help with the following block of PL. My problem is when I try to run this block it ask to call the values for 2, even if no variable substitution replacement variables not present in the code. Please find the code below:


Declare
Cursor C_1 is
Single select table_name from gsi_daily_count;
table_names varchar2 (240);
Begin
C_1 open;
Loop
Extract the C_1 in table_names;
WHEN THE EXIT C_1% NOTFOUND;

EXECUTE IMMEDIATE "select last_extract_date,
TO_CHAR (min (largest (nvl (last_update_date,'| 1 January 10 |'), nvl (program_update_date,'| 1 January 10 |'))),'|) HH24:MI:SS DD-MON-YY |') MI,
TO_CHAR (max (greatest (nvl (last_update_date,'| 1 January 10 |'), nvl (program_update_date,'| 1 January 10 |'))),'|) HH24:MI:SS DD-MON-YY |') my
of ' | table_names | »
Last_extract_date group
order of last_extract_date desc';

End loop;
Close C_1;
COMMIT;
End;

Help, please.

Thanks in advance.

Try this:

Declare
cursor C_1 is
select unique table_name from user_tables;
table_names varchar2(240);
Begin
Open C_1;
Loop
Fetch C_1 into table_names;
EXIT WHEN C_1%NOTFOUND;

EXECUTE IMMEDIATE('select last_extract_date,
to_char(min(greatest(nvl(last_update_date,''01-Jan-10''),nvl(program_update_date,''01-Jan-10''))),''DD-MON-YY HH24:MI:SS'') mi,
to_char(max(greatest(nvl(last_update_date,''01-Jan-10''),nvl(program_update_date,''01-Jan-10''))),''DD-MON-YY HH24:MI:SS'') ma
from ' || table_names ||'
 group by last_extract_date
order by last_extract_date desc');

End Loop;
Close C_1;
COMMIT;
End; 

Tags: Database

Similar Questions

  • Is it possible to make the condition depending on the sql statements in the data models

    Hi all

    Is it possible to include the condition based on sql statements in the data models.

    For example
    if (some parameter is not null)
    <sqlstatement name="STATEMENT_1">
    ...
    </sqlstatement>
    else
    <sqlstatement name="STATEMENT_2">
    ...
    </sqlstatement>
    Is something like this? Also, the good doc is available for ' how to take full advantage of the "data models" in BI Publisher?

    Thank you
    -Sookie

    Hello Sookie,
    I couldn't find the time to get a data model of demonstration of work for you, but I'll try to explain.

    First, write a PL/SQL package. Make sure that you set all the parameters of model of data such as a global variable in the default PL/SQL package.

    CREATE OR REPLACE
    package as employee
    function BeforeReportTrigger return Boolean;
    query_text varchar (2000);
    number of p_DEPTNO;
    END;
    /

    CREATE OR REPLACE
    package as body employee
    function BeforeReportTrigger return Boolean IS
    Start

    IF (p_DEPTNO = 10) THEN
    query_text: = select col1, col2, col3 from HR.
    elsif (p_DEPTNO = 20) THEN
    query_text: = select col1, col2, col3 hr_history.
    on the other
    query_text: = select col1, col2, col3 hr_history1.
    end if;
    Returns true;
    end;
    /

    Use this package in the default package in your data model. Check the "defaultPackage ="employee"in the following data model header.

    Sample data model
    ------------------------------












    --
    --
    --
    --

    Before running the query SQL, data engine reads the "before the release of the report" and all the texte_requete argument based on the p_DeptNo value. When executing the Q1, engine sqlQuery analyze the query ' & quert_text and replace it with the actual value. For example if the p_deptno = 10, the query will be "select col1, col2, col3 from HR.

    Try it...

  • When you add pictures to the Vista image folder it creates a folder HIDDEN of the same name with two copies of the same image inside

    I use Vista 32 bit. I started to see this problem when I recently copy photos from an SD card.

    When you add pictures to the Vista image folder it creates a folder HIDDEN of the same name with two copies of the same image inside

    I saw hidden files enabled in folder options.

    Any help is appreciated.

    Hey guys... I found the answer... Problem is with the software vaio content analyzer that comes with the vaio...

    It just search for Vaio Content Analyzer (parameters) and deselect

    Video analysis
    image analysis
    analysis of the music

    I went looking for this crazy thing... used almost all types of online scan, and finally to find that it is caused by an internal software only...
    anyway thanks to all... Hope it helps someone in the future :)
  • Synchronization between two databases with only 2% of the data; Please help me

    Hi all

    I have two oracle databases in 2 different servers PROD and TEST instances. the two databases are in gr 10 2 in linux servers.

    My PROD database contains about 300 GB of data and is dedicated for production area.
    My Test database is dedicated to Spanish test for PROD database. (small server in terms of space and RAM comparing to PROD db)
    I would like to synchronize every week TEST db with PROD db with only 2% of the data and all the structures
    Could someone tell me, if you use a datapump export I can import only 2% of the amount of data and the structures ot theere is another way to do it?
    Thank you very much

    best regards,
    W

    I'm not really sure what you're talking about. There is no option, expdp and impdp x % of the data, is that? And if Oracle can sovle repositories inetegrity (PK, FK), it cannot be assumed which tables are lookup table (to be entirely exported) and can not assume the logical data integrity.

    Nicolas.

  • * Dynamic * Table name in the From Clause, with the help of the cursor

    Hello
    I said a slider...
    Select the table table_name from dba_tables where < blah >
    The result is
    Row1: emp
    rwo2: emp_1-> tables have the same structure and quite different data... Please don't ask why it's like that, and we can not change...

    Now, we need to run an Insert...

    Insert into tableX (col1, col2,...) select a, b,... from < o/p of the cursor > where < blah >...
    Note: The table changes name and it the cursor can o/p emp, emp_a and emp_b.

    Trying to do at the same time instead of do series and with the best performance... .no sql injection issues.
    In parallel, I mean
    Insert into tableX (col1, col2,...) select a, b,... from emp where < blah >
    and insert tableX (col1, col2,...) select a, b,... from emp_1 where of < blah > statements at the fire parallel / at the same time to the database. If you can share the procedure if you guys already have with you... is really appreciated

    Thank you very much for your time...

    Published by: user007009 on April 27, 2013 20:33

    >
    because suppose each request took 10 minutes and we have 5 tables, then 50 minutes so executed in series and 5 minutes, if each of them both right... I'm saving this time
    >
    And that's what I'm talking about when I said that
    >
    what you're doing wrong is trying to implement solutions more possible complex for a problem that does not exist yet.
    >
    You do not HAVE a problem. You are just "assuming"; "Suppose that each query took 10 minutes... ».

    Well suppose that the time it takes to "chunk" the query, run it in parallel is longer than the time it takes to simply run the query. Oh, wait, that OF what you have discovered.

    Well, let's assume that each query took 2 seconds. Assume that all this takes that half a second. Suppose you waited until you actually have a problem.

    The solutions are to solve real problems, not imaginary and non-existent problems.

    If all you are doing is "assume that" you will never find a 'solution' because you could always 'suppose' another problem that prevents this 'solution' of work.

  • Dynamic table names

    It is quite complex to explain, so forgive me if I miss some details.

    I got a code of work for Coldfusion 9, but my host only uses Coldfusion 8, and I'm not able to change it (or change host also).

    Now, I have a list of recipes, users can choose one or several of the recipes and can add it to the 'shopping list', grocery list is generated from the ingredients of the recipe. It begins as any application "your basket" there, however, following the various tutorials on the subject, that I'm still stuck in obtaining the 'ingredients' list, these tutorials allow to pass a variable and almost nothing else.

    Also this list may be printed or downloaded via file .txt (to put on my phone), so I need to keep the data.

    As explained above whatever I came with doesn't work under CF8, so far, I've modified my code to the following (note: I know that the "Evalute()" has not received a lot of love, so I tried to remove them, only because the ones I left are that no matter what else I have tried does not work):

    < cfoutput >
    <!--> loop in the first table containing the name of the recipees (table is called "ArList")
    < = cfloop '1' to = "#arraylen (arList) ' # ' index 'meter' = >"


    <! - calling the Array via a method - >

    #arList [meter]. Nom.getNom () # < /th >

    <!-check if there is any array containing the ingredient or if it is empty (just a security to avoid some bugs I've encountered). Otherwise, creates the table, each recipe gets its own ingredients database table, this way, it is possible to erase the unnecessary ingredient from the grocery list->
    < cfif not isdefined (session '. ") (' I_ #counter # ') or ArrayIsEmpty (Evaluate "(session.) ((' I_ #counter # ")) >

    <!--a little weird to start the < cfinvoke > here, but it works, the query returns only the ingredients of the recipe in each loop-->
    < cfinvoke component = "cfc.manoire" method = "Display_Ingrid" returnvariable = "Display_Ingrid" > "
    < name cfinvokeargument = "M_ID' value = '#arList [meter]. Nom.getM_id () #">"
    < / cfinvoke >

    <!-initialize the Array ingredient, these are dynamic because I can't predict how many users recipees will choose-->
    < cfset VARIABLES [session "."] I_"& counter] = ArrayNew (1) >

    <!--> loop through the query to complete the table
    < cfloop query = "Display_ingrid" >
    < cfset Arrayappend (VARIABLES "[session.) ([I_"& counter], structnew()) >
    < cfset position = arraylen (VARIABLES "[session.) ([I_"& counter]) >
    < cfset VARIABLES [session "."] [I_"& counter] [post]. I_Nom = #I_Nom # >
    < cfset VARIABLES [session "."] [I_"& counter] [post]. Quantity = #Quantite # >
    < cfset VARIABLES [session "."] [I_"& counter] [post]. Unite = #Unite # >
    < / cfloop >
    < / cfif >


    <!-displaty tables containing the list of ingredients, contains the hyperlink for the delete option. ->
    < cfloop from '1' = "#Arraylen (Evaluate('session.) = "(I_ #counter #')) #" index = "val" >
    #VARIABLES ['session. [I_"& counter] [val]. I_Nom #.
    #VARIABLES ['session. [I_"& counter] [val]. Incrus #.
    #VARIABLES ['session. [I_"& counter] [val]. Unite #.
    < / cfloop >

    < / cfloop >
    < / cfoutput >

    I get a"session of the item. "I_1 is not defined in an object of type Java coldfusion.runtime.VariableScope class" at the beginning of the last loop.

    I tried with evaluate() and it has a problem starting [val], which is not something I found pretty well documented so I guess there must be something relatively simple and direct that completely missed me.

    I am not put in any direction, so advice or constructive criticism is / are welcome.

    Thank you

    It seems to me like it the combination of the evaluate() in the CFLOOP could be led to SEE looking for a variable variables.session.i_1.  If this is the case, then it's a bug in CF, but you can get out help yourself by getting rid of the evaluate().  You don't have to evaluate() allows access to a variable name.

    Just use:

    session ["i_ #count #"], for example:

    --

    Adam

  • Insert as select on a table with 759 columns, including the Vitrual columns

    Dear people,

    DB version: 11.2.0.3.4
    Quality: Production
    Type: 2 node RAC

    Description of the problem: we meet with repeated ORA-00600 when we tried expdp a table as part of the application process. This has later been explored as a logical corruption on the primary key index. Request team works on the deletion and re-creation of the index according to the suggestion of support oracle.
    In the meantime, I tried to copy the table data affected with insert that choose, since exp pump/classic/ETG work or meet the requirement.

    The affected table contains more than 255 columns, to be precise - 757 normal columns and 2 virtual columns, these 2 virtual columns to create a composite subpartition on the table. Subparts are compressed BASIC.

    Since we cannot load the data in a virtual column, I exclude these 2 virtual columns and load data on to rest columns, virtual columns are filled based on the opinions of other 2 columns. The number of columns to select in the insert that is greater than 255, I am not able to load data using sql * more and sql developer, because they cannot manage this huge list of selection.

    SQL * Plus fails with the error "too Long".
    Developer SQL fails with "left/right parenthesis not found."
    I failed to Toad, so I have not tried the same thing, don't know if the TOAD can handle this huge list of selection either.

    My insert would look like below...

    Insert into the target (t1, t2, t3... t757) select (t1, t2, t3... t757) source;

    Can someone give me some directions please?

    Thanks and greetings
    Raja

    You sure have a closing parenthesis at the end of the select statement? This seems to reproduce the error:

    SQL> insert into t1 ( id,
      2  descr,
      3  name)
      4  select (id,
      5  descr,
      6  name
      7* from t
    SQL> /
    select (id,
              *
    ERROR at line 4:
    ORA-00907: missing right parenthesis
    

    You can also remove the opening parens of the select statement, because it is not really necessary.

    John

  • Def sequence (table grapes) with loops, clocked by the relatively long software.

    Hello and apologies in advance I am an infrequent user of LabVIEW.

    Running on a VI to control a peristaltic pump and valve used to control some for a biosensor nanogap Microfluidic devices. I have the pump and the valve works manually (i.e., I adjust the values on the fly) but I am now trying to allow the user to define a sequence of steps that are then executed one after the other.

    User input: number, flow, duration of valve, pump direction (boolean).  Ideally the user can then run several different steps by adding more steps, so I thought of an indexed cluster array where each element represents a step?

    I would like the user to enter the time in minutes and seconds. The minimum will usually be 30 seconds and could be as long as an hour. I'm not sure of the best strategy for the timed loop, if I understand the use of the block 'waiting (ms)' can cause problems. I thought about getting a timestamp, a value added to it and the comparison? Are there any other suggestions?

    Any advice would be appreciated.

    I use an acquisition of data USB-6009.

    PS the VI LabVIEW is probably an education version, so may cause problems when opening?

    Just ask yourself how you should architect your code? Using a table of parameters of the step is an eay easy to do. And the wait is not necessarily a bad thing, it depends on your application and if you need the calendar to be exact in a certain way. You can use wait it until Mrs several place for synchronization.

    You can lookin to a State Machine architecture to make the best UI feature.

    The Computer of State Simple model that comes with LabVIEW is really the best way for new developers to become familiar with LabVIEW using a semi scalable architecture.

    Here is a large example of the works of a state machine:

    • States: Init, slowed down, exit, DoThing1, DoThing2, DoThing3
    • Each State contains code that could take some time. Ideally, not too long because this is how long your code might not meet.
    • The idle state contains a structure of event for all of the user interactions.
    • The front panel has a button that says "do the 1 thing.
    1. Loop iteration 0: Application starts, the first State is Init. Init State made the initialization stuff and tells the application to go to the idle state when finished.
    2. Iteration of the loop 1: request goes to the idle state. He's sitting there, waiting for the structure of the event.
    3. Time passes, and then the user presses the button 'do 1 thing ". There is no code or minimal code, within the occurrence of the event. The output of this state of the event tells the application to go to the State of DoThing1.
    4. Iteration of the loop 3: Application passes to the State of DoThing1. Here, there is code that does a few things. The output of DoThing1 State tells the application to return to the idle state.
    5. Iteration of the loop 4: Application goes to a State of rest where he waits again to the structure of the event.
    • Each State can tell the application to go to any State they want. You want to reset? Return to the Init State. You want to put an end to the program? Go to the exit State. You want each State to start another (such as a sequence)? Have DoThing1 out of DoThing2, which DoThing3, which outputs Idle.

    You can create a report that runs the cluster setting input and operates it. The risk with a long wait, is that the code will not be able to receive entries to user during this waiting period. So if you make a long wait, you can use a VI of elapsed time to check several times if the wait is over.

  • find sql_id using the sql statement, including the carriage return and tab...

    Hello. all.

    I wonder how to find sql_id using a sql statement, including transport retrun and tab space multiple.
    To be more precise,

    My sql is:

    Select
    col_a,
    col_b,
    ..
    ..

    I usually use the following query to find the sql_id

    Select sql_id in v$ sql where sql_text like 'MY SQL STATEMENT %.

    When MY SQL STATEMENT includes carriage return and tab space multiple, how can I do?

    Thanks in advance.
    Best regards.

    Hello

    Did you look at regular expressions? Use regexp_like instead of as.

    http://www.Stanford.edu/dept/ITSS/docs/Oracle/10G/server.101/b10759/conditions018.htm

    Kind regards

  • Is it possible with javascript to compile the data entered by the user in an easy format to excel?

    I have a form in which the user enters several lines of data as well as additional information on these data.  I would like finally to export data, so I can manipulate the Excel.  This is possible because javascript (or otherwise)?  Here is an example of what I mean.

    The form of a table in which the user enters each of the names of his friend, their favorite color and their age.  I want the name of the specific friend linked to their favorite color and age so when I export to excel I can see how many friends has the user whose favorite color is red.

    If the form data would be as follows:

    Friend1name

    Friend2name

    Friend3name

    Friend1color

    Friend2color

    Friend3color

    Friend1age

    Friend2age

    Friend3age

    When I export the data as entered above, the results of each field in another column.

    Anyone has any ideas for that?

    It is possible with JavaScript. You can write the data to the JavaScript console and then copy & paste into Excel, or write to a file as an attachment (aka data object) and export it. Here's a sample script that writes the field data in the JavaScript console:

    Table of domain names

    Invoke the var = ['Friend1name', 'Friend2name', 'Friend3name', 'Friend1color', 'Friend2color', 'Friend3color', 'Friend1age', 'Friend2age', 'Friend3age'];

    Browse the fields and write the field values in the console

    for (var i = 0; i)< afields.length;="" i="" +="1)">

    Console.println (getField(aFields[i]).valueAsString);

    }

    Display console

    Console.Show ();

    You can place this code in the mouse event to the top of a button and click the button to run it. This last line of code displays the console and you will be able to copy & paste the data.

  • Schema name is not displayed in the data loading

    Hi all

    I'm trying to load a CSV file using oracle apex data loading option. The options are using a new upload (.csv) file and table. In the data load page, the schema name is not list my current schema because of which I could not not to download the CSV file.
    Can someone please help with that?


    I use apex oracle 4.1.1

    Concerning
    Rajendrakumar.P

    Raj,

    If it works on apex.oracle.com (4.2) and not in your case (4.1.1), my suspicion is that this is a bug that has been fixed in 4.2 APEX. Apart from upgrading your version 4.2 of the APEX, I'm not sure that there is not really a viable alternative.

    Thank you

    -Scott-

    http://spendolini.blogspot.com
    http://www.enkitec.com

  • SQL queries for reports help: need to reverse the data in the column in columns [O

    Hi all

    I'm looking for help in writing SQL, where I need to reverse the data in the columns column.

    My data in DB is as below.

    VALUE OF NAME OF MONTH
    Jan-10 M1 5
    Jan-10 M2 8
    Jan-10 M3 9
    Feb-10 M1 4
    Feb-10 M2 6
    Feb-10 M3 2
    M4 10 Feb 10
    M1 10 Mar 21
    Mar-10 M2 6

    Power required for the declaration will be like:


    MONTHS M1 M2 M3 M4
    Jan-10 5 8 9
    Feb-10 4 6 2 10
    21 Mar-10 6

    How can I do this using SQL. [ORACLE 10g]?

    I can make use of server Oracle BI also.

    Please help me on this...

    I think this is wrong forum to ask this question. You want to do it in OBIEE or at the DB level. In oBIEE you can do in a table privot view.

    Thnaks,
    Knani

  • Different VM 1 with 3 vmdk in the data store: Migration of data to rename store

    Hello

    I'm here today to ask for your help please.

    In our Organization, we have 1 large VM

    1 vmdk = > The BONES in lun, SAS performance

    1 vmdka = > 1 Tera SATA MON only of DATA

    Another 1 vmdka = > 1 Tera SATA MON only of DATA

    This virtual machine is being tested and we need to rename it to the name of the production.

    When you rename in vcenter you do a data store migration to correct all files with the new name.

    In this case, how can we specify each VMDK to go to the data store specified during migration?

    Because we could all think in the same data store due to the limitation of 2Tera by a data store

    Thanks for your help

    When you "migrate" a virtual machine and choose 'Change Datastore' use the advanced option. This will allow you to specify multiple destinations of data store. Use the drop-down arrow in the current [location].

  • Statement on the date of a virtual machine has been created

    Is it possible to report on the date on which a virtual machine was created?  This info is stored anywhere with the virtual machine?  Otherwise, he'll find newspapers in VMware Server to say how many virtual machines have been created last year?

    Thank you

    The Get-VIEvent cmdlet gets its information from the database of vCenter. To be more precise in the VPX_EVENT table. You can only return in time with respect to the first record in this table. To retrieve this date, you can use the following code:

    $eventMgr = Get-View EventManager
    $filter = New-Object VMware.Vim.EventFilterSpec
    $eventCollector = Get-View ($eventMgr.CreateCollectorForEvents($filter))
    $eventCollector.RewindCollector | Out-Null
    $eventCollection = $eventCollector.ReadNextEvents(1)
    $eventCollection[0].createdTime
    $eventCollector.DestroyCollector()
    

    The downside to the use of the Get-VIEvent cmdlet is that you must specify the number of records to be returned (100 by default) with the - MaxSamples parameter, and all these records are retrieved from the database. If you find events and you don't have a period, you must provide enough samples to include yours, and it can last forever. The event table can grow very large. In my environment, there are 8 million + records in this table.

    For the search of the database of events, I prefer to use the SDK instead of the Get-VIEvent cmdlet. That way I can start research until my records are found, and I can use specific filters to retrieve only the records that are of interest. I also pick up only as many records of the database if necessary. You can search the crΘation from a virtual computer by using the code below:

    $vm = Get-VM "myVM"
    
    $eventNumber = 100
    $eventMgr = Get-View EventManager
    
    $filter = New-Object VMware.Vim.EventFilterSpec
    $filter.Entity = New-Object VMware.Vim.EventFilterSpecByEntity
    $filter.Entity.Entity = $vm.ExtensionData.MoRef
    $filter.EventTypeId = "vim.event.VmCreatedEvent","vim.event.VmClonedEvent","vim.event.VmDeployedEvent"
    
    $eventCollector = Get-View ($eventMgr.CreateCollectorForEvents($filter))
    $eventCollector.RewindCollector | Out-Null
    $eventCollection = $eventCollector.ReadNextEvents($eventNumber)
    $matches=@()
    While ($eventCollection) {
      $matches += $eventCollection
      $eventCollection = $eventCollector.ReadNextEvents($eventNumber)
    }
    $eventCollector.DestroyCollector()
    $matches
    

    See you soon,.

    Arnim

  • Suddenly my mail is displayed in alphabetical order by name of shippers, rather than the date of receipt?

    Normally when I opened my Thunderbird mail the most recent e-mail appears at the top of the page with old messages below the last in order of date of receipt. Now the mail is represented with senders name in alphabetical order, regardless of the date of receipt

    You can sort the list of messages on most of his columns. Just click where it says "Date." There is a column which is not sort, but if you click on the label he switches between views threaded and Unthreaded.

    For more explicit sort options, activate the menu using alt or F10, and then go to view | Sort by.

    I use the sort by different columns (sender, subject, date) to help find and organize messages. Sorting is a tool provided for your convenience. Fear not, use it in a constructive way.

Maybe you are looking for

  • HOW CAN I ADD/REMOVE THE BAR LIST SEARCH ENGINE SEARCH ENGINES

    I would like to remove Google from the list and add an alternative search engine name to the list in the drop-down list on the search bar. Please help with what I can not find the answer in the Firefox "help" sections. ConcerningLojong7

  • Detect voltage 9237 programmatically?

    I'm using four 9237 complete Modules of bridge on a device of crio with interface FPGA and Labview 8.6. I'm trying to find a way to detect the voltage at runtime to include in the PDM file and be kept with the data. I was not able to find a way to do

  • scratch on screen

    There is a white blank strip on the upper left corner of my screen, it's about 2 "long and 1/2" high, it covers my shortcut icons.  How can I get rid of him? and what are the causes?  He came forward and then disappear after a few weeks

  • BlackBerry Smartphones Desktop Manager 4.7 for BB "BOLD" - Roxio does not recognize the SD Media

    I use the latest (version 4.7) Desktop Manager but Roxio will not recognize the SD card inserted in the phone. I tried (2) Micro SD cards with data on them both. The phone recognizes both cards and I can access the files via telephone. I forgot one o

  • Too old Mac operating system...

    Adobe told me that my mac operating system is too old to download photoshop, even if I pay for it through the Creative Cloud program, someone else has had this problem or is anyone know if West an older version of Digital.Anarchy.backdrop.Designer.v1