When we use package's begin part?
Guys, I would like to learn when we use this part of package. I mean, because begin part only executes ones and never executes again in that session. So why we use this part?
create or replace
package body my_pack
is
num number;
str varchar2(50);
begin
So when should we use this part of packages?????
dbms_output.put_line(Why we use this part??????');
end;Thanks
>
So in the example above of a logging interface, if another package also use the same interface then it will overwrite the verbosity level of the initial package that was loaded. In such a case, each procedure in a package will need to first set the log level prior to using application logging.
>
That sounds like a design and implementation issue - not the way I implement logging. It doesn't make sense to have each package potentially overwrite the global log level like this. A package would either use the global log level already set or use it's own level.
The logging package would have an 'init' section that checks for a context variable to set the logging level and then either uses it or a default value if none is set. The log procedures would also be overloaded so that if no log level was specified as a parameter then the global value (set by the log package init section) would be used. The overloaded procedure would accept a log level parameter so that different levels could be used as needed.
The 'init' section in other packages would also check for a context variable (one for their package) and use it if it had been set. Otherwise they would get their log level from the value already set by the log package. If this 'other' package was the first to call the log package then they would get the value set by the log package 'init' as explained.
Similar Messages
-
NoClassDefFoundError when I use "package" keyword
Hi,
When i put the class into a package, i got the following error message:
"Exception in thread "main" java.lang.NoClassDefFoundError: Data (wrong name: suncertify/db/Data)"
But when I delete the "package" keyword, it works fine. why is that?
Thx.
adrianWhen you name a package for a class, the fully qualified name for the class is the package name plus the class name, in your case the package name seems to be suncertify.db and the class name is Data so the fully qualified name is suncertify/db/Data (or suncertify.db.Data). If you don't specify a package, then the fully qualified name is just the class name.
When you launch an application using the java command, you must use the fully qualified class name. In your case, it appears you used "java Data" When the JVM found a Data.class file, it expected a class whose fully qualified name is Data but it found the class suncertify/db/Data - thus the class it found had the wrong name. -
Why did ISO 7.1.1 change the feature where you could use four fingers to close an app and see if he other apps on your home screen as you were closing an app. This was the handiest feature I thought because I could partially close the app I was working in and see the date or other things on my home screen and then released the four finger position and be right back to the app I'm working in. Please change this in the next update back to the way it was!!!!!
I get the multitasking list (all prior apps, scrollable) and can switch to an app, swipe up to force it closed instead of "at rest" and can click back to the originating app in the same place i was prior to the swipe,
-
hi!
I am new to java .... learning how to use packages. I have created dir on my harddrive c:\learning\java ... in which i have created com\tests.... added c:\learning\java to path env variable .... And have written two java programs.
1. jmain.java
adds two integers and puts in another integer
public int sum()
2. jtest.java
main method ... and creates an object of jmain class ... and uses
jmain jm = jmain();
jm.sum();
Both these classes are in the same package com.tests and both jmain.java uses package com.tests;
and jtest.java uses package com.tests; import com.tests.*;
3. jmain compiles alright
but when compiling jtest.java compiler gives an error saying can't resolve symbol
symbol : jmain.class
path : com.tests.jtest
What to do now ???????? when i went to check my directory structure ... i am doing everything right.... using case okay, path is okay, etc
still running errors .... please suggest a solution.
thanks.I tried this ... it's giving me same error.
Please help.
I am on winXp so i added at the end of my path env var .... c:\learning\com\tests
//jmain.java
package com.tests;
public class jmain
public int x=4;
public int y=66;
public int sum = x+ y;
public printsum ()
System.out.println(sum);
//jtest.java
package com.tests;
import com.tests.*;
public class jtest
public static void main(String [] args)
jmain jm = jmain();
jm.printsum();
Above is my program. Both java files are in C:\learning\com\tests
And, is there a difference between CLASSPATH and setting environment variable or system variable ???? What is SOURCEPATH too ???
Please help
Thanks in advance. -
When I use the scissors tool to create a segment of a track, select the segment and bounce it, about 15-20 seconds of silence is added to the beginning of the bounce. What causes this?
Thanks for the replies. I reviewed them shortly after they were submitted but I'm also working on other projects at the same time (hence the delayed reply).
Building a time table and doing a cross join to my original resultset gave me the desired resultset of the months assigned between dates. What I can't figure out now is how to filter months I don't want.
Doing a cross join between my original resultset that had two dates:
08/27/2010
10/24/2011
and a calendar table that has 24 rows (each month for a two year period)
my new resultset looks like this:
I need to filter the rows in yellow as the months assigned for stage 3 that started on 8/27/2010 should stop when the patient was assigned to stage 4 on 10/24/2011.
You'll notice that Jan - Sept 2011 isn't listed for Stage 4 assigned on 10/24/2011 as I included a filter in the WHERE clause that states
the Months Assigned value must be greater than or equal to the date assigned value.
Any advice would be appreciated. -
Hello everyone, So When I use the eraser on a photo and try to save it as jpeg is makes is save it as a copy but the parts that I erased are replaced with a white background and thats not what I want
That may not be what you want, but Jpeg images are flattened, without transparency. Every pixel has a color value, with the default background usually being white. If you want to crate an image that leaves the erased area transparent, you will need to use an image format such as .gif or .pnc.
-
my keynote 09 version 5.3
i am using the arabic font albayan the problem is that when i use the build tool in the inspector the uper and the lower part of the word is gone i tryed to make the font smaller or adjust the position and that did not change so is there any way to fix this please because we can not use the build and the inspector tool like that ???!!!!!All iWork apps have bugs like this that make them generally unsuitable for RTL scripts like Arabic. All you can do is try a different font and see if the results are any better. Or try another app like OpenOffice or PowerPoint.
Let Apple know this needs to be fixed via
http://www.apple.com/feedback -
Deleting files when installing application using package maker
Hello,
I have made package maker for my application. It is made such that it will be installed in Application directory.
I want to delete directory at ~/Library/Application Support/TestApp.
This is necessary for me, because when user install my application i need to remove all the files that my application has created.
So, how can i use package maker to remove this files and folders if there exist?
Thanks
xmaxHi xmax
I'm not sure I understand your meaning.
When you drag a file (that you're going to install) into the left hand side of package maker, more options open up, including the ability to add pre and post flight scripts.
To change what your user will see during the installation process, run Package Maker and click on Edit Interface.
Bob -
Whine hiss at beginning of songs and when scrolling using the batt
I have the zen xtra 30gb and love it except when playing it using the battery it makes a whiny hiss at the bigging of the songs and when i am scrolling or using any buttons while nothing is playing. When i use the ac adapter no noise at all. the noise is only there using the battery. My wife has the 40 gb version and does'nt have this problem. I even switched batteries with hers to see if the battery was the problem but did'nt make a difference. Do I have a defecti've unit's
i dont think that is the battery making the noise...its most likely the hard dri've. I wouldnt be too concerned about it as long as it works fine
-
When I use google maps in my three laptops one with XP one with Vista and then one with win7 64 when it happens that when I want to move the map when the map starts scrolling uncontrolled one way that can not be stopped without turning off the google maps ?
When I use google maps in my three laptops one with XP one with Vista and then one with win7 64 when it happens that when I want to move the map when the map starts scrolling uncontrolled one way that can not be stopped without turning off the google maps ?
-
Using packaged functions in Apex
Hi,
I'm fairly new to apex and I am about to write an app which needs to access a SQL server database. My local dba has set up the transparent gateway and I can select from and update the SQLServer database no problem via a db link. What I need to decide is whether to code the sql for reports etc directly into the apex page or to call a pl/sql function returning a select statement. I would like to have all the code in packages as a lot of it will be used by multiple apps in future but is there any extra overhead in doing this:
declare
l_sql varchar2(4000);
begin
select package.function into l_sql from dual;
return l_sql;
end;
rather than coding the SQL directly in the page? Also is there a more efficient way of using packaged functions to select data rather that just have it returning sql statements.
Thanks in advance.
DaveHi
I only use function returning select when I have a strong reason to do so, because it is so much more difficult to test and maintain. Not sure about performance, but I think it is not that much worse.
If you simply want to reuse SELECT statements, you could use views instead.
Anyway, if you decide to use the package solution, at least you can make it much simpler -- just code like this in the page:
return package.function;
I hope this helps.
Luis -
Using package constants in package SQL - acts as bind variable or literal?
I'm looking for confirmation on the performance impact of using package constants in package SQL.
Let's say I have a number of queries in package code that refer to various literals that are prone to typos e.g. "CANCELLED" instead of "CANCELED". To reduce the chances of this happening, I have an APP_GLOBALS package where I declare constants for each literal:
C_CANCELED CONSTANT VARCHAR2(12) := 'CANCELED';And in queries that refer to literal 'CANCELED' I use APP_GLOBALS.C_CANCELED instead. This way the typo is caught during compilation. For example:
BEGIN
--Do something with all 'Canceled' orders
FOR r IN (SELECT order_id
FROM orders
WHERE status = APP_GLOBALS.C_CANCELED)
LOOP
END LOOP;
END;Assume that:
- the STATUS column is indexed
- the possible values are PENDING, APPROVED, CANCELED
- a small percentage of orders are CANCELED
From the optimizer's perspective is the query equivalent to
SELECT order_id
FROM orders
WHERE status = :varor
SELECT order_id
FROM orders
WHERE status = 'CANCELED'?
According to what I see in v$sqltext_with_newlines, it's the first one. Can anyone suggest an alternative way of replacing literals in package SQL to prevent typos? Worst case, I suppose I can start with constants so that it compiles successfully then do a global replace of the constants with the literals.Can anyone suggest an alternative way of replacing literals in package SQL to prevent typos?I cannot think of any. But, here is the thing. If the typos are there, then, it technically is a bug even though both the codes would compile. The bug will be hunted down when the program doesn't work as intended. Wouldn't most typos be caught in unit testing of the code?
Also, if you replace a string literal with a variable, then, maybe (just maybe, depending on your version of the dbms), it may end up picking a different execution plan. That might be an unintended consequence. -
Query response time takes more time when calling from package
SELECT
/* UTILITIES_PKG.GET_COUNTRY_CODE(E.EMP_ID,E.EMP_NO) COUNTRY_ID */
(SELECT DISTINCT IE.COUNTRY_ID
FROM DOCUMENT IE
WHERE IE.EMP_ID =E.EMP_ID
AND IE.EMP_NO = E.EMP_NO
AND IE.STATUS = 'OPEN' ) COUNTRY_ID
FROM EMPLOYEE E
CREATE OR REPLACE PACKAGE BODY UTILITIES_PKG AS
FUNCTION GET_COUNTRY_CODE(P_EMP_ID IN VARCHAR2, P_EMP_NO IN VARCHAR2)
RETURN VARCHAR2 IS
L_COUNTRY_ID VARCHAR2(25) := '';
BEGIN
SELECT DISTINCT IE.COUNTRY_ID
INTO L_COUNTRY_ID
FROM DOCUMENT IE
WHERE IE.EMP_ID = P_EMP_ID
AND IE.EMP_NO = P_EMP_NO
AND IE.STATUS = 'OPEN';
RETURN L_COUNTRY_ID;
EXCEPTION
WHEN OTHERS THEN
RETURN 'CONT';
END;
END UTILITIES_PKG;
when I run above query its coming in 1.2 seconds.but when comment subquery and call from package its taking 9 seconds.query returns more than 2000 records.i am not able to find the reason why it is taking more time when calling from package?You are getting a different plan when you run it as PL/SQL most likely. Comment your statement:
SELECT /* your comment here */then find them in V$SQL and get the SQL IDs. You can then use DBMS_XPLAN.DISPLAY_CURSOR to see what is actually happening.
http://www.psoug.org/reference/dbms_xplan.html -
When should be package invalidated?
Hello guys,
I would need again some help...
My question is: When exactly should be package invalidated?
Consider following situation:
We have two packages, one contains constants (in its specification), the other is reading these constants. Package is reading these constants in package body and package spec as well. Now, when I add a new constant to the first package and recompile it, should this invalidate the other package??? The new added constant is not used in the other package.
In reality, we have a Constant package, containing all constants in its specification. One package (test_pkg) is reading some constant let say form line 100. Now we add new constant let say to line 50. When we recompile the constant package, planty of packages get invalidated because they are reading from it. We recompile all invalid packages. However test_pkg is not invalidated!!! Now if we run the code from test_pkg, it is still reading the constant from line 100, so it is reading it from wrong place and the constant has wrong value! The only thing what help is to recompile the test_pkg.
So it looks like the reference to Constant package wasn't updated.
Why isn't test_pkg invalidated???
Oracle version:
SELECT * FROM V$VERSION;
Oracle Database 11g Release 11.2.0.1.0 - 64bit Production
PL/SQL Release 11.2.0.1.0 - Production
"CORE 11.2.0.1.0 Production"
TNS for Linux: Version 11.2.0.1.0 - Production
NLSRTL Version 11.2.0.1.0 - ProductionFrom my standard library of responses...
Packages tend to fail because of their "package state". A package has a "state" when it contains package level variables/constants etc. and the package is called. Upon first calling the package, the "state" is created in memory to hold the values of those variables etc. If an object that the package depends upon e.g. a table is altered in some way e.g. dropped and recreated, then because of the database dependencies, the package takes on an INVALID status. When you next make a call to the package, Oracle looks at the status and sees that it is invalid, then determines that the package has a "state". Because something has altered that the package depended upon, the state is taken as being out of date and is discarded, thus causing the "Package state has been discarded" error message.
If a package does not have package level variables etc. i.e. the "state" then, taking the same example above, the package takes on an INVALID status, but when you next make a call to the package, Oracle sees it as Invalid, but knows that there is no "state" attached to it, and so is able to recompile the package automatically and then carry on execution without causing any error messages. The only exception here is if the thing that the package was dependant on has changes in such a way that the package cannot compile, in which case you'll get an Invalid package type of error.
And if you want to know how to prevent discarded package states....
Move all constants and variables into a stand-alone package spec and reference those from your initial package. Thus when the status of your original package is invlidated for whatever reason, it has no package state and can be recompiled automatically, however the package containing the vars/const will not become invalidated as it has no dependencies, so the state that is in memory for that package will remain and can continue to be used.
As for having package level cursors, you'll need to make these local to the procedures/functions using them as you won't be able to reference cursors across packages like that (not sure about using REF CURSORS though.... there's one for me to investigate!)
This first example shows the package state being invalided by the addition of a new column on the table, and causing it to give a "Package state discarded" error...
SQL> set serveroutput on
SQL>
SQL> create table dependonme (x number)
2 /
Table created.
SQL>
SQL> insert into dependonme values (5)
2 /
1 row created.
SQL>
SQL> create or replace package mypkg is
2 procedure myproc;
3 end mypkg;
4 /
Package created.
SQL>
SQL> create or replace package body mypkg is
2 v_statevar number := 5; -- this means my package has a state
3
4 procedure myproc is
5 myval number;
6 begin
7 select x
8 into myval
9 from dependonme;
10
11 myval := myval * v_statevar;
12 DBMS_OUTPUT.PUT_LINE('My Result is: '||myval);
13 end;
14 end mypkg;
15 /
Package body created.
SQL>
SQL> exec mypkg.myproc
My Result is: 25
PL/SQL procedure successfully completed.
SQL>
SQL> select object_name, object_type, status from user_objects where object_name = 'MYPKG'
2 /
OBJECT_NAME
OBJECT_TYPE STATUS
MYPKG
PACKAGE VALID
MYPKG
PACKAGE BODY VALID
SQL>
SQL>
SQL> alter table dependonme add (y number)
2 /
Table altered.
SQL>
SQL> select object_name, object_type, status from user_objects where object_name = 'MYPKG'
2 /
OBJECT_NAME
OBJECT_TYPE STATUS
MYPKG
PACKAGE VALID
MYPKG
PACKAGE BODY INVALID
SQL>
SQL> exec mypkg.myproc
BEGIN mypkg.myproc; END;
ERROR at line 1:
ORA-04068: existing state of packages has been discarded
ORA-04061: existing state of package body "SCOTT.MYPKG" has been invalidated
ORA-06508: PL/SQL: could not find program unit being called: "SCOTT.MYPKG"
ORA-06512: at line 1
SQL>
SQL> select object_name, object_type, status from user_objects where object_name = 'MYPKG'
2 /
OBJECT_NAME
OBJECT_TYPE STATUS
MYPKG
PACKAGE VALID
MYPKG
PACKAGE BODY INVALID
SQL>
SQL> exec mypkg.myproc
PL/SQL procedure successfully completed.
SQL>
SQL> select object_name, object_type, status from user_objects where object_name = 'MYPKG'
2 /
OBJECT_NAME
OBJECT_TYPE STATUS
MYPKG
PACKAGE VALID
MYPKG
PACKAGE BODY VALIDAnd this next example shows how having the package variables in their own package spec, allows the package to automatically recompile when it is called even though it became invalidated by the action of adding a column to the table.
SQL> drop table dependonme
2 /
Table dropped.
SQL>
SQL> drop package mypkg
2 /
Package dropped.
SQL>
SQL> set serveroutput on
SQL>
SQL> create table dependonme (x number)
2 /
Table created.
SQL>
SQL> insert into dependonme values (5)
2 /
1 row created.
SQL>
SQL> create or replace package mypkg is
2 procedure myproc;
3 end mypkg;
4 /
Package created.
SQL>
SQL> create or replace package mypkg_state is
2 v_statevar number := 5; -- package state in seperate package spec
3 end mypkg_state;
4 /
Package created.
SQL>
SQL> create or replace package body mypkg is
2 -- this package has no state area
3
4 procedure myproc is
5 myval number;
6 begin
7 select x
8 into myval
9 from dependonme;
10
11 myval := myval * mypkg_state.v_statevar; -- note: references the mypkg_state package
12 DBMS_OUTPUT.PUT_LINE('My Result is: '||myval);
13 end;
14 end mypkg;
15 /
Package body created.
SQL>
SQL> exec mypkg.myproc
My Result is: 25
PL/SQL procedure successfully completed.
SQL>
SQL> select object_name, object_type, status from user_objects where object_name = 'MYPKG'
2 /
OBJECT_NAME
OBJECT_TYPE STATUS
MYPKG
PACKAGE VALID
MYPKG
PACKAGE BODY VALID
SQL>
SQL> alter table dependonme add (y number)
2 /
Table altered.
SQL>
SQL> select object_name, object_type, status from user_objects where object_name = 'MYPKG'
2 /
OBJECT_NAME
OBJECT_TYPE STATUS
MYPKG
PACKAGE VALID
MYPKG
PACKAGE BODY INVALID
SQL>
SQL> exec mypkg.myproc
My Result is: 25
PL/SQL procedure successfully completed. -
Using package functions in an update
Okay, I have a package function that returns a correct value when used in a SELECT, but when used in an UPDATE, it returns Null. Why can't I used its result in the UPDATE?
Package Spec
FUNCTION fpub_get_contract_attribute
( n_contract_id_in IN CONTRACT.CONTRACT_ID%TYPE,
s_attribute_in IN VARCHAR2 )
RETURN VARCHAR2;
PRAGMA RESTRICT_REFERENCES(fpub_get_contract_attribute,TRUST,WNDS);
Source :
clear;
rollback;
select
contract_functions.fpub_get_contract_attribute(CONTRACT_ID,'ORIGINAL_SALES_CHANNEL') "Before",
original_sales_channel
from contract
where contract_id = 52549615;
update contract
set original_sales_channel = NVL(contract_functions.fpub_get_contract_attribute(CONTRACT_ID,'ORIGINAL_SALES_CHANNEL'),'Null')
where contract_id = 52549615;
select
NVL(contract_functions.fpub_get_contract_attribute(52549615,'ORIGINAL_SALES_CHANNEL'),'Null') "After",
original_sales_channel
from contract
where contract_id = 52549615;
rollback;
Result :
Rollback complete
Before ORIGINAL_SALES_CHANNEL
RE
1 row updated
After ORIGINAL_SALES_CHANNEL
Null Null
Rollback completeAny ideas?
Thanks,
JasonPragma restrict_references has not been required since 8i, so you can get rid of that. However, certain things will still be enforced, with or without the pragma. For example, you cannot perform DML from within a packaged function when that function is used in a select statement, although you can perform DML within a packaged function when it is used in an update statement. So, if you are performing some sort of DML in your function, it would not raise an error when used in the update statement, but would cause it to return whatever is specified in the exception block when used in a select statement, causing the different results.
Please see the demonstration below in which I have created a sample function that contains an insert statement. When I use the function from a select statement, it raises an error and does not insert a row. However, when I use the function in an update statement, it does not raise an error and inserts a row. I have then added an exception clause to the function and re-tested. When I used the function in a select statement, it now returns the value in the exception block, but still does not insert a row. When I used the function in an update statement, it returns a different value, not from the exception block, and inserts a row. Then I removed the insert statement from the function and re-tested. Now it returns the same value, whether used in a select statement or an update statement.
scott@ORA92> SELECT banner FROM v$version
2 /
BANNER
Oracle9i Enterprise Edition Release 9.2.0.1.0 - Production
PL/SQL Release 9.2.0.1.0 - Production
CORE 9.2.0.1.0 Production
TNS for 32-bit Windows: Version 9.2.0.1.0 - Production
NLSRTL Version 9.2.0.1.0 - Production
scott@ORA92> CREATE TABLE test
2 (col1 VARCHAR2(30))
3 /
Table created.
scott@ORA92> CREATE TABLE contract
2 (contract_id NUMBER,
3 original_sales_channel VARCHAR2(30))
4 /
Table created.
scott@ORA92> INSERT INTO contract (contract_id) VALUES (52549615)
2 /
1 row created.
scott@ORA92> COMMIT
2 /
Commit complete.
scott@ORA92> CREATE OR REPLACE PACKAGE contract_functions
2 AS
3 FUNCTION fpub_get_contract_attribute
4 (n_contract_id_in IN CONTRACT.CONTRACT_ID%TYPE,
5 s_attribute_in IN VARCHAR2 )
6 RETURN VARCHAR2;
7 END contract_functions;
8 /
Package created.
scott@ORA92> SHOW ERRORS
No errors.
scott@ORA92> -- test with insert statement and no exception handling:
scott@ORA92> CREATE OR REPLACE PACKAGE BODY contract_functions
2 AS
3 FUNCTION fpub_get_contract_attribute
4 (n_contract_id_in IN CONTRACT.CONTRACT_ID%TYPE,
5 s_attribute_in IN VARCHAR2 )
6 RETURN VARCHAR2
7 IS
8 BEGIN
9 INSERT INTO test (col1) VALUES ('inserting');
10 RETURN 'Null';
11 END fpub_get_contract_attribute;
12 END contract_functions;
13 /
Package body created.
scott@ORA92> SHOW ERRORS
No errors.
scott@ORA92> SELECT * FROM contract
2 /
CONTRACT_ID ORIGINAL_SALES_CHANNEL
52549615
scott@ORA92> COLUMN "Before" FORMAT A30
scott@ORA92> select contract_functions.fpub_get_contract_attribute (CONTRACT_ID, 'ORIGINAL_SALES_CHANNEL') "Before",
2 original_sales_channel
3 from contract
4 where contract_id = 52549615
5 /
select contract_functions.fpub_get_contract_attribute (CONTRACT_ID, 'ORIGINAL_SALES_CHANNEL') "Before",
ERROR at line 1:
ORA-14551: cannot perform a DML operation inside a query
ORA-06512: at "SCOTT.CONTRACT_FUNCTIONS", line 9
scott@ORA92> SELECT * FROM test
2 /
no rows selected
scott@ORA92> update contract
2 set original_sales_channel = NVL (contract_functions.fpub_get_contract_attribute (CONTRACT_ID, 'ORIGINAL_SALES_CHANNEL'), 'Null')
3 where contract_id = 52549615
4 /
1 row updated.
scott@ORA92> SELECT * FROM test
2 /
COL1
inserting
scott@ORA92> COLUMN "After" FORMAT A30
scott@ORA92> select contract_functions.fpub_get_contract_attribute (CONTRACT_ID, 'ORIGINAL_SALES_CHANNEL') "After",
2 original_sales_channel
3 from contract
4 where contract_id = 52549615
5 /
select contract_functions.fpub_get_contract_attribute (CONTRACT_ID, 'ORIGINAL_SALES_CHANNEL') "After",
ERROR at line 1:
ORA-14551: cannot perform a DML operation inside a query
ORA-06512: at "SCOTT.CONTRACT_FUNCTIONS", line 9
scott@ORA92> SELECT * FROM test
2 /
COL1
inserting
scott@ORA92> --
scott@ORA92> -- repeat test with insert statement and exception handling:
scott@ORA92> ROLLBACK
2 /
Rollback complete.
scott@ORA92> CREATE OR REPLACE PACKAGE BODY contract_functions
2 AS
3 FUNCTION fpub_get_contract_attribute
4 (n_contract_id_in IN CONTRACT.CONTRACT_ID%TYPE,
5 s_attribute_in IN VARCHAR2 )
6 RETURN VARCHAR2
7 IS
8 BEGIN
9 INSERT INTO test (col1) VALUES ('inserting');
10 RETURN 'Null';
11 EXCEPTION
12 WHEN OTHERS THEN RETURN 'RE';
13 END fpub_get_contract_attribute;
14 END contract_functions;
15 /
Package body created.
scott@ORA92> SHOW ERRORS
No errors.
scott@ORA92> select contract_functions.fpub_get_contract_attribute (CONTRACT_ID, 'ORIGINAL_SALES_CHANNEL') "Before",
2 original_sales_channel
3 from contract
4 where contract_id = 52549615
5 /
Before ORIGINAL_SALES_CHANNEL
RE
scott@ORA92> SELECT * FROM test
2 /
no rows selected
scott@ORA92> update contract
2 set original_sales_channel = NVL (contract_functions.fpub_get_contract_attribute (CONTRACT_ID, 'ORIGINAL_SALES_CHANNEL'), 'Null')
3 where contract_id = 52549615
4 /
1 row updated.
scott@ORA92> SELECT * FROM test
2 /
COL1
inserting
scott@ORA92> select contract_functions.fpub_get_contract_attribute (CONTRACT_ID, 'ORIGINAL_SALES_CHANNEL') "After",
2 original_sales_channel
3 from contract
4 where contract_id = 52549615
5 /
After ORIGINAL_SALES_CHANNEL
RE Null
scott@ORA92> SELECT * FROM test
2 /
COL1
inserting
scott@ORA92> --
scott@ORA92> -- repeat test with no insert statement and no exception handling:
scott@ORA92> ROLLBACK
2 /
Rollback complete.
scott@ORA92> CREATE OR REPLACE PACKAGE BODY contract_functions
2 AS
3 FUNCTION fpub_get_contract_attribute
4 (n_contract_id_in IN CONTRACT.CONTRACT_ID%TYPE,
5 s_attribute_in IN VARCHAR2 )
6 RETURN VARCHAR2
7 IS
8 BEGIN
9 RETURN 'Null';
10 END fpub_get_contract_attribute;
11 END contract_functions;
12 /
Package body created.
scott@ORA92> SHOW ERRORS
No errors.
scott@ORA92> select contract_functions.fpub_get_contract_attribute (CONTRACT_ID, 'ORIGINAL_SALES_CHANNEL') "Before",
2 original_sales_channel
3 from contract
4 where contract_id = 52549615
5 /
Before ORIGINAL_SALES_CHANNEL
Null
scott@ORA92> SELECT * FROM test
2 /
no rows selected
scott@ORA92> update contract
2 set original_sales_channel = NVL (contract_functions.fpub_get_contract_attribute (CONTRACT_ID, 'ORIGINAL_SALES_CHANNEL'), 'Null')
3 where contract_id = 52549615
4 /
1 row updated.
scott@ORA92> SELECT * FROM test
2 /
no rows selected
scott@ORA92> select contract_functions.fpub_get_contract_attribute (CONTRACT_ID, 'ORIGINAL_SALES_CHANNEL') "After",
2 original_sales_channel
3 from contract
4 where contract_id = 52549615
5 /
After ORIGINAL_SALES_CHANNEL
Null Null
scott@ORA92> SELECT * FROM test
2 /
no rows selected
scott@ORA92>
Maybe you are looking for
-
How to export bookmaks from an old hard drive
my old computer crashed i removed the hard drive to extract files and i cannot find my book marks i pick up an drive kit so i can hook up my old drive via usb and i have found no help for anyone doing it this way i was running xp and i dont remember
-
OK, here is the dilemma, and i bet there is a nifty shortcut to it. We all know how to continue select say object or points within illustrator yes, in saying this we will select one point, and then use thte mouse to select more points by covering spa
-
No connection with iPad but iPhone works? Express network is found
It finds The express but not The network
-
PPDS production order dates mismatch between APO and R3
Hi Friends, We are facing one problem regarding production order date mish match between R3 and APO systems specific to a product. The product is planned in PPDS and the order automatically transfer to R3 through online CIF. PPM has got two operation
-
ARD 3.2.2 & Unix
We have close to 35 Mac's under control of ARD 3.2.2, that are set to turn on at 6 in the morning, and off at 8pm Monday thru Friday. However when holiday's come along, we need machines off for the holidays. So I'm using a Unix command "pmset" to set