Stored Proc after Allocation
Is there a way to run a stored procedure (using *RUN_STORED_PROCEDURE) only after a certain allocation has run?
// Default base level logic - applies to all base members in all dimensions
//Contract Allocation
*IGNORE_STATUS
*XDIM_MAXMEMBERS ENTITYDIM=12
*RUNALLOCATION
*FACTOR USING/TOTAL
*DIM ACCOUNTPRS WHAT=>>>; WHERE=SALES; USING=<<<; TOTAL=<<<;
*DIM DATASRC WHAT=ALLOCATION; WHERE=INPUT; USING=INPUT; TOTAL=<<<;
*DIM CONTRACTENTITY WHAT=; WHERE=; USING=; TOTAL=;
*DIM SYSTEM WHAT=FCST_MEMBER; WHERE=BAS(ALL_MEMBERS),[ACTIVE]='Y';
USING=[ACTIVE]='Y'; TOTAL=<<<;
*DIM CATEGORY WHAT=FCST; WHERE=<<<; USING=ACTUAL; TOTAL=<<<;
*DIM MANAGINGCO WHAT=; WHERE=; USING=; TOTAL=;
*DIM MEMBERCLASS WHAT=FCST_CLASS; WHERE=BAS(ALL_CLASS); USING=ALL_CLASS; TOTAL=<<<;
*DIM PRIMETYPE WHAT=FCST_PRIM; WHERE=BAS(PRIME_TYPE); USING=PRIM_TYPE; TOTAL=<<<;
*DIM TIME WHAT=YYYY.MONTH; WHERE=<<<; USING=<ALL>; TOTAL=<ALL>;
*DIM ALLIANCE WHAT=; WHERE=; USING=; TOTAL=;
*DIM SUPTIME WHAT=%SUPTIME_SET%; WHERE=%SUPTIME_SET%; USING=TOTAL.2009; TOTAL=<<<;
*ENDALLOCATION
*COMMIT
*RUN_STORED_PROCEDURE=SPBUDCALC();
Edited by: Nick Wills on May 20, 2010 4:46 PM
Hi,
You can call it after the allocation logic.. Like you have specified in the code... Is there anything else that you want to do?
Regards,
Shoba
Similar Messages
-
Can't run stored proc after migration to Active Directory
I just moved our company's SQL server 2000 server from our
old NT domain to our new Active Directory. After makign this
switch, i noticed one thing that won't work right.
it is a coldfusion page that calls a stored procedure on the
SQL server using the followign code:L
<cfstoredproc procedure="dbo.erehabDTS_import"
datasource="#Application.DSN#"
returncode="yes">
the stored procedure then calls a DTS package which imports
data from a text file (uploaded by the CF page) into a SQL server
table. It all worked before moving to active directory, but now
when i run the CF page, i get the following error:
Error Executing Database Query.
[Macromedia][SQLServer JDBC Driver][SQLServer]xpsql.cpp:
Error 1788 from LogonUserW on line 620
Error Code: HY000
NativeErrorCode: 50001
can someone please help?If you are not already using the latest JDBC drivers (ver
3.5), upgrade to them. The new microsoft sql driver has updated
code for doing NTAuthentication logins. Test with it.
Get the
Technote
and download the zip. Apply both files as indicated. There are
instructions for using NTAuth in the technote. Make sure to follow
those. If you are using ntauth., make sure the ColdFusionMX
application service is running as that user in the services
applet. -
Do Java Stored Proc support GUI
Calling Java stored procedure from database Trigger
I tried three things individually in Java Stored proc after
trigger is fired:
1. Do SQL statement (Insert into ... )
2. Execute a command to open notepad screen.
3. Open a new Frame and display it.
These three are simple testing, Item 1 works fine, however,
Item 2 and 3 never works.
IS JAVA STORED PROC CAN ONLY DO SQL TYPES OF WORK (INSERT, DELETE, UPDATE) ?
The errors I have for Items 2 and 3 are like:
1. When loading java: Java call terminated by uncaught Java exception:
oracle.aurora.awt.UnsupportedOperation:GUI not supported.
2. When triger is fired: class SCOTT.DBTrigger could not be resolved.
Thanks for help !!As far as I know java stored procedures can't use any GUI classes. Only unvisible actions!
Regards -
Stored Proc running twice using DBMS_Scheduler
Hello all,
I have a vb front end that calls a main stored proc which submits scheduler jobs to execute several stored procs asynchronously. Everything is working, except the part that the several stored procs are running twice. In the troubleshooting, I have eliminated the front end from being the culprit and the stored procs themselves. Essentially, when I call the stored proc using dbms_scheduler.create_job, it runs twice, even manually. I am about at wits end trying to figure out why: Using Oracle 11gR2
I started off setting up the programs
begin
--create program
dbms_scheduler.create_program
( program_name => 'prog_name'
,program_type => 'STORED_PROCEDURE'
,program_action => 'usp_sub_proc_1'
,number_of_arguments => 8
,enabled => FALSE
dbms_scheduler.DEFINE_PROGRAM_ARGUMENT
( program_name=> 'prog_name'
,argument_position=>1
,argument_name => 'name'
,argument_type=>'VARCHAR2'
/*the remaining 7 arguments are in code but not display for space reasons*/
dbms_scheduler.enable('prog_name');
end;Then the main stored proc executes this code:
declare v_job_name varchar2(100);
v_1 varchar(50) := 'All';
v_2 varchar(50) := 'All';
v_3 varchar(50) := 'All';
v_4 varchar(50) := 'All';
v_5 varchar(50) := 'TEST';
i_6 integer := 1;
v_7 varchar(50) := 'TEST_NE';
ts_8 timestamp := current_timestamp;
begin
v_job_name := 'uj_dmo_1';
dbms_scheduler.create_job (v_job_name
,program_name => 'prog_name'
,job_class => 'UCLASS_1'
,auto_drop => TRUE
--set parameters
dbms_scheduler.set_job_argument_value(v_job_name,1, v_1);
dbms_scheduler.set_job_argument_value(v_job_name,2, v_2);
dbms_scheduler.set_job_argument_value(v_job_name,3, v_3);
dbms_scheduler.set_job_argument_value(v_job_name,4, v_4);
dbms_scheduler.set_job_argument_value(v_job_name,5, v_5);
dbms_scheduler.set_job_argument_value(v_job_name,6, to_char(i_6));
dbms_scheduler.set_job_argument_value(v_job_name,7, v_7);
dbms_scheduler.set_job_argument_value(v_job_name ,8, to_char(ts_8));
--enable job
dbms_scheduler.enable(v_job_name);
--execute job
dbms_scheduler.run_job(job_name => v_job_name , use_current_session => FALSE);
end;
...And this is where I get the double execution of the job, but I am just not seeing it in my syntax, dba_scheduler_jobs, logging, etc. Any help is greatly appreciated, thanks!!Well apparently I will not win any Captain Obvious awards;
With 34MCA2K2's response with "what doesn't work" for some reason turned the light on. After some more testing here is what I found.
This code works as expected :
Exhibit A
begin
dbms_scheduler.create_job (job_name =>'TESTER'
,job_type => 'PLSQL_BLOCK'
,job_action => 'declare test1 integer := 1; begin test1 := test1 + 5; end;'
,auto_drop => True
/*dbms_scheduler.enable('TESTER'); */
dbms_scheduler.run_job(job_name => 'TESTER', use_current_session =>FALSE);
end;As does this:
Exhibit B
begin
dbms_scheduler.create_job (job_name =>'TESTER'
,job_type => 'PLSQL_BLOCK'
,job_action => 'declare test1 integer := 1; begin test1 := test1 + 5; end;'
,auto_drop => True
dbms_scheduler.enable('TESTER');
/*dbms_scheduler.run_job(job_name => 'TESTER', use_current_session =>FALSE); */
end;Exhibit A will create the job and is visible in the schedulerjobs view, and the RUN_JOB will execute it even when not enabled, but the pl/sql will not drop the job.
Exhibit B will create the job and once enabled, executes the job and then drops from schedulerjobs view.
Therefore, my desired results for running the jobs once asynchronously and dropping immediately is....
begin
v_job_name := 'uj_dmo_1';
dbms_scheduler.create_job (v_job_name
,program_name => 'prog_name'
,job_class => 'UCLASS_1'
,auto_drop => TRUE
--set parameters
dbms_scheduler.set_job_argument_value(v_job_name,1, v_1);
dbms_scheduler.set_job_argument_value(v_job_name,2, v_2);
dbms_scheduler.set_job_argument_value(v_job_name,3, v_3);
dbms_scheduler.set_job_argument_value(v_job_name,4, v_4);
dbms_scheduler.set_job_argument_value(v_job_name,5, v_5);
dbms_scheduler.set_job_argument_value(v_job_name,6, to_char(i_6));
dbms_scheduler.set_job_argument_value(v_job_name,7, v_7);
dbms_scheduler.set_job_argument_value(v_job_name ,8, to_char(ts_8));
/*enable job*/
dbms_scheduler.enable(v_job_name);
/*execute job (Do not execute the code below, it will lead to multiple executions)
dbms_scheduler.run_job(job_name => v_job_name , use_current_session => FALSE); */
end; -
Getting error while invoking relational physical DS for sybase stored proc
*com.bea.dsp.das.exception.DASException: com.bea.dsp.wrappers.rdb.exceptions.RDBWrapperException: {bea-err}RDBW0004: Error executing SQL query: [BEA][Sybase JDBC Driver][Sybase]SELECT INTO command not allowed within multi-statement transaction+.*
I have created a physical DS function using "relational" in the wizard and connecting to sybase ASE stored procedure that is in unchained mode. I had configured the JDBC pool using BEA sybase non-XA 12.x driver.
When i run the physical DS (or logical DS), i get the above error. The sybase srever(and stored proc) is hosted by an external system and right now i do not have access/contacts to change anything.
After hours spent googling, it appears that the fix may possibly be setting "set chained off" before calling the stored proc. To achieve that, i tried the below two methods but nothing seems to work:
- In the JDBC URL, set property via ?chained=off (also tried false instead of "off")
- In Admin console/JDBC connection pool configuration/initSQL tried "SQL SET CHAINED OFF" and "SET CHAINED OFF"
My ODSI version is 10gR3
Oracle Workshop for WebLogic
Version: 10.3
Build id: 1137967
I tried using java physical DS and get the same error. I wrote a test stored proc in my local PC sybase ASE and it runs fine. But i connected as "sa".
I would like to exhaust all possible options from my side before making the long process of getting something changed in the external sybase DB like setting the proc mode to "anymode".
Please help.
Thank you.mikereiche wrote:
Did the test stored proc use "SELECT INTO"?Yes. But it did not do much(code below)
>
Was the test stored proc tagged the same as the one that fails (chained/unchained?)Yes. "sp_procxmode" confirms that the test stored proc is in "unchained" transaction mode.
>
Can you get jdbc code that successfully calls the stored proc using the datasource?Yes, my colleague was trying the jdbc code and i was trying in the workshop with relational. She has left for the day so will post tomorrow. Please note that this is only for the test stored proc. The java jdbc also gets the same error for the "real" stored proc.
>
BTW - if you used "SET CHAINED OFF" as initSql, unless you have a table named SET, the sql will fail and the datasource will not be created. So that casts some doubt on whether the other setting "SQL SET CHAINED OFF" was applied.
Also - the connections are reset to default when they are returned to the connection pool, so I think "SQL SET CHAINED OFF" should be used as the "Test Table Name" and Test On Reserve should be checked.Tried it now, but it does not work. I'm getting the same error.
test stored proc:
create procedure dbo.getCustomerMulti @cid_inp varchar(40)
as
begin
select dbo.Customer.FirstName, dbo.Customer.cid, dbo.Customer.LastName, dbo.Customer.DateCreated, dbo.Customer.id into #temp from dbo.Customer
select dbo.Customer.FirstName, dbo.Customer.cid, dbo.Customer.LastName, dbo.Customer.DateCreated, dbo.Customer.id from dbo.Customer where cid LIKE @cid_inp + '%'
end
Thank you. -
Calling DB2 Stored Proc from Oracle DB
Hi,
I am having two different database running (One is oracle on solaris while the other one is db2 on os/390 mainframe) i want to pass the data realtime. Is there any way I can call a DB2 stored procedure from oracle directly. If anyboy can help in this will be really helpful.
thanks,
Kishorodi version we have is ODI_11.1.1.6.0, it is not migrated and 'Always Execute' option is checked already.
tried using variables in capital format but did not worked,
begin
schema_name.proc_name(#LV_TABLE_NAME,#LV_SCHEMA_NAME,#LV_START_DATE,#LV_END_DATE);
end;
odi is giving error if it finds any bug in stored proc but after fixing its completing successfully without errors in operator but i am not able to see the result.
Please advise. -
XML Parsing in Java Stored Proc--Oracle XML Support Installation?
I am working with a third party product that is having difficulty running a java stored proc that is parsing a supplied XML file. The proc basically looks like:
import java.io.IOException;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.FactoryConfigurationError;
import javax.xml.parsers.ParserConfigurationException;
import org.w3c.dom.Document;
import org.xml.sax.SAXException;
InputStream is = getXMLAsInputStream(xml);
try {
DocumentBuilderFactory factory =
DocumentBuilderFactory.newInstance();
DocumentBuilder builder = factory.newDocumentBuilder();
Document document = builder.parse( is );
... parse the document ....
catch (FactoryConfigurationError e) {
// unable to get a document builder factory
We are running on 9.2.0.6, HP-UX 64-bit. At first, when we would attempt to run the proc, a database hang would occur; now after attempting to install using loadjava jars for xerces2.6: ORA-29532: Java call terminated by uncaught Java exception:
javax.xml.parsers.FactoryConfigurationError: Provider
org.apache.xerces.jaxp.DocumentBuilderFactoryImpl not found)
The vendor says that the errors we are getting when running are not due to any dependency on xerces or jre1.4, and that we need to "install Oracle XML support", but I'm not certain what this means (I cannot find any documentation on what to install). I believe that there are jars that need to be loaded into the database to support the XML parsing, as jre1.3 does not include built-in XML support, and Oracle 9.2.0.6 uses jre1.3.
So...does anyone have any thoughts as to how to resolve the missing references? Is there a way to "install Oracle XML support", or is it to install the necessary jars?
Thanks,
CandiCandi,
The following resources should be of help:
Oracle9i Database Release 2 (9.2) Documentation Library
In particular, check out the following:
Java Developer's Guide
Java Stored Procedures Developer's Guide
XML API Reference - XDK and Oracle XML DB
XML Database Developer's Guide - Oracle XML DB
XML Developer's Kits Guide - XDK
If that doesn't help, then try the following:
OracleJVM and Java Stored Procedures
XML Technology Center
Good Luck,
Avi. -
Parse XML in a java stored proc
I am trying to parse an xml document in a java stored procedure. Just following my nose, I have developed a stored proc that works fine in development (outside the database using JRE 1.4.1) using the Xerces 2.5 parser. But, after having transferred the xerces xercesImpl.jar, xmlapis.jar, and my implementation class into oracle using loadjava when I call my stored proc the code throws an exception trying to build the document with an error like:
NoClassDef exception org.apache.xerces.jaxp.DocumentFactoryBuilderImpl
My Code looks like this:
import java.io.IOException;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.FactoryConfigurationError;
import javax.xml.parsers.ParserConfigurationException;
import org.w3c.dom.Document;
import org.xml.sax.SAXException;
InputStream is = getXMLAsInputStream(xml);
try {
DocumentBuilderFactory factory =
DocumentBuilderFactory.newInstance();
DocumentBuilder builder = factory.newDocumentBuilder();
Document document = builder.parse( is );
... parse the document ....
catch (FactoryConfigurationError e) {
// unable to get a document builder factory
The exception caught is a FactoryConfigurtionError.
I'm not particularly attached to xerces, I'm really just looking for a way to parse XML inside my java stored proc, so any help to solve my problem, or an alternative suggestion will be greatly appreciated.
thanks
DaleI looked again and sure enough the xerces implementation classes were missing. I had run a .cmd file containing these two lines, but it looks like only the first one ran...
loadjava -u ncc/xyz@usd -v -r M:\Database\JavaGeocode\Xerces2_5_0\xml-apis.jar
loadjava -u ncc/xyz@usd -v -r M:\Database\JavaGeocode\Xerces2_5_0\xercesImpl.jar
Now I've got everything working fine with Xerces!
Dale -
I'm doing a select on the ALL_ARGUMENTS like:
SELECT count(*) FROM all_arguments WHERE owner LIKE 'MySchema' ESCAPE '/' AND object_name LIKE 'MyStoredProc' ESCAPE '/' AND package_name LIKE 'MyPackage' ESCAPE '/';
Sometimes, after connecting to the DB after a certain period of time, I get a result = 0, althought the Stored Procedure is there. Immediatelly after that I retry, and I get result = 2.
Why is that? Does the SELECT recompile the stored proc?I'm surprised that you get anything if you use that query.
Oracle considers object names to be uppercase unless the name is enclosed in double quotes. So there would be no schemas with a name 'MySchema' since the name would actually be 'MYSCHEMA'. -
hello.
What would trigger the change of "STATUS" from valid to invalid
for a java stored procedure (status of the PROCEDURE, not the
java class/source)?
E.g.
- loaded a java source/class
- published it with CREATE PROCEDURE ...
- the procedure inserts a row into some table X
- select* from user_objects where object_type = 'PROCEDURE'; shows that
the proc is valid
- call the proc, fine
- delete a column from the table X
- select* from user_objects where object_type = 'PROCEDURE'; shows that
the proc is still VALID
- call the proc, the call actually completed without error! (but the new row didn't get inserted into the table)
When the schema of a table that a java stored proc refers
to changes, will the java stored proc automatically marked
as "INVALID"? If not, when will this status changed from
VALID to INVALID?
Thanks.
MinMin:
A java stored procedure is marked as VALID or INVALID depending on whether Oracle had any problems loading the class file into the database. Since you had no problems loading the class file it will always be valid.
Now, after you deleted the column in the table I would assume that the java stored procedure would have a problem when it tried to do an insert and it would throw an exception. Your java stored procedure is VALID, it just isn't executing properly and is more than likely throwing an exception.
Sometimes an exception thrown from a jsp is written to a log file instead of to the console. I suspect that this is the case in your situation. You think that the call to the jsp executed with no errors, but I bet it didn't. You will probably find the errors somewhere in the oracle\ora90\admin\mydatabase directory. Look at the latest .trc file. (Note: the path I gave to the .trc files may be different depending on what version of oracle you are using). -
Should I do this with Java Code or Stored Procs ? (for best performance)
Hi All,
I need to decide where should I implement my business logic, in Java code or Stored procs.
Here is the requirement :
- One Order has 70 products (Order_Table )
- Can be duplicate products, so I have to do summarize / grouping by product
- For every product, I have to check, if it is entitled for a Bonus product, then I have to Insert one to Bonus_Table.
- This is done when/after the transaction is SAVED (COMMIT)
The question is, which one has better PERFORMANCE :
(1) Create a rowsetIterator on the Order details (70 products) and call a stored procedure to do the logic for every single product (so that the Insert to Bonus_Table done in stored proc). means the stored proc will be called 70 times.
OR
(2) After the transaction is COMMITted, call the stored procs ONCE to do the logic for all the products at once.
OR
(3) I do all the logic with Java Code within ADF
Given the requirement above, which approach is most efficient / best performance ?
Thank you very much,
xtantoProblem with this is that you ask 100 people and you probably get 100 different answers. ;o)
Many would say that you push as much business logic into the database with your data; others might say you only put data in your database and your business logic is kept on the application server.
In reality your would probably have a mix of both and your decision would probably be influenced by your own background ...
Can't be more precise than that.
Grant -
Calling an EJB deployed in OC4J from Java Stored Proc in Oracle
Hello!
Trying to make a call to an EJB deployed in OCJ4 from a oracle java stored proc. After loaded orion.jar and crimson.jar lib into SCOTT schema, I can't get the JNDI Context working because of this error:
============================================
javax.naming.NoInitialContextException: Cannot instantiate class:
com.evermind.server.ApplicationClientInitialContextFactory. Root exception is
java.lang.ClassNotFoundException:
com/evermind/server/ApplicationClientInitialContextFactory
at java.lang.Class.forName0(Class.java)
at java.lang.Class.forName(Class.java)
at com.sun.naming.internal.VersionHelper12.loadClass(VersionHelper12.java:45)
at javax.naming.spi.NamingManager.getInitialContext(NamingManager.java)
at javax.naming.InitialContext.getDefaultInitCtx(InitialContext.java)
at javax.naming.InitialContext.init(InitialContext.java)
at javax.naming.InitialContext.<init>(InitialContext.java)
===============================
I did load the java with "loadjava" with on time with the "resolve" option and time time no option and still no working.
Here is the EJB client code:
=======================================
import java.sql.*;
import java.util.*;
import javax.naming.*;
import com.evermind.server.ApplicationClientInitialContextFactory;
class EmpRemoteCall {
public static void main(String[] args) {
System.out.println(getEmpName());
public static String getEmpName() {
String ejbUrl = "java:comp/env/ejb/Emp";
String username = "admin";
String password = "admin";
Hashtable environment = new Hashtable();
environment.put(Context.INITIAL_CONTEXT_FACTORY, "com.evermind.server.ApplicationClientInitialContextFactory");
environment.put(Context.PROVIDER_URL, "ormi://127.0.0.1/testemp");
environment.put(Context.SECURITY_PRINCIPAL, username);
environment.put(Context.SECURITY_CREDENTIALS, password);
//environment.put(Context.SECURITY_AUTHENTICATION, ServiceCtx.NON_SSL_LOGIN);
//environment.put(javax.naming.Context.URL_PKG_PREFIXES, "oracle.aurora.jndi");
com.kboum.sertir.essais.EmpHome homeInterface = null;
try {
Class.forName("com.evermind.server.ApplicationClientInitialContextFactory", true, ClassLoader.getSystemClassLoader());
System.out.println("Creating an initial context");
Context ic = new InitialContext(environment);
System.out.println("Looking for the EJB published as 'java:comp/env/ejb/Emp'");
homeInterface = (com.kboum.sertir.essais.EmpHome) ic.lookup(ejbUrl);
catch (CommunicationException e) {
System.out.println("Unable to connect: " + ejbUrl);
e.printStackTrace();
//System.exit(1);
catch (NamingException e) {
System.out.println("Exception occurred!");
System.out.println("Cause: This may be an unknown URL, or some" +
" classes required by the EJB are missing from your classpath.");
System.out.println("Suggestion: Check the components of the URL," +
" and make sure your project includes a library containing the" +
" EJB .jar files generated by the deployment utility.");
e.printStackTrace();
//System.exit(1);
catch (ClassNotFoundException e) {
System.out.println("Unable to connect: " + ejbUrl);
e.printStackTrace();
//System.exit(1);
try {
System.out.println("Creating a new EJB instance");
com.kboum.sertir.essais.Emp remoteInterface = homeInterface.findByPrimaryKey(Integer.valueOf("7369"));
System.out.println(remoteInterface.getENAME());
System.out.println(remoteInterface.getSAL());
remoteInterface.setSAL(2);
System.out.println(remoteInterface.getSAL());
return remoteInterface.getENAME();
catch (Exception e) {
System.out.println(e.getMessage());
e.printStackTrace();
return "error";
nullWhat I did to solve this problem was to
create a simple RMI remote object that
resides outside the database JVM and that
serves as a proxy EJB client for your java
stored procedure. The stored procedure can
invoke a method on the remote RMI object
which then looks up the EJBean's home
interface and invokes the relevant method on
the bean's remote interface, and relays any
return values back to the java stored
procedure.
Hope this helps,
Avi.
null -
Use 'default' keyword in call string while calling stored proc?
I am calling following sql server stored procedure from java code using my jdbc driver for sql server: CREATE PROCEDURE test_findTbInfo (
@paramIn_Str varchar(10),
@paramOut_Int int OUT,
@paramIn_Int int = 20
AS
begin
set @paramOut_Int = @paramIn_Int * 100
end
If I make a call like this:
CallableStatement cs = conn.prepareCall(" { call test_findTbInfo(? , , ? ) }");
cs.setString(1, "test_tab");
cs.setInt(2, 4);
cs.execute();
It works without any error. But this is not a right behavior. !! The second parameter as you see is passed like an optional parameter. But in stored proc it is NOT an optional param and so if the value not passed it should fail...
Now if I change the code to
CallableStatement cs = conn.prepareCall(" { call test_findTbInfo(? , default, ? ) }");
it works correctly. Gives error that "Procedure 'test_findTbInfo' expects parameter '@paramOut_Int', which was not supplied." which is correct.
So is it a normal practice to use 'default' keyword while calling sql server stored procedures having optional parameters in jdbc ????
Anyone knows ??? As far as I know "call test_findTbInfo(? , , ? )" works fine except in some cases and also it forces users to put all optional parameters at the end of parameter list in stored proc.
Please let me know whether I should go with 'default' throuout for sql server stored proc while calling using my jdbc driver.
Amit{?= call <procedure-name>[<arg1>,<arg2>, ...]}The question mark in the above is the result parameter
that must be registered.
That is not the same as an OUT argument.Yes that is true. The result value and OUT parameters are different but they both MUST be registered as per jdbc API
"The type of all OUT parameters must be registered prior to executing the stored procedure; their values are retrieved after execution via the get methods provided here."
Anyway, my original question still stays as it was. If there are some optional IN parameters in stored procedure
e.g.
PROCEDURE test_findTbInfo (
@paramIn_Int int = 20,
@paramOut_Int int OUT
how do you call this?
CallableStatement cs = conn.prepareCall(" { call test_findTbInfo( , ? ) }");
cs.registerOutParameter(1, Types.INTEGER);
cs.execute();
or
CallableStatement cs = conn.prepareCall(" { call test_findTbInfo(default, ? ) }");
Also note that I am intending to use ONLY sql server driver for this.
The first as well second seem to work. Except that second way is seems reliable. I just wanted a second opinion on that...
Amit -
Sybase stored proc, no rows in the resultset
Hi!
I have a sybase stored proc that looks more like -
IF OBJECT_ID('dbo.ETC_DETAILS') IS NOT NULL
BEGIN
DROP PROCEDURE dbo.ETC_DETAILS
IF OBJECT_ID('dbo.ETC_DETAILS') IS NOT NULL
PRINT '<<< FAILED DROPPING PROCEDURE dbo.ETC_DETAILS >>>'
ELSE
PRINT '<<< DROPPED PROCEDURE dbo.ETC_DETAILS >>>'
END
go
CREATE PROCEDURE dbo.ETC_DETAILS
@trade_id id,
@broker_cd code,
@contact_group_id int,
@product_id id,
@security_type_id smallint
AS
if(cond1)
begin
select distinct
cd=t.cd,
name=t.name,
t.trade_id,..........
from
table1 t,
table2 tt,
table3 b,.......
where t.trade_id = tt.trade_id
and t.transaction_type_id = ttt.transaction_type_id
and .....
end
else
select distinct
cd=t.cd,
name=t.name,
t.trade_id,..........
from
table4 t,
table5 tt,
table6 b,.......
where t.trade_id = tt.trade_id
and t.transaction_type_id = ttt.transaction_type_id
and .....
end
go
GRANT EXECUTE ON dbo.ETC_DETAILS TO public
go
IF OBJECT_ID('dbo.ETC_DETAILS') IS NOT NULL
PRINT '<<< CREATED PROCEDURE dbo.ETC_DETAILS >>>'
ELSE
PRINT '<<< FAILED CREATING PROCEDURE dbo.ETC_DETAILS >>>'
go
EXEC sp_procxmode 'dbo.ETC_DETAILS','unchained'
go
GRANT EXECUTE ON dbo.dbo.ETC_DETAILS TO public
go
When run through SQL Editor - runs and returns me rows. But does not return any rows when invoked from Java. "gotResultSet" is true, but the while loop does not execute. Any clues, why? Here is the Java code.
public class AllocationExtractor {
public Collection getAllocations(int tradeId, String brokerCode, int contactGroupID, int productID, int securityTypeID) throws SQLException
Connection c = null;
String query = "{ call ETC_DETAILS(?,?,?,?,?) }";
CallableStatement stmt = null;
ResultSet rs = null;
boolean gotResults = false;
try{
c = ConnectionFactory.getSybaseConnection(url, user, pwd);
stmt = c.prepareCall(query);
stmt.setInt(1, tradeId);
stmt.setString(2, brokerCode);
stmt.setInt(3, contactGroupID);
stmt.setInt(4, productID);
stmt.setInt(5, securityTypeID);
gotResults = stmt.execute();
if(gotResults)rs = (ResultSet) stmt.getResultSet();
if (rs != null){
System.out.println("Got resultSet");
while(rs.next()){
System.out.println("Iterating the resultset");
Allocation a = new Allocation();
a.setTradeID(rs.getString("trade_id"));
System.out.println(a.getTradeID());
allocations.add(a);
public static void main(String args[]){
AllocationExtractor e=new AllocationExtractor();
Collection c = null;
int tradeID = 3115;
String broker_cd = new String("327");
int product_id = 20;
int contact_group_id = 1;
int security_type_id = 1219;
e.user = "developer";
e.url = "jdbc:sybase:Tds:devbox:12344";
e.pwd = "developer";
try{
c = e.getAllocations(tradeID, broker_cd, product_id, contact_group_id, security_type_id);
catch(SQLException se){
se.printStackTrace();Silly me! had switched the parameters to the method in Java.
-
New Stored Proc For Patch 20 ? SBO_SP_PostTransactionNotice
Does anyone know more information about this stored proc and at what stage it is fired?
I assume it is after an object has been "Added, Updated, closed etc..."
and this will allow us to then perform some actions
Is this correct
Please HelpHi all,
Just adding some info. The SAP Note 1039449 says the following:
<i>Three new stored procedures were added to the database:
1. SBO_SP_TransactionSupport
2. SBO_SP_PostTransactionNotice
3. SBO_SP_PostTransactionSupport
The stored procedures SBO_SP_TransactionSupport and
SBO_SP_PostTransactionSupport are encoded and cannot be edited by the user.
The stored procedure SBO_SP_PostTransactionNotice is open for editing like
the SBO_SP_TransactionNotification stored procedure.
These stored procedures are executed before and after each transaction in
SAP Business One to ensure the correctness of the transaction.</i>
Still can't find time to test it, but if I understand well (actually I'm hoping this), we can now use the TN to correctly rollback a transaction, and the SBO_SP_PostTransactionNotice to correctly notify about transactions. Any test about this topic will very welcome.
Regards,
Ian
Maybe you are looking for
-
Custom Annotation :: inject object at runtime
I would like develop a custom annotation to inject object at runtime. The annotation will work as follows 1. develop ValidatorClass annotation on type. 2. If annotated on a type object will be created at runtime and injected to the object. e.g. in cl
-
Hi Friends, I have created one userid and i want to give autharizations to acess only SUIM,SM50,PFCG, and i created one role as adding those T-codes but PFCG is not working remaining SUIM, SM50 is working for the userid. Thanks and Regards D
-
Why does my screen flicker?
After a couple of hours of use my screen begins to flicker with ghost images of windows flickering on the screen.
-
Display brightness resets on wake...
Hello everyone. I am having an odd issue I cannot seem to troubleshoot. I have an LED Cinema Display connected to my 2009 aluminum MacBook (now they are called Macbook Pro's). Seemingly at random, when I wake I will find the LED Display has reset it'
-
Can a search highlight a string inside a div
Hi, <br>I have '&P1_REPORT_SEARCH.' for Highlight Words and<br> < div style="height:70px;width:425px;overflow:auto;">#PROBLEM_DETAILS#< /div> for HTML Expression in my column attributes.<br>When I search for a string on my report page, it will identi