PL/SQL Package
Hi Varad,
I have anothe question related to the same package you helped me with yestarday. I need to calculate the function total_balance , there is a function in the package (*function total_balanceformula*) to calculate the total_balance, and I need your help to make it work.
Regards,
Ribhi
create or replace PACKAGE Accnt101 AS
from_date date;
to_date date;
emp_code number;
balance number := 0 ;
function postive_amountformula(TYPE in number, amount in number) return number ;
function negative_amountformula(TYPE in number, amount in number) return number ;
function BeforeReport return boolean ;
function total_balanceformula(total_balance in number, TYPE in number, negative_amount in number, postive_amount in number, amount in number) return number ;
Function balance_p return number;
END Accnt101;
----Package Body----------------
create or replace PACKAGE BODY Accnt101 AS
function postive_amountformula(TYPE in number, amount in number) return number is
begin
if ((TYPE>26 and TYPE<35)
or (TYPE=17))
then
return(amount);
elsif (type = 70)and (amount >=0) then
return (amount) ;
elsif (type = 72)and (amount >=0) then
return (amount) ;
elsif (type = 73)and (amount >=0) then
return (amount) ;
elsif (type = 74)and (amount >=0) then
return (amount) ;
elsif (type = 60)and (amount >=0) then
return (amount) ;
else
return (null) ;
end if;
RETURN NULL; end;
function negative_amountformula(TYPE in number, amount in number) return number is
begin
if ((TYPE>7 and TYPE<16)
or (TYPE >34 and TYPE <43)
or (TYPE=7)
or (TYPE=18)
or (type=21)
or (type=24)
or (type= 81)
or (type=82))
then
return(amount);
elsif (type = 70)and (amount <0) then
return (abs (amount)) ;
elsif (type = 72)and (amount <0) then
return (abs (amount)) ;
elsif (type = 73)and (amount <0) then
return (abs (amount)) ;
elsif (type = 74)and (amount <0) then
return (abs (amount)) ;
elsif (type = 60)and (amount <0) then
return (abs(amount)) ;
else
return (null) ;
end if;
RETURN NULL; end;
function BeforeReport return boolean is
var_pos number(15,3) ;
var_neg number(15,3) ;
beg_bal number(15,3) ;
Begin
begin
select sum (nvl(amount,0)) into beg_bal
from EMPLOYEE_TRANSACTI
where (TYPE=99 or type = 92 or type = 93 or type = 94)
and to_char(from_date,'YYYY')=to_char(date0,'YYYY')
and FK_EMPLOYEENUMBER0=emp_code;
EXCEPTION
WHEN NO_DATA_FOUND THEN
beg_bal := 0;
end;
begin
select sum(nvl(amount,0)) into var_pos
from EMPLOYEE_TRANSACTI
where
(TYPE=17
or type=60
OR TYPE=70
oR TYPE=72
OR TYPE=73
OR TYPE=74
or (TYPE>26 and TYPE<35))
and fk_vouchervalue_da<from_date
and fk_vouchervalue_da>= trunc(from_date,'year')
and FK_EMPLOYEENUMBER0=emp_code;
EXCEPTION
WHEN NO_DATA_FOUND THEN
var_pos := 0;
end;
Begin
select sum(nvl(amount,0)) into var_neg
from EMPLOYEE_TRANSACTI
where ((TYPE>7 and TYPE<16)
or (TYPE >34 and TYPE <43)
or (TYPE=7)
or (TYPE=18)
or (type=21)
or (type=24)
or (type= 81)
or (type=82) )
and fk_vouchervalue_da<from_date
and fk_vouchervalue_da>= trunc(from_date,'year')
and FK_EMPLOYEENUMBER0=emp_code;
balance :=nvl(beg_bal,0) + nvl(var_pos,0) - nvl(var_neg,0);
return(true);
EXCEPTION
WHEN NO_DATA_FOUND THEN
balance :=nvl(beg_bal,0) + nvl(var_pos,0) - nvl(var_neg,0);
RETURN (TRUE);
end;
RETURN NULL; end;
function total_balanceformula(total_balance in number, TYPE in number, negative_amount in number, postive_amount in number, amount in number) return number is
begin
if total_balance is null then
if ((TYPE>7 and TYPE<16)
or (TYPE >34 and TYPE <43)
or (TYPE=7)or (TYPE=18)
or (type=21) or (type=24)
or (type= 81)
or (type=82))
then
return(balance-negative_amount);
elsif ((TYPE>26 and TYPE<35) or (TYPE=17))
then
return(balance+postive_amount);
elsif (type=70 or type=72 or type=73 or type=74
or type=60) and (amount >=0) then
return(balance+postive_amount);
elsif (type=70 or type=72 or type=73 or type=74
or type=60) and (amount <0) then
return(balance-negative_amount);
end if;
else
if ((TYPE>7 and TYPE<16)
or (TYPE >34 and TYPE <43)
or (TYPE=7)or (TYPE=18)
or (type=21) or (type=24)
or (type= 81)
or (type=82))
then
return(total_balance-negative_amount);
elsif ((TYPE>26 and TYPE<35) or (TYPE=17))
then
return(total_balance+postive_amount);
elsif (type=70 or type=72 or type=73 or type=74
or type=60) and (amount >=0) then
return(total_balance+postive_amount);
elsif (type=70 or type=72 or type=73 or type=74
or type=60) and (amount <0) then
return(total_balance-negative_amount);
end if;
end if ;
RETURN NULL; end;
Functions to refer Oracle report placeholders
Function balance_p return number is
Begin
return balance;
END;
END Accnt101
Varad,
I'm using the query below. This query works fine if the field Amount has the right sing (-/+), The Amount. Transaction type determins if the Amount is positive or negative.
Regards,
Ribhi
select FK_VOUCHERSERIAL_N,
FK_VOUCHERVALUE_DA,
DESCRIPTION,
nvl(AMOUNT,0) amount,
TYPE,
Accnt101.postive_amountformula(TYPE, nvl(AMOUNT,0)) CREDIT,
Accnt101.negative_amountformula(TYPE, nvl(AMOUNT,0)) DEBIT,
--accnt101.total_balanceformula(:total_balance,TYPE,:Credit,:Debit,Amount) total_balance,
sum(adj_sal) over(order by FK_VOUCHERVALUE_DA asc, FK_VOUCHERSERIAL_N asc, type desc) r_sum_sal
from(
select FK_VOUCHERSERIAL_N,
FK_VOUCHERVALUE_DA,
DESCRIPTION,
nvl(AMOUNT,0) amount,
Accnt101.postive_amountformula(TYPE, nvl(AMOUNT,0)) CREDIT,
Accnt101.negative_amountformula(TYPE, nvl(AMOUNT,0)) DEBIT,
--accnt101.total_balanceformula(:total_balance,TYPE,:Credit,:Debit,Amount) total_balance,
TYPE,
decode(rank() over (order by FK_VOUCHERVALUE_DA asc, FK_VOUCHERSERIAL_N asc, type desc),1,amount + :P5_balance,amount) adj_sal
from EMPLOYEE_TRANSACTI
where FK_EMPLOYEENUMBER0=:P5_emp_code
and STATUS=1
and FK_VOUCHERVALUE_DA<=:P5_to_date
and FK_VOUCHERVALUE_DA>=:P5_from_date
and ((TYPE >7 and TYPE <16)
or (TYPE >34 and TYPE <43)
or (TYPE =7)
or (TYPE =18)
or (TYPE >26 and TYPE <35)
or (TYPE =17)
OR (TYPE = 60)
OR (TYPE = 70)
OR (TYPE = 72)
OR (TYPE = 73)
OR (TYPE = 74)
or (type = 21)
or (type =24)
or (type = 81)
or (type = 82))
order by FK_VOUCHERVALUE_DA asc, FK_VOUCHERSERIAL_N asc, type desc
Similar Messages
-
The -dataSource parameter in assemble a web service from a PL/SQL package
When I use Web Service Assembler to assemble a Web Service from a PL/SQL package, I need to specify the dataSource parameter, e.g.:
java -jar wsa.jar -plsqlAssemble -sql pkgname -dataSource jdbc/MyDS -dbConnection ... -dbUser scott/tiger ....
The dataSource also needs to be pre-configured in the data-sources.xml in OC4J.
I am wondering why dataSource is needed here because the database connection information is already specified on the commandline ( dbConnection and dbUser).
If I have to specify dataSource, how do I configure data-sources.xml dynamically at run-time (e.g., adding entries)?
Thanks,
JimThe -dataSource parameter specifies the data-sources.xml entry used at runtime. The database connection info is only for design time use. Typically you make sure data-sources.xml contains an entry with jndi-location of the same name you specifies for -dataSource. To configure data-sources.xml at runtime, it is out of the scope of web services. Please refer to OC4J admin guide. You can probably modify the data-sources.xml file and force OC4J to reconfigure based on the new data-sources.xml file.
-
Creating PL/SQL Package with all the types
CREATE OR REPLACE
TYPE rec_type AS OBJECT (
first_name VARCHAR2(20),
last_name VARCHAR2(20)
CREATE OR REPLACE
TYPE REC_TYPE_TAB AS TABLE OF rec_type
I am able to create the above types in oracle and used in PL/SQL packages. And like this I have somany types. I would like to if I can create a package with the types to make the life easier. Could you please tell me how to do it.
your help is greately appreciated..
--Krishsb92075 wrote:
TYPE add only aggravation, complexity, & should be avoidedI disagree.
When used correctly types can be the simplest solution.
For example when passing multiple values to a stored procedure. Avoiding the type in the below example would lead to further complexity and aggravation not lessen it.
SQL> create or replace procedure p
2 (
3 p_object_list in sys.odcivarchar2list,
4 p_result out sys_refcursor
5 ) as
6 begin
7 open p_result for
8 select owner, object_name, object_type
9 from all_objects
10 where object_name in
11 (
12 select column_value from
13 table(p_object_list)
14 )
15 order by
16 owner, object_name, object_type;
17 end;
18 /
Procedure created.
SQL> exec p(sys.odcivarchar2list('DUAL','ALL_OBJECTS'),:c)
PL/SQL procedure successfully completed.
SQL> print c
OWNER OBJECT_NAME OBJECT_TYPE
PUBLIC ALL_OBJECTS SYNONYM
PUBLIC DUAL SYNONYM
SYS ALL_OBJECTS VIEW
SYS DUAL TABLE -
Hello,
The problem I am confronted with is reusing generated models.
In the process of DataMinig several steps are used: prepare data, Attribute selection (using AI), and building, testing and applying models.
If PL/SQL packages are used two problems occur:
First: Long, hand driven process of building:
Model generation in ODM,
PL/SQL package building in ODM and Export to SQL file,
importing package to DB, compiling and running.
I am sorry, but I don't understand why is it necessary to export PL/SQL packages in a file? As if these products aren't both Oracle products?
Second: If data (in time) changes and AI selects new attributes, then all next steps fail, since column names, and even some values, are hard coded! Therefore it is necessary to go trough the build and export process all over again. This really hurts.
Do you have a suggestion how to get around this problem?
I already considered using a SPSS Clementine, but since it is not an Oracle product I still believe, the original Oracle solution should give me some advantages.
Oh and another issue.
I tried using PL/SQL generator (Ver.: 10.1.3.0.17) in JDeveloper (ver.: 10.1.3.0.4), but it gave me an error:
java.lang.NoClassDefFoundError: oracle/dmt/dm4j/DM4JConnectionManager
at oracle.dmt.dm4j.extension.CodeGenerator.invoke(Unknown Source)
at oracle.ide.wizard.WizardManager.invokeWizard(WizardManager.java:310)
at oracle.ide.wizard.WizardManager$2.run(WizardManager.java:358)
at oracle.ide.util.IdeUtil.invokeAfterRepaint(IdeUtil.java:1093)
at oracle.ide.wizard.WizardManager$1.run(WizardManager.java:366)
at oracle.ide.util.IdeUtil$1$1.run(IdeUtil.java:1073)
at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:209)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:461)
at java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchThread.java:242)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:163)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:157)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:149)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:110)
Thanks for the reply,
IgorHi,
The code generation available in ODMr would allow you to deploy the build, apply or test process as generated code.
I am not sure what your application goal is, but if you simply want to deploy a model be used in an apply process that is rather straight forward.
You would build the model using ODMr. Then create an Apply Activity, again using ODMr.
The Apply Activity can then be used to generate code (pl/sql) using the JDev RTM release (10.1.3.2 or above). We will also have a version that will work with SQLDev shortly.
The generated code is immediately placed into the db for you.
If you want to score in a separate db you can either create a db link from that db or move both the model and the apply pl/sql code to the new db (using dba utilities).
If you want to rebuild a model, where you would add/remove attributes, change transformations etc. then you will have to regenerate the code.
If you simply want to rebuild the model without changing any transformations and settings you could also deploy the model build generated code.
As for the JDev failure, we are going to look into that. Have you tried the JDev 10.1.3.3 release available on the Oracle web site?
Thanks, Mark -
Creating PL/SQL package in SQL Developer 4.0.0.12
Hi,
I have built a model in SQL Developer 4.0.0.12 and I want to create it's PL/SQL package.
In ODMiner 11.1.0.4 from "Tools" > "Create pl/sql package" I can get a script for creating package and every thing is OK.
but in SQL Developer I select "Deploy" from every node's context menu and it generates a folder containing some scripts related to every node. I don't see any relevant script for creating any package.
How can I create relevant PL/SQL package from my workflow?
Thank you for any help you can provide in this situation.Please refer to this White paper for how to generate PL/SQL package for workflow deployment:
Oracle Data Miner (Extension of SQL Developer 4.0)
Generate a PL/SQL script for workflow deployment
http://www.oracle.com/technetwork/database/options/advanced-analytics/odmrcodegenwhitepaper-2042206.pdf -
How to get changes of a custom PL/SQL package updated in ISG?
Hi All,
I need some help on how to change a custom PL/SQL package in ISG integration repository:
I already uploaded my custom PL/SQL package to the integration repositoy some time ago. Now I have made some changes to PL/SQL record/table types defined in the package (added some fields and removed some others). These changed record/table types are used by a procedure I already uploaded to the integration repository. When regenerating the WSDL for my PL/SQL package in integration repository I get an error that the wrapper for respective procedure can't be found. When checking up the SQL types that were automatically generated (by JPublisher) for corresponding PL/SQL types, these generated SQL types are invalid...
So it seems that in one case JPublisher generated an empty SQL type (with no attributes). In another case JPublisher generated the SQL type with old attribute list, so it didn't adopt the changes of corresponding PL/SQL type in the package...
Can anybody tell me how to get the changes of a cusotm PL/SQL package updated in ISG? Or is there any possibility to first remove a whole PL/SQL package from the ISG integration repository (and getting rid of all old automatically generated SQL types), so that I can newly upload my PL/SQL package afterwards?
Thanks
Konrad
Edited by: Konrad on 24.10.2011 10:51Thanks Daniel, for your reply...
(-> for info: I'm a colleague of Konrad...)
Yes, we used a higher version number - and the upload of iLDT file works fine...
But, the problem occured when generating the WSDL...
However, I think we have found an approach of how to get the changes of a custom PL/SQL package updated correctly in ISG:
1. Save a copy of PL/SQL package and then delete it in the database
2. Regenerate the WSDL for PL/SQL package in ISG (seems that all atutomatically generated JPub wrappers and SQL types are also deleted)
3. Restart all processes
4. Create the changed version of PL/SQL package in the database again
5. upload of iLDT
6. Regenerate the WSDL for PL/SQL package in ISG
Best Regards
Carolin -
Creating a webservice from PL/SQL Package in JDev 11g
Hi All...
I have a PL/SQl package and I am using JDEv 11g. I want to create it as a webservice. I want to deploy it in a remote server. Can I deploy it from my client machine. In server Weblogic already started. What are the prerequisites, that we need to deploy a wbservice. I done the following steps.
1. Create an application.
2. Right click the package and select Generate Java option.
3. It create a Java class in the Application sources.
4. Double click the class and select Create Web Service. It created the web service.
5. When I select the webservice and click Run it shows the following error. It going to the Default \server. Actually I need it in a remote server.
[Running application NewWebService on Server Instance DefaultServer...]
---- Deployment started. ---- Apr 20, 2009 1:15:40 PM
Target platform is (Weblogic 10.3).
Running dependency analysis...
2009-04-20 13:15:40.205: Writing WAR file to D:\Oracle\Middleware\jdeveloper\system\system11.1.1.0.31.51.88\o.j2ee\drs\NewWebService\NewWebService-LastNoWebService-webapp
2009-04-20 13:15:40.222: Wrote WAR file to D:\Oracle\Middleware\jdeveloper\system\system11.1.1.0.31.51.88\o.j2ee\drs\NewWebService\NewWebService-LastNoWebService-webapp
2009-04-20 13:15:40.357: Writing EAR file to D:\Oracle\Middleware\jdeveloper\system\system11.1.1.0.31.51.88\o.j2ee\drs\NewWebService
2009-04-20 13:15:40.374: Wrote EAR file to D:\Oracle\Middleware\jdeveloper\system\system11.1.1.0.31.51.88\o.j2ee\drs\NewWebService
Deploying Application...
<Apr 20, 2009 1:15:40 PM IST> <Warning> <J2EE> <BEA-160195> <The application version lifecycle event listener oracle.security.jps.wls.listeners.JpsAppVersionLifecycleListener is ignored because the application NewWebService is not versioned.>
<Apr 20, 2009 1:15:40 PM IST> <Error> <Deployer> <BEA-149265> <Failure occurred in the execution of deployment request with ID '1240213540593' for task '3'. Error is: 'java.lang.ClassNotFoundException: sqlj.runtime.ref.DefaultContext'
java.lang.ClassNotFoundException: sqlj.runtime.ref.DefaultContext
at weblogic.utils.classloaders.GenericClassLoader.findLocalClass(GenericClassLoader.java:283)
at weblogic.utils.classloaders.GenericClassLoader.findClass(GenericClassLoader.java:256)
at weblogic.utils.classloaders.ChangeAwareClassLoader.findClass(ChangeAwareClassLoader.java:54)
at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
at java.lang.ClassLoader.loadClass(ClassLoader.java:251)
Truncated. see log file for complete stacktrace
java.lang.ClassNotFoundException: sqlj.runtime.ref.DefaultContext
at weblogic.utils.classloaders.GenericClassLoader.findLocalClass(GenericClassLoader.java:283)
at weblogic.utils.classloaders.GenericClassLoader.findClass(GenericClassLoader.java:256)
at weblogic.utils.classloaders.ChangeAwareClassLoader.findClass(ChangeAwareClassLoader.java:54)
at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
at java.lang.ClassLoader.loadClass(ClassLoader.java:251)
Truncated. see log file for complete stacktrace
>
<Apr 20, 2009 1:15:40 PM IST> <Warning> <Deployer> <BEA-149004> <Failures were detected while initiating deploy task for application 'NewWebService'.>
<Apr 20, 2009 1:15:40 PM IST> <Warning> <Deployer> <BEA-149078> <Stack trace for message 149004
java.lang.ClassNotFoundException: sqlj.runtime.ref.DefaultContext
at weblogic.utils.classloaders.GenericClassLoader.findLocalClass(GenericClassLoader.java:283)
at weblogic.utils.classloaders.GenericClassLoader.findClass(GenericClassLoader.java:256)
at weblogic.utils.classloaders.ChangeAwareClassLoader.findClass(ChangeAwareClassLoader.java:54)
at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
at java.lang.ClassLoader.loadClass(ClassLoader.java:251)
Truncated. see log file for complete stacktrace
java.lang.ClassNotFoundException: sqlj.runtime.ref.DefaultContext
at weblogic.utils.classloaders.GenericClassLoader.findLocalClass(GenericClassLoader.java:283)
at weblogic.utils.classloaders.GenericClassLoader.findClass(GenericClassLoader.java:256)
at weblogic.utils.classloaders.ChangeAwareClassLoader.findClass(ChangeAwareClassLoader.java:54)
at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
at java.lang.ClassLoader.loadClass(ClassLoader.java:251)
Truncated. see log file for complete stacktrace
>
[Deployer:149034]An exception occurred for task [Deployer:149026]deploy application NewWebService on DefaultServer.: sqlj.runtime.ref.DefaultContext.
weblogic.application.WrappedDeploymentException: sqlj.runtime.ref.DefaultContext
#### Deployment incomplete. #### Apr 20, 2009 1:15:40 PM
oracle.jdeveloper.deploy.DeployException
at oracle.jdevimpl.deploy.common.Jsr88RemoteDeployer.doDeploymentAction(Jsr88RemoteDeployer.java:247)
at oracle.jdevimpl.deploy.common.Jsr88RemoteDeployer.deployImpl(Jsr88RemoteDeployer.java:157)
at oracle.jdeveloper.deploy.common.AbstractDeployer.deploy(AbstractDeployer.java:94)
at oracle.jdevimpl.deploy.fwk.WrappedDeployer.deployImpl(WrappedDeployer.java:39)
at oracle.jdeveloper.deploy.common.AbstractDeployer.deploy(AbstractDeployer.java:94)
at oracle.jdeveloper.deploy.common.BatchDeployer.deployImpl(BatchDeployer.java:82)
at oracle.jdeveloper.deploy.common.AbstractDeployer.deploy(AbstractDeployer.java:94)
at oracle.jdevimpl.deploy.fwk.WrappedDeployer.deployImpl(WrappedDeployer.java:39)
at oracle.jdeveloper.deploy.common.AbstractDeployer.deploy(AbstractDeployer.java:94)
at oracle.jdevimpl.deploy.fwk.DeploymentManagerImpl.deploy(DeploymentManagerImpl.java:436)
at oracle.jdeveloper.deploy.DeploymentManager.deploy(DeploymentManager.java:209)
at oracle.jdevimpl.runner.adrs.AdrsStarter$5$1.run(AdrsStarter.java:1365)
Caused by: oracle.jdeveloper.deploy.DeployException
at oracle.jdevimpl.deploy.common.Jsr88DeploymentHelper.deployApplication(Jsr88DeploymentHelper.java:413)
at oracle.jdevimpl.deploy.common.Jsr88RemoteDeployer.doDeploymentAction(Jsr88RemoteDeployer.java:238)
... 11 more
Caused by: oracle.jdeveloper.deploy.DeployException: Deployment Failed
at oracle.jdevimpl.deploy.common.Jsr88DeploymentHelper.deployApplication(Jsr88DeploymentHelper.java:395)
... 12 more
#### Cannot run application NewWebService due to error deploying to DefaultServer.
[Application NewWebService stopped and undeployed from Server Instance DefaultServer]
6. when i goto the consoleof weblogic server, already an instance created. But nothing displayed under WebServices.
7. Select the instance and press 'Start'. While deploying an error came.
java.lang.Exception: [DeploymentService:290049]Deploy failed for id '1,240,213,727,265' since no targets are reachable.
Please help me..
its very urgent...
Regards,
Resmi.Oh, no - another very urgent question. The world must be about to end ;)
Resmi, Have a read of [url http://forums.oracle.com/forums/thread.jspa?threadID=883293]this - JDeveloper 11g, as of today, doesn't (at least is not supposed to) support publishing PL/SQL procedures/packages as a web service.
John -
How to Print the Value of a variable inside a PL/SQL package
Hi Friends,
Here is my Scenario
I have a PL/SQL Package. Let us call it Baseline Package.
This Package includes a dynamically built merge Statement.
Execute Immediate v_merge_query.
I have a procedure which replaces which few Keywords from the Package Text and Creates a new one depending on Inputs I provide. (This is something like a Code generator)
Now while Creating the new package, I need to print the Value of v_merge_query.... I Need s Static Query to be Printed inside the new package and not a dynamic query.
My Question is "Is there a way to print the value of the variable inside a different PL/SQL package?
Thanks in Advance,
MohitPrint where?
That PL/SQL code is server-side code. It runs in an Oracle server process.
That server process does not have a keyboard. Or a screen/monitor. Or display canvas. Or an attached printer.
That server process is incapable of "printing" as that is not its job or responsibility and not part of its environment.
What is can do is record data for the client to look at afterwards. This can be done using static PL/SQL session variables. Or a SQL table.
The former is done by DBMS_OUTPUT - a very primitive interface for writing text into a static PL/SQL string array. That btw resides in expensive private process server memory. The client can query the array after a database call and render the contents.
PS. Also keep in mind that bind variables are critical for performance and server robustness - especially when (ab)using dynamic SQL. -
Invoking Web Service From PL SQL package
Below is the sample code to invoke web service from pl/sql package using UTL_HTTP:
Declare
http_req UTL_HTTP.req;
http_resp UTL_HTTP.resp;
Begin
http_req :=
UTL_HTTP.begin_request
'http://'
|| lv_hosturl
-- || '.net/soa-infra/services/finance_rt/Payments/paymentsprocess_client_ep',
--new url
|| '.net/soa-infra/services/finance_rt/PaymentsReq/paymentsprocess_client_ep?WSDL',
'POST',
'HTTP/1.1'
UTL_HTTP.set_header (http_req, 'Content-Type', 'text/xml');
-- since we are dealing with plain text in XML documents
UTL_HTTP.set_header (http_req,
'Content-Length',
LENGTH (lv_soap_request)
UTL_HTTP.set_header (http_req, 'SOAPAction', '');
-- required to specify this is a SOAP communication
UTL_HTTP.write_text (http_req, lv_soap_request);
http_resp := UTL_HTTP.get_response (http_req);
UTL_HTTP.read_text (http_resp, lv_soap_respond);
UTL_HTTP.end_response (http_resp);
resp := XMLTYPE.createxml (lv_soap_respond);
End;Hi,
there are a lot of option to make plsql web services .
First you can stay with jdev 10.1.3
Use the xmldb servlets
use jdev 11g tp4 to create plsql ws and upgrade to jdev 11g production
And I think in the next release of jdev it will be back , there are more options which disappeared like the adf bc sdo ws or jmx datacontrol etc.
thanks Edwin -
Support for Creating Web Service from pl/sql package in JDeveloper 11
We have been creating all of our web services from pl/sql packages in our Oracle database using JDeveloper 10.1.3.1. I understand that this capability is not supported in Jdev 11. We have been mandated to either move up to JDeveloper 11, or consider switching to eclipse, or even VS2008 and run .NET services from IIS. I have seen work-around solutions using TopLink and Jdev 11. Are there plans to revive this feature in the near future? We're now looking at switching to .NET since we could scrap our OAS instances and use IIS to publish web services. The only reason we were sticking with Oracle was the ease in converting all our existing package to web services with Jdev.
Is anyone else in the same situation. If so, what solutions are you considering?Hi,
there are a lot of option to make plsql web services .
First you can stay with jdev 10.1.3
Use the xmldb servlets
use jdev 11g tp4 to create plsql ws and upgrade to jdev 11g production
And I think in the next release of jdev it will be back , there are more options which disappeared like the adf bc sdo ws or jmx datacontrol etc.
thanks Edwin -
Error when publishing a PL/SQL package as a Webservice
Hi all,
I am using the JDeveloper (10.1.3.1.0) to publish a PL/SQL package as a Webservice, and I am having some troubles on the generation process.
The problem that I am facing is on the generated code for the database side, where some methods have a “$GET_” at the end of its name.
This “$GET_” is handled by the database as a special word, and the package can’t be compiled.
If the ‘$’ character is removed from all the methods, the package can be compiled and the Webservice works fine.
What’s wrong? Is there a bug on the generation process of the JDeveloper?
Regards,
Rui TorresOK, This is the PL/SQL package:
Function:
FUNCTION Obtener_paises RETURN res_webservice AS
v_respuesta res_webservice;
i PLS_INTEGER:=1;
CURSOR C_paises IS
SELECT cpais, tpais
FROM paises
ORDER BY tpais;
BEGIN
v_respuesta := res_webservice(null,null);
v_respuesta.error := res_error(null,null,null);
v_respuesta.error.cerror := 0;
v_respuesta.error.cerror_ora := 0;
v_respuesta.error.terror := null;
v_respuesta.datos := res_datos ();
FOR v_pais IN C_paises LOOP
v_respuesta.datos.extend;
v_respuesta.datos(i) := reg_datos(null,null);
v_respuesta.datos(i).codigo := v_pais.cpais;
v_respuesta.datos(i).descripcion := v_pais.tpais;
i := i + 1;
END LOOP;
Insertar_log(NULL,SYSDATE,'C','Obtener_paises',NULL,'ERROR:0');
RETURN v_respuesta;
EXCEPTION
WHEN OTHERS THEN
v_respuesta.error.cerror := 1;
v_respuesta.error.cerror_ora := SQLCODE;
v_respuesta.error.terror := substr(SQLERRM,1,80);
Insertar_log(NULL,SYSDATE,'C','Obtener_paises',NULL,'ERROR:1 '||substr(SQLERRM,1,120));
RETURN v_respuesta;
END Obtener_paises;
TYPES USED:
CREATE OR REPLACE
TYPE res_webservice AS OBJECT (error res_error, datos res_datos);
CREATE OR REPLACE
TYPE res_error AS OBJECT (cerror NUMBER(1), cerror_ora VARCHAR2(12), terror VARCHAR2(80));
CREATE OR REPLACE
TYPE res_datos AS TABLE OF reg_datos;
CREATE OR REPLACE
TYPE reg_datos AS OBJECT(codigo VARCHAR2(12), descripcion VARCHAR2(150));
Thanks in advanced...
Could happen this bacause of these defined types??? -
Problem with pl/sql package
hi,
i have requirement where i have to create a PL/SQL package which takes two parameters from procedure where i shd give fromdate and todate as parameter below is the code i am getting two errors
create or replace PACKAGE AgentTimeReport_XDO_pkg AS
PROCEDURE AgentTimeReport_Demo_RTF(o_errbuf OUT VARCHAR2
,o_retcode OUT VARCHAR2,p_fromdate IN VARCHAR2,p_todate IN VARCHAR2 );
END AgentTimeReport_XDO_pkg
CREATE OR REPLACE
PACKAGE BODY AGENTTIMEREPORT_XDO_PKG AS
PROCEDURE AgentTimeReport_Demo_RTF(o_errbuf OUT VARCHAR2
,o_retcode OUT VARCHAR2,p_fromdate IN
VARCHAR2,p_todate IN VARCHAR2 ) AS
cursor cs_agenttime
is
SELECT
incident.Incident_Number as ServiceRequestNumber,
TO_CHAR (incident.incident_date,'DD-MON-YYYY') as ServiceRequestDate,
incident.Summary as Summary,
agenttime.agentname as AgentName,
to_char(agenttime.agentstarttime,'DD-MM-YYYY HH24:MI') as StartTime,
to_char(to_date('00:00:00','HH24:MI:SS') +
(agenttime.endtime-agenttime.agentstarttime), 'HH24:MI') as TimeSpent
FROM cs_incidents_all_b incident,cs_agenttime_agv agenttime
WHERE agenttime.incident_id=incident.incident_id
AND incident.incident_date between to_date(:p_fromdate,'DD-MON-YYYY')
AND to_date(:p_todate,'DD-MON-YYYY');
BEGIN
/*First line of XML data should be ‘<?xml version="1.0" encoding='utf-8'?>’*/
FND_FILE.PUT_LINE(FND_FILE.OUTPUT,'<?xml version="1.0" encoding="utf-8"?>');
FND_FILE.PUT_LINE(FND_FILE.OUTPUT,'<AGENTTIME>');
FOR cs_agent IN cs_agenttime
LOOP
/*For each record create a group tag <G_AGENT_TIME> at the start*/
FND_FILE.PUT_LINE(FND_FILE.OUTPUT,'<G_AGENT_TIME>');
/*Embed data between XML tags for ex:- <EMP_NAME>Abeesh</EMP_NAME>*/
FND_FILE.PUT_LINE(FND_FILE.OUTPUT,'<SERVICEREQUEST_NUMBER>' ||
cs_agent.ServiceRequestNumber
|| '</SERVICEREQUEST_NUMBER>');
FND_FILE.PUT_LINE(FND_FILE.OUTPUT,'<SERVICEREQUEST_DATE>' ||
cs_agent.ServiceRequestDate ||
'</SERVICEREQUEST_DATE>');
FND_FILE.PUT_LINE(FND_FILE.OUTPUT,'<START_TIME>' || cs_agent.StartTime
||'</START_TIME>');
FND_FILE.PUT_LINE(FND_FILE.OUTPUT,'<TIME_SPENT>' || cs_agent.TimeSpent
||'</TIME_SPENT>');
FND_FILE.PUT_LINE(FND_FILE.OUTPUT,'</G_AGENT_TIME>');
END LOOP;
/*Finally Close the starting Report tag*/
FND_FILE.PUT_LINE(FND_FILE.OUTPUT,'</AGENTTIME>');
END AgentTimeReport_Demo_RTF;
END AGENTTIMEREPORT_XDO_PKG;
Error(20,44): PLS-00049: bad bind variable 'P_FROMDATE'
Error(21,13): PLS-00049: bad bind variable 'P_TODATE'
Help me out
naveencreate or replace PACKAGE AgentTimeReport_XDO_pkg AS
PROCEDURE AgentTimeReport_Demo_RTF(o_errbuf OUT VARCHAR2
,o_retcode OUT VARCHAR2,p_fromdate IN VARCHAR2,p_todate IN VARCHAR2 );
END AgentTimeReport_XDO_pkg
CREATE OR REPLACE
PACKAGE BODY AGENTTIMEREPORT_XDO_PKG
AS
PROCEDURE AgentTimeReport_Demo_RTF
o_errbuf OUT VARCHAR2 ,
o_retcode OUT VARCHAR2,
p_fromdate IN VARCHAR2,
p_todate IN VARCHAR2 )
AS
CURSOR cs_agenttime(p_fromdate VARCHAR2,p_todate VARCHAR2)
IS
SELECT incident.Incident_Number AS ServiceRequestNumber,
TO_CHAR (incident.incident_date,'DD-MON-YYYY') AS ServiceRequestDate ,
incident.Summary AS Summary ,
agenttime.agentname AS AgentName ,
TO_CHAR(agenttime.agentstarttime,'DD-MM-YYYY HH24:MI') AS StartTime ,
TO_CHAR(to_date('00:00:00','HH24:MI:SS') + (agenttime.endtime-agenttime.agentstarttime), 'HH24:MI') AS TimeSpent
FROM cs_incidents_all_b incident,
cs_agenttime_agv agenttime
WHERE agenttime.incident_id=incident.incident_id
AND incident.incident_date BETWEEN to_date(p_fromdate,'DD-MON-YYYY') AND to_date(p_todate,'DD-MON-YYYY');
BEGIN
/*First line of XML data should be ‘<?xml version="1.0" encoding='utf-8'?>’*/
FND_FILE.PUT_LINE(FND_FILE.OUTPUT,'<?xml version="1.0" encoding="utf-8"?>');
FND_FILE.PUT_LINE(FND_FILE.OUTPUT,'<AGENTTIME>');
FOR cs_agent IN cs_agenttime(p_fromdate,p_todate)
LOOP
/*For each record create a group tag <G_AGENT_TIME> at the start*/
FND_FILE.PUT_LINE(FND_FILE.OUTPUT,'<G_AGENT_TIME>');
/*Embed data between XML tags for ex:- <EMP_NAME>Abeesh</EMP_NAME>*/
FND_FILE.PUT_LINE(FND_FILE.OUTPUT,'<SERVICEREQUEST_NUMBER>' || cs_agent.ServiceRequestNumber '</SERVICEREQUEST_NUMBER>');
FND_FILE.PUT_LINE(FND_FILE.OUTPUT,'<SERVICEREQUEST_DATE>' cs_agent.ServiceRequestDate || '</SERVICEREQUEST_DATE>');
FND_FILE.PUT_LINE(FND_FILE.OUTPUT,'<START_TIME>' || cs_agent.StartTime ||'</START_TIME>');
FND_FILE.PUT_LINE(FND_FILE.OUTPUT,'<TIME_SPENT>' || cs_agent.TimeSpent ||'</TIME_SPENT>');
FND_FILE.PUT_LINE(FND_FILE.OUTPUT,'</G_AGENT_TIME>');
END LOOP;
/*Finally Close the starting Report tag*/
FND_FILE.PUT_LINE(FND_FILE.OUTPUT,'</AGENTTIME>');
END AgentTimeReport_Demo_RTF;
END AGENTTIMEREPORT_XDO_PKG;Ravi Kumar -
Need Info Regarding Implementaion of Interfaces in java.sql package
Hi All,
I am interested in knowing details abt how the Interfaces in the java.sql package are implemented. We all work with the database using the interfaces provided ,but how do they work at the backend ? How can a Interface provide details (work ) with out an implementation class.I Is this taken care by the JVM or some of the Call level interfaces? Please do provide details abt this..hi Sheshadri,
The implementation of the various interfaces in
java.sql package are provided by your jdbc driver,
which also manages the connection and communication of
your java program with the appropriate database.
cheers,
-Jer -
Using CASE WHEN in PL/SQL package
I am trying to convert the values in a selected column into 1 and 0 so that I can display all 1s in one column, all 0s in another. I am doing this in a PL/SQL package. However ORACLE compiler does not like the CASE construct.
Does anyone know how to group values in a column into several new columns. If CASE WHEN construct is not doable in PL/SQL, what alternatives are there? Thanks.
/******* My package starts here *******/
CREATE OR REPLACE PACKAGE TEST_NEED AS
PROCEDURE procTEST_NEED(STARTING_DATE IN VARCHAR2);
END CVRR_MON_NEED;
CREATE OR REPLACE PACKAGE BODY TEST_NEED
AS
PROCEDURE procTEST_NEED(STARTING_DATE IN VARCHAR2)
IS
TEST_START DATE := TO_DATE(STARTING_DATE,'MM/DD/YYYY');
CURSOR v_Cursor IS
SELECT A.D_CODE, A.M_CODE, TEST_START , C.C_NAME,C.P_ID,
SUM(CASE WHEN MONTHS_BETWEEN(SYSDATE, D.P_DOB)/12 > 40 AND MONTHS_BETWEEN(SYSDATE, D.P_DOB)/12 <85 AND B.B_CODE IN '11.1','222.2','272.4') THEN 1 ELSE 0 END) QUALIFIED
FROM A, B, C, D
WHERE A.ID = B.B_ID
AND RTRIM(A.P_CODE) = C.P_CODE
AND A.P_ID = D.P_ID
AND A.P_ID < 99999999999999999999
AND A.E_DATETIME < SYSDATE
GROUP BY A.D_CODE, A.M_CODE, TEST_START , C.C_NAME,C.P_ID;
v_RecordHolder v_Cursor%ROWTYPE;
BEGIN
OPEN v_Cursor;
FETCH v_CursorINTO v_RecordHolder ;
WHILE v_Cursor%FOUND LOOP
look for records in another table with matching keys of the cursor
if found then update by incrementing the existing values in the matching records with values of the current currsor row
else insert the current cursor row
FETCH v_Cursor INTO v_RecordHolder ;
END LOOP;
END procTEST_NEED;
END TEST_NEED;I am trying to convert the values in a selected
column into 1 and 0 so that I can display all 1s in
one column, all 0s in another. I am doing this in a
PL/SQL package. However ORACLE compiler does not
like the CASE construct.
Does anyone know how to group values in a column into
several new columns. If CASE WHEN construct is not
doable in PL/SQL, what alternatives are there?
Thanks.
CURSOR v_Cursor IS
SELECT A.D_CODE, A.M_CODE, TEST_START ,
, C.C_NAME,C.P_ID,
SUM(CASE WHEN MONTHS_BETWEEN(SYSDATE, D.P_DOB)/12 >
40 AND MONTHS_BETWEEN(SYSDATE, D.P_DOB)/12 <85 ANDB.B_CODE IN '11.1','222.2','272.4') THEN 1 ELSE 0
END) QUALIFIEDUse the Decode function. This has been around in oracle SQL for ages and works like a case construct.
You would do something like
select ...
sum( decode (MONTHS_BETWEEN(SYSDATE, D.P_DOB)/12 >
40 AND MONTHS_BETWEEN(SYSDATE, D.P_DOB)/12 <85 AND
B.B_CODE IN ('11.1','222.2','272.4') 1,0 ) -
Can't register a database in RMAN catalog (PL/SQL package not current)
Hi RMAN experts. I'm trying to register a 10.2.0.1.0 database into a 10.2.0.5.0 RMAN catalog but I get the following error (Note: following was done on the rman server machine, ORACLE_SID=rman, target database is remote)
$ rman catalog rman/rman target sys@MPOWER
Recovery Manager: Release 10.2.0.5.0 - Production on Sat Apr 30 12:54:16 2011
Copyright (c) 1982, 2007, Oracle. All rights reserved.
PL/SQL package SYS.DBMS_BACKUP_RESTORE version 10.02.00.00 in TARGET database is not current
PL/SQL package SYS.DBMS_RCVMAN version 10.02.00.00 in TARGET database is not current
connected to target database: MPOWER (DBID=**********)
connected to recovery catalog database
RMAN> register database;
database registered in recovery catalog
starting full resync of recovery catalog
RMAN-00571: ===============
RMAN-00569: =========ERROR MESSAGE STACK FOLLOWS
RMAN-00571: =================
RMAN-03008: error while performing automatic resync of recovery catalog
ORA-00904: : invalid identifier
Basically the error says that there are two packages in the TARGET database (SYS.DBMS_BACKUP_RESTORE and SYS.DBMS_RCVMAN) which are not compatible with the RMAN catalog.
I cannot register the target database into the RMAN catalog.
I highly appretiate if you give me an advice on this.
Regardsuser13064912 wrote:
Hi RMAN experts. I'm trying to register a 10.2.0.1.0 database into a 10.2.0.5.0 RMAN catalog but I get the following error (Note: following was done on the rman server machine, ORACLE_SID=rman, target database is remote)
$ rman catalog rman/rman target sys@MPOWER
Recovery Manager: Release 10.2.0.5.0 - Production on Sat Apr 30 12:54:16 2011
Copyright (c) 1982, 2007, Oracle. All rights reserved.
PL/SQL package SYS.DBMS_BACKUP_RESTORE version 10.02.00.00 in TARGET database is not current
PL/SQL package SYS.DBMS_RCVMAN version 10.02.00.00 in TARGET database is not current
connected to target database: MPOWER (DBID=**********)
connected to recovery catalog database
RMAN> register database;
database registered in recovery catalog
starting full resync of recovery catalog
RMAN-00571: ===============
RMAN-00569: =========ERROR MESSAGE STACK FOLLOWS
RMAN-00571: =================
RMAN-03008: error while performing automatic resync of recovery catalog
ORA-00904: : invalid identifier
Basically the error says that there are two packages in the TARGET database (SYS.DBMS_BACKUP_RESTORE and SYS.DBMS_RCVMAN) which are not compatible with the RMAN catalog.
I cannot register the target database into the RMAN catalog.
I highly appretiate if you give me an advice on this.
RegardsCould you try to run the rman at the target database server (MPOWER), instead of rman catalog server ant try to register your database?
Your rman client is higher than your target server. That could be the problem.
Best Regards,
Gokhan
If this question is answered, please mark appropriate posts as correct/helpful and the thread as closed. Thanks -
Problems with PL/SQL packages
Hello,
I face the following problem with PL/SQL stored procedures. The Oracle
version is 8.0.5 on Windows NT 4. The PL/SQL package has a set of procedures and functions.
The main procedure of the PL/SQL package is triggered from VC++ executable. If for some reason,
an exception is caught in the stored procedure (like no_data_found
exception), then the following problem occurs.
If we try to trigger the stored procedure again through the VC++ executable,
the variables in the stored procedures have the values as in the previous
execution. They are not getting initialised. (The same database connection
is used in VC++ executable).
Currently, only if a new connection to the database is used , the problem is
solved.
Also, change in the input parameters of the procedure is not reflected, once the procedure fails because of any exception. Only the input which was given during the time of execution when the procedure failed,is considered.
What could be the reason for this problem and how can this be corrected?
Please send in your suggestions.
Thanks and Regards,
Ramya Priya
nullHi Keith,
I am connecting to the database as the package owner..
I have noticed earlier that I have problems when capturing triggers also.. The content of one large trigger contains 36371 characters and when capturing it from DB, the content was truncated to 28020 characters in Designer.
Our ideas with capturing the DB packages/procedures were to use the Designer as version control system.
We wanted to have all objects used in a project in Designer.. entities, tables, triggers, packages, procedures, Forms files, etc. in order to make a configuration for a project release.
Thank you,
Claudia
Maybe you are looking for
-
How to get clamshell mode with Windows 7 on Macbook Pro?
Hi, I am running Windows 7 on Macbook Pro using bootcamp. In OS-X, I can use this cool clamshell feature wherein after putting the MBP to sleep by closing the lid, as soon as I connect an external keyboard, mouse & monitor, I get the display on the m
-
I was having an issue a few months back with one of my user accounts, and the only solution was to create a new user. But I couldn't for the life of me figure out how to get my iWeb site to tranfer to the new user. So my workaround was to create ne
-
Dear all, I create a region with this information : select htmldb_item.hidden(1,QRY_IDS), htmldb_item.hidden(2,SIT_ID), SIT_ID SIT_ID_DISPLAY, htmldb_item.checkbox(4,used_bl,decode(used_bl,'Y','CHECKED',NULL))used_bl, dsc from BSF_QRY_SITES qst, bsf_
-
Add Company Logo to BCM Chat Window
Hi Experts, I am working on BCM 7.0. We have a requirement to add company logo on BCM Chat Window. Could you please guide me how to achieve this? Thanks in Advance. Thanks, Amit
-
Nikon nef format supported in Revel
Why doesn't Revel upload my .nef files? The general FAQs says that the format is supported. It doesn't work from my ipad or from Windows 7 with Internet Explorer. The nef files are from a Nikon D90.