Anonymous blocks that goes down and creates a table
Version: 11.2.0.3
I'm relatively new to PL/SQL.
We have a table named CHK_CNFG_DTL.
I want to create a backup table for CHK_CNFG_DTL who will be named as CHK_CNFG_DTL_BKP_ < timestamp > for example: CHK_CNFG_DTL_BKP_JULY_22_2013
Creating this backup table must be automated, so I want to create an anonymous block that will first remove the existing backup table and then create a new backup of the original table.
The code below works fine. But the first time when you run it, the loop will not iterate because there is no such table named % CHK_CNFG_DTL_BKP.
declare
v_stmt varchar2 (1000);
date of T_DATE;
Start
for rec in
(select * from user_tables where table_name like '% CHK_CNFG_DTL_BKP')
loop
Start
run immediately "alter session set nls_date_format =" DD_MON_YYYY "';"
v_stmt: = 'drop table' | Rec.table_name | "purge."
dbms_output.put_line (v_stmt); -Old backup drops table
immediately run v_stmt;
Select sysdate in double T_DATE;
v_stmt: = "create table CHK_CNFG_DTL_BKP_ | TO_DATE (V_DATE): ' in select * from CHK_CNFG_DTL';
dbms_output.put_line ('Bkp création table CHK_CNFG_DTL_BKP_' | to_date (v_date));
dbms_output.put_line (v_stmt);
immediately run v_stmt; -Creates the new table of backup
exception
while others
then
dbms_output. Put_line (rec.table_name |'-'|) SQLERRM);
end;
end loop;
end;
/
PL/SQL procedure successfully completed.
-Backup table was not created.
SQL > select table_name from user_Tables where table_name like '% CHK_CNFG_DTL ';
TABLE-NAME
------------------------------
CHK_CNFG_DTL
Of course, this can fixed by creating a table as bleow before running the anonymous block
SQL > create table CHK_CNFG_DTL_BKP_JULY_22_2013 (x varchar2 (37));
Table created.
and now the block will be executed with success as
24 end;
25.
drop table CHK_CNFG_DTL_BKP_JULY_22_2013 purge
Creating table Bkp CHK_CNFG_DTL_BKP_22_JUL_2013
create the table CHK_CNFG_DTL_BKP_22_JUL_2013 select * from CHK_CNFG_DTL
PL/SQL procedure successfully completed.
But it goes to production. We cannot have a table like CHK_CNFG_DTL_BKP_JULY_22_2013 without an appropriate reason.
How can I change the code above so that if even if there is no such like '% CHK_CNFG_DTL_BKP' table, he will create the backup table?
Hello
Why don't you press the create backup of the loop?
declare
v_stmt varchar2 (1000);
date of T_DATE;
Start
for rec in
(select * from user_tables where table_name like 'CHK_CNFG_DTL_BKP %')
loop
Start
run immediately "alter session set nls_date_format =" DD_MON_YYYY "';"
v_stmt: = 'drop table' | Rec.table_name | "purge."
dbms_output.put_line (v_stmt); -Old backup drops table
immediately run v_stmt;
exception
while others
then
dbms_output. Put_line (rec.table_name |'-'|) SQLERRM);
end;
end loop;
Select sysdate in double T_DATE;
v_stmt: = "create table CHK_CNFG_DTL_BKP_ | TO_DATE (V_DATE): ' in select * from CHK_CNFG_DTL';
dbms_output.put_line ('Bkp création table CHK_CNFG_DTL_BKP_' | to_date (v_date));
dbms_output.put_line (v_stmt);
immediately run v_stmt; -Creates the new table of backup
end;
Tags: Database
Similar Questions
-
my system does not start upwards - don't stop progression blue bar that goes round and round. I can boot into safe mode and safe mode with networking mode.
Hello
As you are able to boot to the desktop in Mode safe, it means that the third-party application prevents the computer from starting in normal mode. To check you can configure the computer to clean start State and then try to boot into normal mode and check what is happening. To set up its own start-up follow the link below.
http://support.Microsoft.com/kb/310353
If the problem does not continues when the computer is in the clean start State follow the steps listed to identify which application is causing the problem.
Note: When you are finished troubleshooting, follow step 7 article to start on normal startup.
Hope this information is useful.
Amrita M
Microsoft Answers Support Engineer
Visit our Microsoft answers feedback Forum and let us know what you think. -
AS2 - a button that goes in and plays the next image in a moveiclip
Hi all
I have a button (called wrong_btn ) that I want to order a moveiclip ( called lives_mc ).
Gameplay: If you click on wrong_btn , a life is removed.
Visually, lives_mc is a bottle that is empty and this is done through the frameworks within the mc.
How can I get a button to move a picture to the image until the bottle is empty?
Thank you very much
Sophie
{wrong_btn.onRelease = Function ()}
lives_mc.nextFrame (); If the keyframes are adjacent to each other. Otherwise, use Stop
}
-
Data block in the procedure and the Base Table
Hello
I hava a form with a block of master and detail. The fields in the Master block are
Emp_name, DateOfJoin, salary... I created this block with the procedure with a Ref Cursor, becaue the user
want to load the data based on the conditions it enter for example: DateOfJoin < = Sysdate and DateOfJoinn July 1, 2008 "."
SO I created a block of control with the fields name, MiddleName, LastName, of DateOfJoin, in DateOfJoin, the salary, and when the user clicks on the data loading
button, I load the data to block under these conditions using the procedure.
Note that in the Emp_Name table if a field, but contain first name, middle name, and last name with a separate space.
My needs is, is there any method to develop this master block with a database table, so that if the user want to select it
data based on other conditions, it can enter directly into the block of data using Qry enter and run Qry, also if he wants to
Select data based on the top-level asked the search criteria, it will click Load Data.
I hope that in this case, when the user selected the Load data button, I need to change the data source to the Type of procedure and set the source of data on behalf of the procedure name.
Is there any other easy solution flor this
Thanks in advancenot sure if I get your needs. I understand the following:
You have a block based on table emp, containing a DateOfJoin column and the user should be able to enter into a 'complex' where denomination.To do this, you do not have to base block one a procedure or ref_cursor. Two possibilities:
Add two fields more directly in the block that are non-base of data-objects of type date fixed query on yes and let the user to enter a date range in these columns. In the accumulation of PRE-QUERY-trigger a WHERE condition by using the value in this field:
something like:
DECLARE vcMin VARCHAR2(10):='01.01.1700'; vcMax VARCHAR2(10):='01.01.2999'; BEGIN IF :BLOCK.DATE_FROM_JOIN IS NOT NULL THEN vcMin:=TO_CHAR(:BLOCK.DATE_FROM_JOIN, 'DD.MM.YYYY'); END IF; IF :BLOCK.DATE_TO_JOIN IS NOT NULL THEN vcMax:=TO_CHAR(:BLOCK.DATE_TO_JOIN, 'DD.MM.YYYY'); END IF; SET_BLOCK_PROPERTY('BLOCK', ONETIME_WHERE, 'DATEOFJOIN BETWEEN TO_DATE(''' || vcMin || ''', ''DD.MM.YYYY'') AND TO_DATE(''' || vcMax || ''', ''DD.MM.YYYY'')'); END;
Another option:
together, the length of the request of the DATEOFJOIN field to say 255, then the user can directly enter #BETWEEN fromdate AND fodate in the field. -
Find/change the question numbers and create the Table of contents
Hello! I need help to find all my item numbers and apply a paragraph style so I can use them to create a Table of contents page.
The sample numbers
#12345
#12345-5
#12345-20
#12345-ABC
#12345/N
I tried to enter #^? ^ ? ^ ? ^ ? ^ ? in the search/replace and but it is exactly 5 characters after the sign #. I wonder if you can find all characters starting by # and up until the last characters.
Once I found all item numbers, how can I apply the paragraph style to have these characters after the sign #? Because I only want to show item numbers without the # sign on the Table of contents/Index page.
In addition, I have InDesign CS2, which have no function GREP maybe I can do this without the GREP?
I really appreciate any help. Thank you very much.
Are your numbers by themselves in a separate paragraph? OTHERWISE you can not USE the table of contents feature to list all the numbers.
If are, then just look at # in find/replace, then set it to change formatting a new paragraph style (you must create this style in CS2) that you want to include in the table of contents, then as you say, you can use find/replace once more on the history of the TOC to remove the # of all numbers.
-
Existence and creating the table
Sometimes the table name must be fully qualified and sometimes not. I guess I should watch a coat of primer on the tables, users, tablespaces.
Thank you
Ken
drop table "BIS_USER"."ACDArea" ; --Got this exporting dll from existing table prior to dropping CREATE TABLE "BIS_USER"."ACDArea" ( "DivisionId" NUMBER(*,0) NOT NULL ENABLE, "AreaID" NUMBER(*,0) NOT NULL ENABLE, "Area" VARCHAR2(20 BYTE) ) SEGMENT CREATION IMMEDIATE PCTFREE 10 PCTUSED 40 INITRANS 1 MAXTRANS 255 NOCOMPRESS NOLOGGING STORAGE(INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645 PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT FLASH_CACHE DEFAULT CELL_FLASH_CACHE DEFAULT) TABLESPACE "USERS" ; -- "table or view does not exist" insert into acdarea values (1, 2, 'northeast'); create table acdarea2 ( divisionid int, areaid int, area varchar2(100) ); -- works fine insert into acdarea2 values (1, 2, 'south by southwest');
Hello
ktrock wrote:
Sometimes the table name must be fully qualified and sometimes not. I guess I should watch a coat of primer on the tables, users, tablespaces.Yes, it is a good idea.
CREATE TABLE 'BIS_USER '. "" ACDArea ".
...
-"table or view does not exist.
insert into acdarea values (1, 2, "Northeast");Anything either inside quotes is case-sensitive. Anything not in quotes is uppercase before compiling. So if you create a table with quotes and lowercase name (and the last 3 letters of the "ACDArea" are tiny) then you must use double quotes and the exact capitialization of even every time you reference this table.
Do not use quotation marks. It will be just extra work and confusion for you and for all those who have to write code for this table.
-
My bookmarks toolbar is more on the top where it has always been. Now there is a button on the taskbar that descends the bookmarks on the side. How can I get the bookmarks toolbar to the top of the screen?
I had the same problem and realized that the Bookmarks button opens a sidebar instead of a drop-down menu if the menu bar is displayed. Hide the Menu bar causes the Bookmarks button work like a menu drop-down.
-
Red/purple/magenta strange "shadow" that goes away and then comes back
I'm having some trouble with an odd coloring going on inside LR.
When the file is loaded, it looks like this:
Once you touch ANY cursor (or do anything really), this happens:
Notice the weird red/purple/magenta area around his mouth and cheeks.
Someone has ideas of what is and how to stop it from happening? I had some suggestions that it could be a moire caused by the texture of the veil, but it seems strange that LR he was entitled to be with.
Any suggestions are greatly appreciated.
Thank you.
Try the memory option in the adjustment brush.
-
Satellite L10-102: screen goes down and then comes very quickly.
Hi, I have Nooteboom L10-102. Sometimes during work, the screen down abruptly then comes very quickly. Like the natural eye blinking. ? s there a kind of great power problem or comes from the different fault.
I need advice to fix the problem.
Thank you...
Hi, manual
Believe me, according to your explanation, that it is not easy to say exactly what is happening. In my opinion, just an intensive audit can train with a few explanations.
Is that your permanent unit connect to the AC adapter when this happens?
Is the monitor off feature enabled in the power manager?On this path, it is not easy to tell what's happening.
-
What is a race like screen with a block that says administrator and password?
I am using a website called Big Fish Games. I have used every day in Ohio. I moved here a year ago and I can't access this site.
I get a screen "run as" indicating that I need to run as administrator and request a password. That is - what, why is it defined and how past?Hello
1. which web browser you are using?
2. this happens with all sites or with any specific Web site?
3. What is the exact error message you are getting?
4. are you able to access the Web site normally on another computer?
5. don't you make changes to the computer before the show?
Please follow the steps below.
Method 1:
Follow the steps from the link below
http://support.Microsoft.com/kb/967897
Method 2:
Follow the steps below.
(a) open Internet Explorer
(b) click on Tools
(c) select Internet Options
(d) click the Security tab
(e) click the checkmark for Trusted Sites
(f) click the Sites button
(g) type the web address in the Web sites box
(h) and then click Add
-
Hello
When I turn off my laptop the fan starts to spin then and during a night, it drains the battery from 100% to 0. I also have some problems of marketing. If the computer is in sleep mode itself or by me, I can't wake up, need button for 10 seconds and then push again and it starts. When turned on, it works perfectly but has these problems. I read somewhere that the resolution of these problems has been to remove the software intel from my computer and I did. It helped but 2 days computer started having these problems again. My system is Windows 7 64 bit. This problem started after that I have somehow left fully charged computer asleep on the charger for about 2 hours. When I came back fan was spinning and the right side of the laptop was hot. Again, battery life is great and computer has no defects during the work (all tests by dell are passed). What can you suggest me to do?
As you have a laptop, better make this laptop in the computer Forum post here:
http://en.community.Dell.com/support-forums/laptop/default.aspx
Bev.
-
Guard printer goes offline and create a copy of the printer
Hello
I have a printer that does not have very easily the first time. First time, I actually connected via usb first and then installed driver after. I then deleted and did the opposite way around. This seemed to work properly.
However, it will work for awhile and then the printer will be displayed in devices and printers, but does not print anything OR a copy of the printer is displayed.
I tried the passage of the printer with another of the same model and the question remains... so it doesn't seem to be a problem with the computer itself. It is running 32-bit win7. I also tried to change the printer usb cable and cable supply.
So now when the present question, either on the printer market at least will get it print again... OR I need to go into print management and remove the printer and driver package and then restart and then reinstall the driver and connect... it works so perfectly for perhaps a day or two...
The printer is a printer of labels Zebra with the latest driver.
I have a second printer running on this machine very well (it was installed after the other printer).
I wonder if I need to do a complete withdrawal (registry and all) of any trace of the printer to reinstall it?
Go to your Control Panel Printers folder. Look for your printer. Right-click on it and make sure that it is set to "use printer online".
Remember if your printer is turned off the power, it will show as "offline". When you turn it on it should automatically go back to 'online '.
You can always change where I showed you.
This should take care of it. -
Is there a tip action that will open and close the table of contents?
I like that in CP5, Adobe has allowed users to change the icon associated with opening and closing of a Table of contents in layers. Having said that, unfortunately, they show if small, I don't see what I created. So, I was wondering, is there an advanced action or an action script that I could assign to a button that will allow my users open/close the table of contents?
Thoughts?
Eric
I created a quick and dirty AS3 widget that can be used in Captivate 4 and Captivate 5 projects to open / close a table of contents in overlay with your own button mode.
Have fun; (o)
/ Michael
-
How to remove and create a table in a procedure
I want to remove a table like this
drop table movies
create table movies)
fields
);
all the foregoing in a procedure
How can I docreate or replace procedure cretab as table_name varchar2(20); begin execute immediate 'drop table movies'; execute immediate 'create table movies (fields varchar2(1000))'; end; /
-
Hi friends
I am developing anonymous blocks that displays the message on the screen, like "hello world" "is SYSDATE today" and "tomorrow is SYSDATE + 1". To make me try to develop anonymous block, but it shows me error... so friends can you help me with this...
Set SERVEROUTPUT on
declare
p_text varchar2 DEFAULT "hello world";
P_date date default sysdate;
P_next_date date default sysdate + 1;
Start
DBMS_OUTPUT. PUT_LINE (|) P_text);
DBMS_OUTPUT. Put_line (' today's :'||) P_date);
DBMS_OUTPUT. Put_line ("tomorrow is :'|| p_next_date);
end;
/
Thanks in advance
RommyHi, Rommy,
Always format your code. Dash to show the main sections (DECLARED, BÉGIN, etc..)
Type these 6 characters
{code}
(small letters only, inside curly braces) before and after the formatted text, to keep the spacing when posting on this site.DECLARE p_text VARCHAR2 (50) DEFAULT 'hello world'; P_date DATE DEFAULT SYSDATE; P_next_date DATE DEFAULT SYSDATE + 1; BEGIN DBMS_OUTPUT.PUT_LINE (P_text); DBMS_OUTPUT.PUT_LINE ('today is: ' || TO_CHAR (P_date, 'Dy DD-Mon-YYYY')); DBMS_OUTPUT.PUT_LINE ('Tommorrow is: ' || TO_CHAR (p_next_date, 'Dy DD-Mon-YYYY')); END; /
When you declare a VARCHAR2 variable, you must specify the maximum length.
The | operator is used between two string expressions; Looks like you forgot the first operand in one place.
Using a DATE where we expect a VARCHAR2 (as an operand to |, for example) is not technically an error, but it's a bad habit. TO_CHAR to create a string in any format you want.
Maybe you are looking for
-
Worry not that my account was hacked, or my stolen device found once more.
I received an email from auto to Heathrow Airport has sent to my email from Apple yesterday, account while at the point I was in Asia. It's either my hacked account, or a long lost ipad/iphone/computer laptop is turned on. Do you know what email addr
-
Impossible to install the graphics driver for Satellite L50-B-1EE
Hello I can't install the intel graphics hd on my laptop?
-
I am running Vista Business on my Dell Lattitude E5500 laptop, I don't have Microsoft Home and Student 2007 installed here. I have installede Visio on my computer. SO WHY am I having to download an important for this program update, when I DON'T HA
-
I need to know if I should buy a new wifi card?
Hi, so I have an acer aspire computer 5750z, earlier my wifi suddenly stopped working, but ethernet is fine. I searched on the internet and tried to install the required driver (Atheros), but when I try it says that the "reader could have been eject
-
HP mini 1101 computer: need to password reset for hp mini 1101
need to password reset for hp mini 1101 cnu932bkxr Help, please