Questions about how to avoid the "while OTHERS"
HelloI am currently teaching myself PL/SQL. I have the script according to which uses SO that OTHERS (not a good thing):
undef sv_student_id
declare
v_student_id student.student_id%type := &sv_student_id;
v_total_courses number;
begin
if v_student_id < 0 then
raise_application_error(-20000, 'A student ID cannot be negative');
end if;
exception
when others then
dbms_output.put_line('Got an exception');
end;
/
When I run the above script and enter the value - 10 when prompted, I get the following output:SQL> @213c
Enter value for sv_student_id: -10
old 2: v_student_id student.student_id%type := &sv_student_id;
new 2: v_student_id student.student_id%type := -10;
Got an exception
What leaves to be desired (like a better message ;))The questions are:
1. How can I get the outer exception to display the error message specified in the raise_application_error instead of a generic message (such as 'Got to exception')?
2. I want catch exception using something specific, like "when-20000 then" (which does not), instead of the Tote so "than others'.
Thank you for helping,
John.
Published by: 440bx - 11 GR 2 on Aug 14, 2010 08:01 - plural for questions
1)
undef sv_student_id
declare
v_student_id number := &sv_student_id;
v_total_courses number;
begin
if v_student_id < 0 then
raise_application_error(-20000, 'A student ID cannot be negative');
end if;
exception
when others then
dbms_output.put_line('error_code='||sqlcode ||', error_message='|| sqlerrm);
end;
/
2)
undef sv_student_id
declare
v_student_id number := &sv_student_id;
v_total_courses number;
my_ex exception;
pragma exception_init(my_ex, -20001);
begin
if v_student_id < 0 then
raise my_ex;
end if;
exception
when my_ex then
dbms_output.put_line('my catch!');
end;
/
and maybe, that
undef sv_student_id
declare
v_student_id number := &sv_student_id;
v_total_courses number;
begin
if v_student_id < 0 then
raise_application_error(-20001, 'A student ID cannot be negative');
end if;
exception
when others then
if sqlcode = -20001 then
dbms_output.put_line('-20001 message');
elsif sqlcode = -20002 then
dbms_output.put_line('-20002 message');
...
end if;
end;
/
Tags: Database
Similar Questions
-
question about how to combine the two scripts.
HelloI have a sql script that can display a table (or view) all the information, it works fine. I call it validate_table.sql, as below:
command prompt
accept invites owner "Enter table owner:
accept invites from TABLE_NAME "Enter object (table/View...) "name:"
column owner format a10 column 'owner '.
column format a30 topic 'Object name' object_name
column object_type format a15 direction "Type of object".
Status format a10 column titled "Status".
in the heading of column created format a20 "created."
the LAST_DDL_TIME format a20, heading 'LAST_DDL_TIME.
Select
owner
object_name
object_type
status
, to_char (created, "DD_MON_YY hh24:mi:ss") created
LAST_DDL_TIME,
Of
DBA_OBJECTS
where
object_name = upper ('& table_name') and owner = upper ('& owner');
command promptprompt -- ----------------------------------------------------------------------- ---
Guest - table/view structure-
prompt -- ----------------------------------------------------------------------- ---
command prompt
describe and owner... & table table_namecommand prompt
prompt -- ----------------------------------------------------------------------- ---
guest - list assigned user/subsidies-
prompt -- ----------------------------------------------------------------------- ---
command prompt
set pagesize 50000
set linesize 10000
set verify off
Set feedback off
column lvl format A4 direction "Lvl".
proprietary format of columns A14
format column in table_name A29
A38 dealer column format
column privilege A10 format
SELECT 'Role' lvl, t.table_name, t.grantee, t.owner, t.privilege
OF dba_tab_privs t
WHERE t.grantee IN (SELECT FROM dba_roles role WHERE = role t.grantee) and t.table_name = upper ('& table_name') and t.owner = upper ('& owner')
UNION
SELECT 'User' lvl t.table_name, t.grantee, t.owner, t.privilege
OF dba_tab_privs t
WHERE t.grantee IN (SELECT username FROM dba_users WHERE username = t.grantee) and t.table_name = upper ('& table_name') and t.owner = upper ('& owner')
UNION
SELECT 'Pub' lvl, t.table_name, t.grantee, t.owner, t.privilege
OF dba_tab_privs t
WHERE t.grantee = 'PUBLIC' and t.table_name = upper ('& table_name') and t.owner = upper ('& owner')
ORDER BY 1, 2, 3;command prompt
prompt -- ----------------------------------------------------------------------- ---
guest - list of synonyms created.
prompt -- ----------------------------------------------------------------------- ---
command prompt
proprietary format of columns A15
synonym_name A20 column format
A15 table_owner column format
format column in table_name A40
DB_link A40 column formatSelect the owner, synonym_name, table_owner, table_name, DB_link from DBA_synonyms where Table_name = upper ('& table_name') stopped by the owner;
command promptprompt -- ----------------------------------------------------------------------- ---
guest - list index created-
prompt -- ----------------------------------------------------------------------- ---
command prompt
Select
table-name
index_name
index_type
nom_tablespace
status
of DBA_indexes
WHERE table_name = upper ('& table_name') and owner = upper ('& owner')
order of table_name, index_name;
command promptprompt -- ----------------------------------------------------------------------- ---
guest - list of constraints-
prompt -- ----------------------------------------------------------------------- ---
command prompt
format column in table_name A15
format of column cons_type A15
cons_name A20 column format
check_cons A25 column format
VALIDATED A20 column format
column status A10 format
last_change A20 column formatSelect
table-name
(case constraint_type
When 'P', then 'Primary Key '.
When 'R' then 'Foreign Key'
When 'C' then 'check '.
When 'U' then 'single '.
When 'o' then 'read only display '.
When 'V' then 'check the view. "
When 'H' then 'Hash expression. "
When 'F' then 'REF column.
When the of ' then 'additional logging.
cons_type end)
constraint_name cons_name
condition_de_recherche check_cons
status
VALID
last_change
of dba_constraints
where owner = upper ('& owner')
and table_name = upper ('& table_name')
order of cons_type;I have another script that allows to display the newly created tables (table, table names) in the last 24 hours.
SET SERVEROUTPUT ON;
DECLARE
CURSOR tmp_cur IS
SELECT master, object_name
FROM dba_objects
WHERE object_type in ('TABLE', 'SEE') and the owner not in ('SYS', 'SYSTEM', 'GENERAL', "XDB", "OUTLN", "SYSMAN") and last_ddl_time > sysdate - 1;
tmp_rec tmp_cur % ROWTYPE;
BEGIN
FOR tmp_rec IN tmp_cur LOOP
DBMS_OUTPUT. PUT_LINE)
tmp_rec. Owner | ' ' || tmp_rec.object_name);
END LOOP;
END;
/
The gap of the first script (validate_table.sql) is that it can only check table one by one by manual entry, then how can I combine these two scripts, to make a scipt that can check all newly created tables (not a table) in the last 24 hours?
I thank very you much in advance!
Hello
If you already know how to find the owner and all the tables created table_name recently. One thing you can do is to change all the WHERE clauses in validate_table.sql, so instead of things like
where object_name = upper ('& table_name') and owner = upper('&owner');
you say
WHERE (owner, object_name) IN
(
SELECT master, object_name
FROM dba_objects
WHERE object_type in ('TABLE', 'SEE')
AND owner NOT IN ('SYS', 'SYSTEM', 'GENERAL', "XDB", "OUTLN", "SYSMAN")
AND last_ddl_time > SYSDATE - 1
)
;
Here is another approach:
Validate_table. SQL is quite handy as it is. You may want to run this script for tables, even when you know that they are not new. Divide into 2 scripts: one called ask_and_describe_table.sql, which looks like this:
-Ask_and_Describe_Table.sql
accept invites owner "Enter table owner:
accept invites from TABLE_NAME "Enter object (table/View...) "name:"
-You can use any name path instead of d:\some_dir below:
@d:\some_dir\describe_table & owner, table_name
and the other one called Describe_Table.sql, which starts like this:
-Describe_Table.sql
DEFINE owner = & 1
DEFINE table_name = & 2
column owner format a10 column 'owner '.
...
and continues with the same exact content as validate_table.sql.
Now, to write another script (I'll call it Describe_Recent_Tables.sql):
-Describe_Recent_Tables.sql - create and run Describe_Many_Tables.sql
-Turn OFF the devices designed to help people to read the output:
SET ECHO OFF
SET FEEDBACK OFF
SET PAGESIZE 0
VERRIFY OFF SET
-Create a Describe_Many_Tables.sql:
COIL d:\some_dir\describe_many_tables.sql
SELECT ' @d:\some_dir\describe_table '
|| owner
|| ' '
|| object_name
FROM dba_objects
WHERE object_type in ('TABLE', 'SEE')
AND owner NOT IN ('SYS', 'SYSTEM', 'GENERAL', "XDB", "OUTLN", "SYSMAN")
AND last_ddl_time > SYSDATE - 1;
SPOOL OFF
-Features lighting designed to help people to read the output:
SET ECHO ON
SET FEEDBACK ON
SET PAGESIZE 50
SET VERRIFY ON
-Describe_Many_Tables.sql performance
@d:\some_dir\describe_many_tables
I guess that all of your tables have standard names (for example, start with a letter, no spaces in the name,...), which don't require quotation marks. If they could, then the same basic approach will work, but the details are a little messier.
When you want to see the information on a single table or view, no matter how old it is, driven
Ask_and_Describe_Table
or, if you do not need to question the owner of the table and the name, something like
Describe_Table SCOTT EMP
(You can find that you really need not Ask_and_Describe_Table.sql).
When you want to do this for all the tables created in the last 24 hours:
Describe_Recent_Tables
-
Four questions about how to change the Satellite L650 - 1 M 0
Hello
The laptop Toshiba L650 - 1 M 0 is possible to add the Bluetooth?
Currently, I don't have a WiFi card.I have a second question:
The laptop Toshiba L650 - 1 M 0 is possible to replace the ports USB 2.0 to 3.0?And the third question:
The laptop Toshiba L650 - 1 M 0 is possible to replace the matrix with a resolution of 1366 x 768 full HD (1920 x 1080) resolution?Most recent:
The laptop Toshiba L650 - 1 M 0 is possible to replace the processor and graphics card?These questions are for the future. I mention these parts when you are already old and weak.
Sorry for my bad English, but I used the Google Translator because I do not know how the English language. I only know the Polish ;)
Please write without mistakes, because the Google translator will be able to translate for me.
> Is that the laptop Toshiba L650 - 1 M 0 is possible to add the Bluetooth?
I think it would be possible to upgrade with the combo Wifi/BT card.
But I haven't found any info what WLan/BT cards combo would be compatible 100%.
You should test> Laptop Toshiba L650 - 1 M 0 is possible to replace the ports USB 2.0 to 3.0?
No, the USB ports are part of the motherboard.> Is that the laptop Toshiba L650 - 1 M 0 is possible to replace the matrix with a resolution of 1366 x 768 full HD (1920 x 1080) resolution?
I guess it would be possible, but we must find a 15.6 screen that supports such a resolution.
> Laptop Toshiba L650 - 1 M 0 is possible to replace the graphics card and processor?
GPU is not extensible.
In some cases its possible to upgrade the processor, but you will need to check which processors are supported by Mobile Intel HM55 Express Chipset
But even if the chipset would be favourable to a new processor, there would be still pending regarding BIOS support.
However, this upgrade took isn t supported by any laptop manufacturer, and I guess that its your own risk by doing this. -
Question about how 'First' makes the sequences
Hi all
I have a small question. I have a calendar in which I placed a transparent video with a timecode effect thereon for the purpose of lining of the stuff. I turned the visibility of it, but I wonder if I should remove it before as I give to improve the rendering time. First will interfere with him or she will calculate that it is there as an object for "invisible" also?
This may sound really stupid to ask, but I'm learning how to be as effective as possible in my workflow and if first does not care that it is because he is disabled, so I'd be inclined to let incase I need it again, but if she would accelerate rendering my project then I would take it before my final DVD build I intend to publish.
Any thoughts?
Premiere Pro makes that material visible. So feel free to leave there with visibility turned off.
Edit: to prove to yourself, add an effect to transparent video which causes the rendered line go red. As a"camera view". Die the eyeball and the Red goes. Make sense?
-
Question about how Oracle manages the Redo logs
Hello
Assuming a configuration which consists of 2 redo log groups (groups A and B), each group of 2 disks (disks A1 and A2 for Group A) and B1 and B2 disks for Group B. Additionally, assume that each redo log file resides by itself in a disk storage device and that the device is dedicated to her. So in the situation described above, there are 4 discs, one for each redo log file, and each disc contains nothing other than a redo log file. Also, assume that the database is in ARCHIVELOG mode and the files from archive is stored on another different set of devices.
kind of graphically:
The question is: when the disks that make up the Group A are filled and Oracle switches to the disks in the Group B, can the group drives to take offline, perhaps even physically removed from the system if necessary without affecting the functioning of the database? Can the archiver process temporarily delayed until the disks (which have been removed) are presented online or is the DBA have to wait until the end of the process to archive a copy of the redo log file creating in archive?GROUP A GROUP B A1 B1 A2 B2
Thank you for your help,
John.Hello
A journal of the groups fallTo remove a group of online redo logs, you must have the ALTER DATABASE system privilege. Before you delete a line redo log group, consider the following precautions and restrictions:
* An instance requires at least two groups of files logging online, regardless of the number of members in the groups. (A group is one or more members.)
* You can delete a group of newspapers online redo only if it is inactive. If you need to drop the current group, first force a log switch occurs.
* Make sure a group of online redo logs is archived (if archiving is enabled) before dropping. To see if this happens, use the view LOG V$.SELECT GROUP #, ARCHIVED, STATUS FROM V$ LOG;
GROUP # ARC STATUS
--------- --- ----------------
1 ACTIVE YES
2. NO CURRENT
3 INACTIVE YES
4 INACTIVE YESDelete a group of newspapers online redo with the SQL ALTER DATABASE statement with the DROP LOGFILE clause.
The following statement drops redo log group number 3:
ALTER DATABASE, DROP LOGFILE GROUP 3;
When a group of online redo logs is deleted from the database, and you do not use Oracle managed files, operating system files are not removed from the disk. Instead, control of the associated database files are updated to remove members of the Group of the database structure. After deleting a group of online redo logs, make sure the drop completed successfully and then use the command of operating system appropriate to delete the dropped online redo log files.
When you work with files managed by Oracle, the cleaning of operating system files is done automatically for you.
Your database will not be affected as you can work with 2 files, redo log in each group, as the minimum number of redo log in a database file is two because the process LGWR (newspaper writer) writes in the redo log in a circular way. If the process crashes because you have 2 groups only if you want to remove 1 Add a third and make that the current group and remove the one you want to be offline.Please refer to:
http://download.Oracle.com/docs/CD/B10500_01/server.920/a96521/onlineredo.htm#7438
Kind regards
Mohamed
Oracle DBA -
Question about how to include the virtual machine output
Currently, using this command:
Get - vm | Get-networkadapter | ForEach-Object {Write-Host $_.} The name', ' {$_.macaddress} '.
Gives me this result:
NIC 1, 00:50:56:bc:00:1 c
NIC 1, 00:50:56:bc:00:28
I'm interested also in writing the name of real virtual machine as well.
name of the virtual machine 1, NIC 1, 00:50:56:bc:00:1 c
name of the virtual machine 1, NIC 1, 00:50:56:bc:00:28Don't know how to work out of virtual machine name as 'Name' asks also the network card information.
Try it like this
$report = foreach($vm in (Get-VM | where {$_.PowerState -eq "PoweredOn" -and $_.Version -eq "v7"})){ Get-NetworkAdapter -VM $vm | ` Select @{N="VMname";E={$vm.Name}}, @{N="MAC address";E={$_.MacAddress}} } $report | Export-Csv ".\test.csv" -NoTypeInformation -UseCulture
-
How to avoid the SEPARATE in OBIEE SQL
Hello...
For the issue I posted previously...
Problem with the data type LONG in responses
I executed the query into a FROG, and I've identified the error because of what this error is coming... because of SEPARATE...
I took care to avoid this column in ORDER BY putting order on another column...
Now my question is how to avoid the DISTINCT clause in SQL generated by OBIEE...
If the first column of criteria is then it avoids the SEPARATE... but if I use measure... Group of will come... and group of should not be used here...
If it's done... my problem is solved...
Of course... I get duplicate rows...
However, I want the answer how avoid SEPARATE?
Waiting for the response from your...
Thanks and greetings
Kishore GuggillaKishore,
In the physical layer, open the properties of physical catalog and in the features tab find DISTINCT_SUPPORTED and remove the check box value.
who removed separate in each query generated for this database.
-Madan
-
Hello
Captivate 9.0.0.223: HTML5 draft.
I'm sorry to ask this question, it's a little old chestnut on HTML5 in Apple iOS and Android.
I have searched on the internet and forums for a solution underway, but could not find something that works.
The problem is how to avoid the PLAY button, which forces the user to click / tap on it, when the project is accessible on an Apple or Android system.
The project will be published on the internet for use on any Windows, Apple or Android device.
I have no control over the Web server or devices that will use the people, so that any changes to the software server or browser is out of the question.
I have tried both a plain HTML5 and a responsive project, but neither avoid the Play button. I put an example of 1 slide on these links.
http://www.hoffits.com/test_responsive/index.html
http://www.hoffits.com/test_html5/index.html
The bottom line is: ' is it possible to remove the need for the user to click / press the Play button?
Thank you.
Peter
Cardiff
In Wales
UK
In your normal HTML5, there is a line (I think it's 46) with this code:
CP. DoCPInit();
Add cp.movie.play (); Located below.
so:
CP. DoCPInit();
CP. Movie.Play ();
-
Satellite Pro 4200 how to avoid the mistakes of the ACPI
Satellite Pro 4200 how to avoid the ACPI errors after installing SP2 for windows XP Prof
The problem is that my computer after installation service Pack 2 need about 15 minutes from time of shoutdown - what should I do to avoid this problem.
Piotr PleckeHello
in this case it would be interesting what Type of laptop it is exactly.You will find this model on the bottom of your laptop. There is a review of it.
Some models have a Bios update available, others not, for example.
Please send additional information!
Good bye
-
How to avoid the SORT operation.
Hi gurus,
Oracle version is 11.1.0.7
I have a select query that has Row_number() over (Partition of col1, col2 order by col1, col2 desc nulls last) function to eliminate the DUP on these two passes.
Here it costs 4639 for sorting. Now, I added a two other columns in the query Select (has not changed the Row_number analytic function).
COST of sorting is now 555635.
This sort operation may use Temp table space. How to avoid the cost of SORTING.
Note: I use the function analytical only to eliminate duplicates on Col1 and Col2 only.
How to sort takes a large part of the COSTS by adding only two columns in the select list.
Any Suggestions...?
Thank you
MikeI would say:
1 don't worry unnecessarily about the cost of sorting - do you know if you have a problem.2. in general, eliminate from the beginning, sort late (i.e. After you have eliminated all you can)
3. If you are concerned by the outpouring sort on the disc then you could go to manual management of pga (assuming that you are currently using automatic) for this particular operation and override sort_area_size.
-
How to avoid the launch of Labview VI when he invokes in Teststand environment?
Hi, friends.
I am a student of teststand. I wrote a few screws by Labview. Now, I want to invoke in teststand environment.
But when I run the sequence. LabVIEW automatically launches.
How to avoid the launch of Labview when I run the sequence?
Thank you.
LabVIEW programs require a runtime engine. Under the TestStand configuration drop-down, select adapters. You can change the LabVIEW adapter to select the runtime rather than the development system.
This should prevent the main screen of LabVIEW to appear, but you will not be able to change your LabVIEW VIs while they run of TestStand using the runtime engine.
-
How to avoid the report query needs a unique key to identify each line
Hello
How to avoid the error below
The report query needs a unique key to identify each row. The supplied key cannot be used for this query. Please change the report attributes to define a unique key column.
I have master-detail tables but without constraints, when I created a query as dept, emp table he gave me above the error.
Select d.deptno, e.ename
by d, e emp dept
where e.deptno = d.deptno
Thank you and best regards,
Ashish
Hi mickael,.
Work on interactive report?
You must set the column link (in the attributes report) to something other than "link to display single line." You can set it to 'Exclude the column link' or 'target link to Custom.
-
How to avoid the glossy look and brilliant nostrils?
I just built my first character of fuse and when I import into Photoshop, its nostrils are incandescent - as if the light shines through the back of his head!
This fuse:
Becomes this in Photoshop:
I use a brush to set the nostrils, but have no idea how fix eye - of the suggestions?
Even better - any ideas on how to avoid the glossy look and glowing nostrils?
Thank you very much
MalcolmHey, Malcolm.
Best way to explain what basically rendering 3D correctly really takes a lot of time, haha. So that you may be able to work with the real-time 3D model and make changes quickly, we use two different rendering methods.
There is an "Interactive" mode which is not like the beautiful light/shade, but is very fast - and that's what you see when you interact with the default template.
Then, there is a mode "Raytraced" which is much more advanced calculations and stuff to give you a proper lighting / shadow. Raytraced rendered may take time if so we can not use it all the time.
In order to get the lights/shadows appropriate you need to perform a path Ray would make on the document. Best way to do this:
- Select your 3D layer in the layers panel
- Make a selection in the drawing area to the area that you want to make (I recommend to test rendering of area to check the lighting/shadows before committing to make the whole layer).
- Push the button is rendered at the bottom of the properties panel (it looks like a cube in a rectangle box, right next to the delete icon).
There are other things that you must do if you want to get the best image search quality such as the addition of secondary lights! You can add more lights in the 3D Panel using the small icon of light at the bottom. Have 2-3 stage lights and adjusting their colors can make a big difference with the Assembly of your character in the scene. Here is a small image for some comparisons:
You can see the image with two lights a look much more realistic lighting and shadows and raytraced of one and two versions are much nicer and cleaner!
Hope that helps!
-
Camileo S10 - how to avoid the 'information' during video playback on TV
I just received my Camileo S10... very nice indeed... but how to avoid the track and reading data to be shown on the screen during playback on my TV...?
Go to the movies, then before you start playing click the OK button. This also works when you save. You must do this before playing or recording.
-
How to avoid the launch of Labview when called by Teststand VI
Hi, friends.
I am a student of teststand. I wrote a few screws by Labview. Now, I want to invoke in teststand environment. But when I run the sequence. LabVIEW automatically launches. How to avoid the launch of Labview when I run the sequence?
Thank you.
I'm not sure that I follow what you're saying... But it seems that when the VI is called, the LabVIEW Development software is started and you want to avoid this.
If you create an executable file or a dll and that any call within TestStand, she should not call the development environment. You must have the LabVIEW runtime engine installed on the target computer.
For several years I used TestStand with LV, if my memory does not have to be precise. I think that the above worked for me. However, it seems that I remember something to have the LV code in debug mode, causing to open development environment... but it's a distant memory. You do not use breakpoints where the LV VI is called, are you?
R
Maybe you are looking for
-
As usual, reader of spammer lost so much effort... To filter the non - std areas I and probably countless others have created filters that throw E-mail ending in non - std areas. Problem is that spammers have now understood the weakness of filtering.
-
By the way the local variable to sous-suite
I have a sequence that sets a local variable, Locals.LowPassFreqGhz = 1,800. Then it executes 5 subsequences. The Local is set to a new value and then the same 5 subsequences are re-run. Now I have new model numbers where the pair is different and wi
-
When I brought my laptop hp, I do not have my laptop motherboard drivers CD... Please send me this CD
-
Cracked screen NetBook. The health risks?
My netbook has dropped and the screen cracked. Everything still works fine, but I am a little concered. Are there risks to health with a cracked LCD LED? I should have repaired/get rid of it immediately or it is safe to keep around for now? All infor
-
Difficulty logging into account own network (windows 7)
Hi, I had some difficulties logging into my own field of pc on a PC account. I reboot the machine all night, and when I try to log on to the domain / pc it pulls up a temporary office. I have to reboot and try again, and it finally works.