Problem with instructions to update within the if statement
HelloI have the following PL/SQL script. It was written in a way so it can be run several times, without worrying about if she has previously run means that it should only perform the update and edit, if it has not already been done.
DECLARE
CNT NUMBER;
BEGIN
-Rename column
COUNT (*) of SELECT INTO cnt FROM user_tab_columns WHERE TABLE_NAME = 'WELL_TEST_DATA_QUERIES' AND COLUMN_NAME = 'PRIMARY ';
IF (cnt = 1)
THEN
UPDATE WELL_TEST_DATA_QUERIES
THE PRIMARY VALUE = 0
WHERE PRIMARY = 1;
RUN IMMEDIATELY 'ALTER TABLE WELL_TEST_DATA_QUERIES RENAME COLUMN PRIMARY TO WELL_TEST_TYPE;
END IF;
END;
However, when it is executed several times, it seems to execute the body of the if statement each time, despite the fact that the select statement must return a count of 0 (and I checked that this is the case).
If I change the script and put the UPDATE statement in an EXECUTE IMMEDIATE, it works fine:
DECLARE
CNT NUMBER;
BEGIN
-Rename column
COUNT (*) of SELECT INTO cnt FROM user_tab_columns WHERE TABLE_NAME = 'WELL_TEST_DATA_QUERIES' AND COLUMN_NAME = 'PRIMARY ';
IF (cnt = 1)
THEN
IMMEDIATE EXECUTION
' UPDATE WELL_TEST_DATA_QUERIES
THE PRIMARY VALUE = 0
WHERE PRIMARY = 1';
RUN IMMEDIATELY 'ALTER TABLE WELL_TEST_DATA_QUERIES RENAME COLUMN PRIMARY TO WELL_TEST_TYPE;
END IF;
END;
Can someone give me an indication of what is happening here?
Thank you
Kathryn
user10855910 wrote:
HelloI have the following PL/SQL script. It was written in a way so it can be run several times, without worrying about if she has previously run means that it should only perform the update and edit, if it has not already been done.
Are you referring to getting this:
SQL> create table well_test_data_queries (primary number);
Table created.
SQL> insert into well_test_data_queries values (1);
1 row created.
SQL> commit;
Commit complete.
SQL> ed
Wrote file afiedt.buf
1 DECLARE
2 cnt NUMBER;
3 BEGIN
4 -- Rename column
5 SELECT COUNT(*) INTO cnt FROM user_tab_columns WHERE TABLE_NAME = 'WELL_TEST_DATA_QUERIES' AND COLUMN_NAME = 'PRIMARY';
6 IF cnt = 1 THEN
7 UPDATE WELL_TEST_DATA_QUERIES
8 SET PRIMARY = 0
9 WHERE PRIMARY = 1;
10 EXECUTE IMMEDIATE 'ALTER TABLE WELL_TEST_DATA_QUERIES RENAME COLUMN PRIMARY TO WELL_TEST_TYPE';
11 END IF;
12* END;
SQL> /
PL/SQL procedure successfully completed.
SQL> select * from well_test_data_queries;
WELL_TEST_TYPE
--------------
0
SQL> DECLARE
2 cnt NUMBER;
3 BEGIN
4 -- Rename column
5 SELECT COUNT(*) INTO cnt FROM user_tab_columns WHERE TABLE_NAME = 'WELL_TEST_DATA_QUERIES' AND COLUMN_NAME = 'PRIMARY';
6 IF cnt = 1 THEN
7 UPDATE WELL_TEST_DATA_QUERIES
8 SET PRIMARY = 0
9 WHERE PRIMARY = 1;
10 EXECUTE IMMEDIATE 'ALTER TABLE WELL_TEST_DATA_QUERIES RENAME COLUMN PRIMARY TO WELL_TEST_TYPE';
11 END IF;
12 END;
13 /
WHERE PRIMARY = 1;
*
ERROR at line 9:
ORA-06550: line 9, column 11:
PL/SQL: ORA-00904: "PRIMARY": invalid identifier
ORA-06550: line 7, column 5:
PL/SQL: SQL Statement ignored
SQL>
The problem is not because the IF statement entered the swiped m the cnt = 1, but because, when the code is compiled the PRIMARY column does not exist. The code should compile properly against the database, and all verified database object references, until the code is actually running.
As you have discovered, when you do the dynamic update to help to run immediately, you will not get this problem, because execute immediate statements are strings that can not be validated at compile time and so the code will compile ok and then run.
Tags: Database
Similar Questions
-
I'm having a problem with both photoshop update on the creative cloud applications
I'm having a problem with updates of photoshop creative cloud. Is anyone else having the same problem? Is there a solution?
It was a network problem that should be solved by the firewall opening and
a different administrator on the pc account.
-
I have problems installing Microsoft SQL server 2005 express edition service pack 3. When I use windows update Setup does not exceed 0% and crashes. I tried to download the service pack online. When I ran the installer, it crashes when you try to install SQL server database services.
Any help would be much appreciated.
Hello
Download SQL Server 2005 Express Edition Service Pack 3 from the link below:
http://www.Microsoft.com/downloads/details.aspx?FamilyId=3181842A-4090-4431-ACDD-9A1C832E65A6&displaylang=enRestart the computer in safe mode.
http://www.computerhope.com/issues/chsafe.htm#03Install the update in safe mode and check.
Cheers and enjoy!
-
I ran the troubleshooting and it fixed 2 problems but when I check the updates I always get this error message.
Colleen,
Click Start
Type: cmd
Right-click on cmd in the start menu and select "Run as Administrator"
Type: net stop wuauserv
Press enter
Type: ren c:\windows\SoftwareDistribution softwaredistribution.old
Press enter
Type: net start wuauserv
Press enter
Type: exit
Press enter
Reset
Try to download updates
`~`
The current time and the date now in Baja California, Mexico
09:23Tuesday, June 4, 2013
DST - 0700 UTCUTC/GMT is 16:23 Tuesday, June 4, 2013Current weather conditions in San FelipeClaire81 ° F / 27 ° C -
seems I'm not the only one having problems with safari after update 9.3 cannot follow the links. Safari blocks. hope it gets fixed quickly. jaa shooting allows to follow the link, but the Web page is not out of good old days. any oher ideas?
The 'list' of relevant articles that I know, they are now
-You can read about the problems in the present statutes and possibly find workaround solutions, particularly in the last
Apple iOS suspension 9.3 updates for older devices, work on activation fix | IVous
Apple launches new version of iOS for iPad users 9.3 2 affected by bricking bug | 9to5Mac
If you are unable to activate your iPad 2 (GSM model) update to iOS 9.3 - Apple Support
Leave a post by: ChitlinsCC
-
original title: problems with Windows VISTA update
I'm using Windows Vista (SP2). Windows update is not able to update the following updates on my system. Whenever I get these error messages.
- 9 47 code
- Code 800070002
- Code D 80024200.
Is there a resolution to do the same thing?
Hello
Did you change your computer?
I suggest you to follow the methods and check.
Method 1:
Problems with installing updates
http://Windows.Microsoft.com/en-us/Windows-Vista/troubleshoot-problems-with-installing-updates
Method 2:
If you have installed a security software on the computer, then I suggest you try to disable temporary and check to see if the same problem happens. Make sure that you enable security software back once the diagnosis is made to prevent the computer from virus attacks.
http://Windows.Microsoft.com/en-us/Windows-Vista/disable-antivirus-softwareMethod 3:
How to troubleshoot Windows Vista and Windows Server 2008 service pack installation issues
http://support.Microsoft.com/kb/947366
How to troubleshoot a problem by performing a clean boot in Windows Vista or in Windows 7
http://support.Microsoft.com/kb/929135
Note: After a repair, be sure to set the computer to start as usual as mentioned in step 7 in the above article.
-
I've updated to 2015.2 in September and started having problems with freezing while working on the photos. I upgraded my memory from 4 GB to 8 GB and it has disappeared (in most cases); However, I always feel a lot of questions of export of JPEGs (gel) but not tif files? Very frustrating. Tried to install the new updates but my creative cloud is just a blank page?
Hello
I think you are referring to the white empty window of CC desktop application.
Please refer to the threads below where this issue has been addressed:
Creative cloud is empty window why?
New application Cloud Creative unusable: it is empty!
Re: Empty opening creative cloud app
Kind regards
Sheena
-
Is anyone having problems with their Apple Watch since the iOS 10 came to life?
Is anyone having problems with their Apple Watch since the iOS 10 came to life?
Hello
If you have not already done so, it can also help update your Apple Watch to the latest version of the software:
-
Problem with installation if updates when installed
Hello
as I fought with some problems with Agents, I have studied the docs again.
That's why I said - allright get later reinstalled (patched) Version the Enterprisemanager.
When installing, I chose "(obtenir les mises à jour)." These where downloaded, rebooted interfaces.
However, the installation runs in an error:
INFO: oracle.sysman.top.oms:stty: Standardeingabe: Unpassender IOCTL (I/O-Control) as das Gerät
INFO: oracle.sysman.top.oms:stty: Standardeingabe: Unpassender IOCTL (I/O-Control) as das Gerät
INFO: oracle.sysman.top.oms: enter the SYSMAN user password:
INFO: oracle.sysman.top.oms:stty: Standardeingabe: Unpassender IOCTL (I/O-Control) as das Gerät
INFO: oracle.sysman.top.oms:stty: Standardeingabe: Unpassender IOCTL (I/O-Control) as das Gerät
INFO: oracle.sysman.top.oms:Verify:
INFO: oracle.sysman.top.oms: Enter password: SYSMAN
INFO: oracle.sysman.top.oms: process_id:mve1rmclp7j2
INFO: oracle.sysman.top.oms: [Initializing the RCU Runner MA, run the Action of schema, schema successfully completed Action]
INFO: oracle.sysman.top.oms:Die Befehlsausfuhrung transx wurde mit dem status 0 sky
INFO: oracle.sysman.top.oms:process_id:13nzs6kxz2aqx
INFO: oracle.sysman.top.oms:Failure...
INFO: oracle.sysman.top.oms:1 or the mistakes that happened in the exercise of the action:
NEWS: oracle.sysman.top.oms:1):
ORA-04063: Discovers "SYSMAN. "MGMT$ PA_RECOM_METRIC_SOURCE" contains Fehler
File: / U02/app/Product/middleware/WHO/SYSMAN/admin/emdrep/SQL/Core/latest/patch/REC/patch_recom_grants. SQL
Statement: GRANT SELECT ON MGMT$ PA_RECOM_METRIC_SOURCE to MGMT_VIEW
INFO: oracle.sysman.top.oms:The plugin Repository Configuration failed his method
And stopped :-(
Is the code of the view:
Select
p.patch_uid as patch_guid,
p.patch_id as a hotfix,
p.Abstract as abstract,
p.classification as the classification,
t.target_guid as pa_tgt_guid,
t.target_name as pa_tgt_name,
t.target_type as pa_tgt_type,
t.type_display_name as pa_tgt_type_display_name,
Host.target_name as host_name,
Host.target_guid as target_guid
Of
mgmt_targets host,
gc_assoc_instances has,
MOS$ PA_FINAL_RECOM f,.
MGMT$ ARU_PATCH_RECOM_MD p,.
mgmt_targets t
where
Host.target_type = 'to host '.
and host.is_group = 0
and a.assoc_type = 'hosted_by. '
and f.patch_uid = p.patch_uid
and f.target_guid = t.target_guid
and a.source_me_guid = t.target_guid
and a.dest_me_guid = host.target_guid
The Table MGMT$ ARU_PATCH_RECOM_MD does not exist - this seems to be the cause of the failure
Is this a known issue?
And if so - no work around?
THX
Christian
Edit:
I checked it on a system installed without the upgrade option selected.
The table ARU_PATCH_RECOM_MD $ MGMT are here.
It is being investigated as a bug by our quality assurance team. For now, please ignore the automatic update and installation should proceed to problem.
-
My computer recently crashed. A fixed it but! When I then tried to use photoshop I got the message: - message - problem with display driver, temporarily disabled the improvements. Does that mean, they will return when the problem is solved?
Update or restore your graphics driver.
-
I had problems with access to most of the Web sites and noticed that HTTPS no longer appears whenever I try to access a Web site. I can easily connect to my gmail and facebook account, but the problem is that when I click on a link on FB and gmail, I get the annoying message "refused to connect.
How to address this issue, rather how to make HTTPS permanent so I can easily access any Web site. The date and time on my laptop are both correct. I am currently using OS x 10.9.5.Please!
How to address this issue, rather how to make HTTPS permanent so I can easily access any Web site.
My guess is that you have a damaged or invalid certificate entry OS X KeyChain, but to directly answer this question, I would say that consider you something like HTTPS Everywhere. Note, it is not available for Safari. It is available directly through the Google Chrome browser extensions.
-
problem with my laptop asking for the administrator password or power on password
I have the same problem with my laptop asking for the administrator password or power on password. It is a compaq presario cq61. It happened when my hard drive failed and was not used for a long time. With the password, any help would be much appreciated. It says system turn off after a few trials with the key: 55427586
Hello
Try to enter: 40585508
Kind regards
DP - K
-
I recently tried to remove malware on my Vista based laptop Toshiba.
I recently tried to remove malware on my Vista based laptop Toshiba. Malwarebytes helped, but I still have problems with a redirect virus and the refusal by the system to allow me to download various things, Windows Live Mail in particular. I tried to download from a copy of the USB stick to a clean computer, but he still refuses to load telling me to check my internet connection, which is fine for general use. Please help I get crazy and do not forget that I am a pure layman - thank you if you can help - Kidso
I found that the best place to ask this type of question is here: -.
http://forums.ComputerActive.co.UK/forumdisplay.php?f=20
There are some very good people out there who helped me (successfully) on 2 occasions.
Good luck.
I'll be interested to know how you go.
-
Hi allI have the problem with my language of keyboard, the fact is I can't add or remove languages from keyboardWhen I press the keyboard button change that nothing happens, but in the event viewer I get the following messageThe failing application name: Rundll32.exe_shell32.dll, version: 6.1.7600.16385, time stamp: 0x4a5bc9e0Name of the failed module: input.dll, version: 6.1.7600.16385, time stamp: 0x4a5bdf4fException code: 0xc0000005Offset: 0 x 0000000000003756ID of the process failed: 0xf5cStart time of application vulnerabilities: 0x01cd697d57b60837The failing application path: C:\Windows\system32\Rundll32.exePath of the failing module: C:\Windows\system32\input.dllReport ID: 95fbd586-d570-11e1-8bfb-c860006d193aCan someone help me with this? or maybe there's another way to change the keyboard languages? for example through registry?Thanks in advanceI HAVE Windows 7 x 64
Hello
I suggest to create a new user account and check.
Create a user account.
http://Windows.Microsoft.com/en-us/Windows7/create-a-user-account
If the problem does not occur in the new user account, I suggest you to fix a corrupted user profile.
Fix a corrupted user profile.
http://Windows.Microsoft.com/en-us/Windows7/fix-a-corrupted-user-profile
-
Hello. I purchased a CS2 product and im having problems with activation. I have the key but my installation failed in the 'summary '. Please help thanks. This is what im seeing.
See my response in audition 3 error with installation
Maybe you are looking for
-
Carpet * a UJ - 831S engraving options (Satellite M40X-237)
Hello I recently bought a Satellite M40X-237 with this carpet * a DVD - RAM drive.For DVD playback in a home theater system, I usually burn DVDs with booktype set to DVD - ROM, so that the reader can read correctly.Problem is that the latter does not
-
Equium L10 300 Wont start white screen
Hi I wonder if anyone can help or advise me with a problem starting It's a portable satellite L10 300 XP homedition, after running PC doctor to remove Popups and adware my laptop stopped commissioning. Initially started after the system check it kept
-
Is compatible with BNC-2090 PCI-6723 has?
Hi everyone, I am working in a project where I'm forced to use both a PCI-6723 connected to a BNC-2090 case has... In the datasheet of the 6723 only to versions of the BNC-2110 and 2115 are suggested. Anyone know if I can still use the one I have no
-
Lately the computer goes to sleep in the middle of my work. How can I control?
-
Question of size BrowserField2 displayContent fonts
We are calling BrowserField2.displayContent (String, String) and passing in HTML. On 5.0.0 police find normal, but on 6.0.0 it is very large. I checked the zoomScale on both and they are 1.0f. I checked the size of the BrowserField and the Manager ho