Dynamic queries in stored procedures - JDBC
Hi,
How do we write a query in stored procedures if the field to be selected,conditions & sort order are dynamic?
The user selected the columns,conditions & sort order only at run time.
Thanks in advance,
sundar
The syntax for a stored procedure varies by database. And support for dynamic SQL in a stored proc varies to. And it has nothing to do with java. So you are more likely to get better responses by asking the question on a board/list that is specific to your database and that address stored procedures.
And to get a response here you need to specify the database your are using, and the version might be a good idea too.
And from the design prespective you might keep in mind that dynamic SQL is significantly slower than other forms. And it is also harder to debug and code for. So you might want to consider why you need to do that.
Perhaps you actually want to know how to create dynamic SQL in Java instead?
Similar Messages
-
Dynamic Execution of Stored Procedure
Hi Everybody!
I have two questions for you. All my questions are pertaining PL/SQL programming with Oracle 8i. But before that, I would like to introduce a bit about the background.
We have .NET based application, which calls some 80 odd Oracle stored procedures one after one. The input parameters for all these stored procedure are same i.e. two IN parameters of Integer type and a OUT parameter of cursor type. The name of these stored procedures are listed in table (let say tblSPTable). We use to get the list of stored procedures from this table and execute them one after one.
Sooner or later we realized that, this way of calling the stored procedures is causing a performance issue. So, we thought of moving the call to all these stored procedures to a new stored procedure. We thought of giving a call to this new stored procedure, which will in turn execute all these stored procedures one after one (by using the tblSPTable), and return us the all the cursors at one shot. But here is where we got stuck:
How can I declare a OUT parameter for a list of cursors? Because I need to store the output of all the 80 odd calls in different cursors and have to get it back. I have tried to declare VARRAY of cursors or TABLE of cursors but it is not supported. One way of doing this is to declare all the 80 cursors as OUT parameters in the new stored procedure, but that is absolutely a bad programming practice. Apart from that, in future if we want to modify the order of the stored procedure, OR if we want to add or remove few stored procedures listed in tblSPTable, we have to modify this new procedure every time. My question is how can I declare or use a variable which can hold the list of cursors, which I can use from a .NET base application.
Secondly, I will get the name of all the stored procedure by querying the tblSPTable, and will execute them dynamically. I have tried out something like this but not succeeded
declare
cur_result some_package.some_cursor;
var_spname varchar;
begin
var_spname:=’pr_some_procedure’;
execute immediate 'begin ‘ || var_spname || ‘(:2); end;' using out cur_result;
end;
Bur, I am getting an error saying “Error while trying to retrieve text for error ORA-03113”. I have scanned through few docs available over net, but none of them are really helpful. My question is how can I dynamically execute a stored procedure which has a cursor as a OUT parameter.
Please help me out if you people have any idea regarding this. Please let me know whether my approach is correct or not. I am waiting for your valuable suggestions.
Thanking you
Ayan Mitra
Message was edited by:
user588628your solution will work out only in case all the functions returning you a cursor which holds same number of columnNot so. It is unfortunate that my example does not make that clear.
The UNION ALL is of a single column which is of type weak refcursor.
By way of example the below changes the p_dept procedure so it returns two columns rather than three.
Oracle Database 10g Express Edition Release 10.2.0.1.0 - Production
SQL> CRE ATE OR REPLACE PROCEDURE p_dept (
2 p_deptno IN dept.deptno%type,
3 p_resultset OUT SYS_REFCURSOR)
4 IS
5 BEGIN
6 OPEN p_resultset FOR
7 SELECT d.deptno, d.dname
8 FROM dept d
9 WHERE d.deptno = p_deptno;
10 END p_dept;
11 /
Procedure created.
SQL> VARIABLE p_resultset REFCURSOR;
SQL> BEGIN
2 :p_resultset := f_all (
3 p_deptno => 30,
4 p_functions => varchar2_table ('F_DEPT', 'F_EMP'));
5 END;
6 /
PL/SQL procedure successfully completed.
SQL> PRINT p_resultset;
RN FN RS
1 F_DEPT CURSOR STATEMENT : 3
CURSOR STATEMENT : 3
DEPTNO DNAME
30 SALES
2 F_EMP CURSOR STATEMENT : 3
CURSOR STATEMENT : 3
EMPNO ENAME JOB
7499 ALLEN SALESMAN
7521 WARD SALESMAN
7654 MARTIN SALESMAN
7698 BLAKE MANAGER
7844 TURNER SALESMAN
7900 JAMES CLERK
6 rows selected.
SQL>[pre] -
DDL statements and dynamic sql in stored procedure
I created a stored procedure to create and drop tables, using dynamic sql.
When I try to do the inserts using dynamic sql, i.e
v_string := 'INSERT statement';
EXECUTE IMMEDIATE v_string;
I get the following error message:
ERROR at line 1:
ORA-00942: table or view does not exist
ORA-06512: at line 63
Line 63 happens to be the line that the EXECUTE IMMEDIATE v_string; statement is in.
I am able to describe the table that the inserts are being made into, so I know that the table exists.
Any idea why I'm getting this error message would be appreciated.Yes I do and I have been able to create other tables using dynamic sql.
The table that I am having problems with SELECTs data from another table to get its column values; within the SELECT statement, the CAST function is used:
ie. CAST(CASE SUBSTR(CAST(E_MOD AS VARCHAR(7)),2,3)
WHEN 'AAA' THEN 'A55'
ELSE ............
I get the following error message:
ERROR at line 18: (this line starts the CAST statement)
ORA-06550: line 18, column 13:
PLS-00103: Encountered the symbol "AAA" when expecting one of the following:
. ( * @ % & = - + ; < / > at in is mod not rem return
returning <an exponent (**)> <> or != or ~= >= <= <> and or
like between into using || bulk
When I remove the quotes or add another single quote, the same error cascades to 'A55'.
After doing the same for the next error, I get the error message below:
ERROR at line 1: (this line has the EXECUTE IMMEDIATE statement)
ORA-00936: missing expression
ORA-06512: at line 6
Any idea what the problem could be?
Also is there another way to have DDL statements as stored procedures other than using dynamic sql or the DBMS_SQL package? -
MS SQL Server Stored Procedure - JDBC Receiver Adapter
Hi,
I am calling a stored procedure in MS SQL Server using the JDBC Receiver Adapter. The stored procedure takes 1 input parameter which is a VARCHAR field. The stored procedure's input parameter and the input parameter are identical. My target structure looks like:-
<STATEMENT>
<storedProcedureName action="EXECUTE">
<TABLE>SP_REPROCESS</TABLE>
<input1 isInput="true" type="VARCHAR">1</input1>
</storedProcedureName>
</STATEMENT>
I am getting the following error:-
Message processing failed. Cause: com.sap.engine.interfaces.messaging.api.exception.MessagingException: Error processing request in sax parser: Error when executing statement for table/stored proc. 'SP_REPROCESS' (structure 'STATEMENT'): com.microsoft.sqlserver.jdbc.SQLServerException: String or binary data would be truncated.
Any suggestions.
Thanks.
Krishnan
Edited by: Krishnan on Jul 17, 2008 7:07 AM
Edited by: Krishnan on Jul 17, 2008 7:07 AM
Edited by: Krishnan on Jul 17, 2008 7:48 AMhi,
can anyone help me to fix this issue.
In MONI, i am able to see the output xml as :-
<?xml version="1.0" encoding="UTF-8"?>
<ns0:REPROCESS_DATA_MT xmlns:ns0="http://abc.com/db/integration">
<STATEMENT>
<storedProcedureName action="EXECUTE">
<TABLE>SP_REPROCESS</TABLE>
<input1 isInput="true" type="VARCHAR">1</input1>
</storedProcedureName>
</STATEMENT>
</ns0:REPROCESS_DATA_MT>
in the communication channel monitoring --> in the JDBC receiver channel, I am getting the following error:-
Message processing failed. Cause: com.sap.engine.interfaces.messaging.api.exception.MessagingException: Error processing request in sax parser: Error when executing statement for table/stored proc. 'SP_REPROCESS' (structure 'STATEMENT'): com.microsoft.sqlserver.jdbc.SQLServerException: String or binary data would be truncated.
thanks.
krishnan -
Passing dynamic parameter to stored procedure from CR formula?
Dear all,
I need to insert in some textboxes the right string based on the desired Language Code.
I crated a stored procedure in my db.
CREATE PROCEDURE MY_GET_TRANSLATION
@TextID nvarchar(8),
@LangCode int
This parameters are used as keys to get the Trans field.
I created a workshop formula: GetTranslation
Please, can someone suggest the correct statement to call my MY_GET_TRANSLATION stored procedure passing parameters?
I would like to call the GetTranslation formula from all my textboxes, passing the specific TextID value
and visualized the right translated string.
For example:
in my TEXT1 textbox, I would like to call the GetTranslation formula passing the parameters
TextID = "T000001"
and
LangCode = 13 (Italian language)
How can pass dynamic parameters to a formula?
How can pass dynamic parameters to a stored procedure from a CR formula?
Regards
EmanueleDear Jason,
I'm trying to modify a SAP B1 CR marketing report.
This CR marketing document is called by SAP B1 automatically passing the Document Number and Document Type.
The report uses the right SAP B1 tables to read the information of the header and rows of the document.
The language of the document is contained in a field of the header table
{MyMarketingDocTable.LanguageID}
I created a user table named "MyTranslationTable" where I added some strings in different langiages.
For example:
TexiID TextString LangID
T00001 Delivery 8
T00001 Consegna 13 (Italian translation)
T00002 Invoice 8
T00002 Fattura 13 (Italian translation)
In the header of the report I'd like, for example, to visualise the string "Consegna" if my document is a delivery in italian language.
I'd like to implement this method to translate all the textboxes (header, comments, etc.) based on the languageID of my document.
For each textboxes, in the CR designer statically I know what TextID I want to visualized but dinamically I need to pass to my stored procedure the right language. I'd like my report automatically gets the language at run-time. I don't want that when I press the Print-preview button in SAP B1, the report asks to prompt the languageID.
It already read the DocNum and DocType and it already filter the SAP B1 tables basing on the DocNum and DocType of the document. In this way it reads the right row in the SAP B1 table and in this way I can read all the fields of this row (also the languageID of the actual document).
Regards
Emanuele
Edited by: Emanuele Croci on Dec 3, 2010 9:03 AM -
Dynamic prompting with stored procedures XI- urgent
Post Author: moleary77
CA Forum: Crystal Reports
I have a report that has 7 parameters and two stored procedures, I get the dynamic prompting to work wonders as stand alone dynamic parameters, however I need them to be cascading. How can I accomplish this while still using my stored procedures? Is there something I need to change within the stored procedure, I've looked all over in Crystal and I can't seem to figure it out. Please let me know! Below are my stored procs
set ANSI_NULLS ONset QUOTED_IDENTIFIER ONGOALTER PROCEDURE [dbo].[gm_RPT_Appt_Parms]-- Add the parameters for the stored procedure hereASBEGIN-- SET NOCOUNT ON added to prevent extra result sets from-- interfering with SELECT statements.SET NOCOUNT ON;-- Insert statements for procedure hereDECLARE @PTABLE TABLE(COMPANY VARCHAR(10) NULL,BOOKCODE VARCHAR(22) NULL,FACILITY VARCHAR(47) NULL,PROV VARCHAR(21) NULL,LOGONID VARCHAR(15) NULL,DEPARTMENT VARCHAR(26) NULL)--GET COMPANIESINSERT INTO @PTABLE(COMPANY, BOOKCODE, DEPARTMENT ) SELECT DISTINCT COMPANY , BOOKCODE, DEPARTMENT FROM MWBOOK ORDER BY COMPANY , BOOKCODE, DEPARTMENT INSERT INTO @PTABLE(COMPANY, FACILITY ) SELECT DISTINCT COMPANY, FACILITY FROM CLFAC ORDER BY COMPANY, FACILITY INSERT INTO @PTABLE(COMPANY, PROV ) SELECT DISTINCT COMPANY , PROV FROM MWPROV ORDER BY COMPANY , PROV SELECT * FROM @PTABLE
END
set ANSI_NULLS ONset QUOTED_IDENTIFIER ONGOALTER PROCEDURE [dbo].[gm_RPT_Appt_Data] -- Add the parameters for the stored procedure here @START DATETIME, @END DATETIME, @COMPANY VARCHAR(10), @BOOK VARCHAR(2056) = NULL, @USERCODE varchar(2056) = NULL, @FACILITY varchar(2056)= NULL, @PROV varchar(2056) = NULLASBEGIN -- SET NOCOUNT ON added to prevent extra result sets from -- interfering with SELECT statements.DECLARE @VALUES VARCHAR(2000) SET NOCOUNT ON; IF(@BOOK IS NULL) BEGIN SET @VALUES = '' SELECT @VALUES = @VALUES + COALESCE(BOOKCODE + ',','') FROM MWBOOK WHERE COMPANY = @COMPANY SET @BOOK = @VALUES END IF(@FACILITY IS NULL) BEGIN SET @VALUES = '' SELECT @VALUES = @VALUES + COALESCE(FACILITY + ',','') FROM CLFAC WHERE COMPANY = @COMPANY SET @FACILITY = @VALUES END IF(@USERCODE IS NULL) BEGIN SET @VALUES = '' SELECT @VALUES = @VALUES + COALESCE(LOGONID + ',','') FROM CLUSER WHERE COMPANY = @COMPANY SET @USERCODE = @VALUES END
IF(@PROV IS NULL) BEGIN SET @VALUES = '' SELECT @VALUES = @VALUES + COALESCE(PROV + ',','') FROM MWPROV WHERE COMPANY = @COMPANY SET @PROV = @VALUES END SELECT mws.ANOTE, mwb.BOOKNAME, mwb.FACILITY, LEFT(mwa.PATIENTID, 50) AS PATIENT, mwa.ADATE, mwa.ADESC, mwa.ANOTE, mwa.USERCODE, mwa.BOOK, mwa.USERFLAG, mwa.ATIME, mwa.COMPANY, mwa.AKEYTIME, mwb.PROV FROM dbo.MWAPPTS mwa LEFT OUTER JOIN dbo.MWBOOK mwb ON mwa.COMPANY = mwb.COMPANY AND mwa.BOOK=mwb.BOOKCODE LEFT OUTER JOIN dbo.MWSCHED mws ON mwa.ADATE=mws.ADATE AND mwa.BOOK=mws.BOOK AND mwa.COMPANY = mws.COMPANY WHERE mwa.BOOK IN (SELECT ARRTEXT FROM DBO.SPLIT(@BOOK, ',')) AND mwa.USERCODE IN (SELECT ARRTEXT FROM DBO.SPLIT(@USERCODE, ',')) AND mwa.ADATE BETWEEN @START AND @END AND mwb.FACILITY IN (SELECT ARRTEXT FROM DBO.SPLIT(@FACILITY, ',')) AND mwa.COMPANY=@COMPANY AND (mwb.PROV IN (SELECT ARRTEXT FROM DBO.SPLIT(@PROV, ','))) ORDER BY MWA.ADATE, MWA.BOOK
ENDSince your {?Project} parameter is part of a stored procedure, you have to think of it as part of the table.  In reality, it could "change" the result set so Crystal has always prompted them first. It's like in math with the order of operation between +-*/.Â
All "added" parameters (like the one you created within the report) must be prompted after the server-based prompts (stored proc).
- Kathryn Webster (Report Design Specialist) -
Here is a chunk of code from my servlet, which is calling a stored procedure...
String userID = request.getParameter("hdnUserID");
String serialNum = "123456789";
String pinNum = "987654321";
String cliNum = request.getParameter("txtclinum");
String price = request.getParameter("txtprice");;
String creationDate = "";
String ActivationDate = "";
String validityMonths = request.getParameter("ddlvaliditymonths");
String balance = "100";
String statusId = request.getParameter("ddlstatus");
String batchId = request.getParameter("ddlbatch");
String retID = request.getParameter("hdnID");
String vID = retID;
xDatabase db = new xDatabase();
try {
CallableStatement pCall = db.m_conDatabase.prepareCall(
"{call bil_sp_add_scratch_card_batch(?,?,?,?,?,?,?,?,?,?,?,?)}");
pCall.setString(1, retID);
pCall.setString(2, serialNum);
pCall.setString(3 , pinNum);
pCall.setString(4 , cliNum);
pCall.setString(5 , price);
pCall.setString(6 , creationDate);
pCall.setString(7 , ActivationDate);
pCall.setString(8 , validityMonths);
pCall.setString(9 , statusId);
pCall.setString(10 , batchId);
pCall.setString(11 , balance);
pCall.setString(12 , userID);
pCall.executeQuery();
//close the statement
pCall.close();and here are the stored procedures parameters.. the stored procedure works fine as i tested it manually in oracle..
create or replace procedure bil_sp_add_Edit_scratch_card
v_CARD_ID in out varchar2,
v_CARD_SERIAL_NUM in varchar2,
V_CARD_PIN_NO in varchar2,
V_CLI_NO in varchar2,
V_CARD_PRICE in varchar2,
V_CARD_CREATION_DATE in varchar2,
V_CARD_ACTIVATION_DATE in varchar2,
V_CARD_VALIDITY_MONTHS in varchar2,
V_CARD_STATUS_ID in varchar2,
V_SCRATCH_CARD_BATCH_ID in varchar2,
V_CARD_BALANCE in varchar2,
user_id in varchar2
)And i get this exception
java.sql.SQLException: ORA-00936: missing expression
at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java)
at oracle.jdbc.ttc7.TTIoer.processError(TTIoer.java)
at oracle.jdbc.ttc7.Oall7.receive(Oall7.java)
at oracle.jdbc.ttc7.TTC7Protocol.doOall7(TTC7Protocol.java)
at oracle.jdbc.ttc7.TTC7Protocol.parseExecuteDescribe(TTC7Protocol.java)
at oracle.jdbc.driver.OracleStatement.doExecuteQuery(OracleStatement.java)
at oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout(OracleStatement.java)
at oracle.jdbc.driver.OracleStatement.doScrollStmtExecuteQuery(OracleStatement.java)
at oracle.jdbc.driver.OracleStatement.executeQuery(OracleStatement.java)
at ibill.xDatabase.executeSQL(xDatabase.java:143)
at org.apache.jsp.iBillForms.scratchCardNewAddEdit_jsp._jspService(org.apache.jsp.iBillForms.scratchCardNewAddEdit_jsp:98)
at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:97)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:322)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:291)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:241)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:856)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:744)
at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)
at org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:80)
at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:684)
at java.lang.Thread.run(Thread.java:595)I am sending all the required parameters to the procedure then what is the problem?OOPPPSssssss..
Oh GOD is there somebody out there. who would like to kill me..
The only problem was that i was calling the wrong stored procedure
:( -
How to TRUNCATE a table dynamically in a Stored Procedure?
Hi everyone, How can I create a Procedure with dynamic sql to truncate a table name I pass by every time in Oracle? I am running the following query and nothing happens. It neither creates the procedure nor errors out.
CREATE OR REPLACE PROCEDURE TruncateTable(TableName IN VARCHAR2(50))
IS
BEGIN
SQLCmd VARCHAR(200);
BEGIN
SQLCmd := 'TRUNCATE TABLE ' || TableName;
EXECUTE IMMEDIATE SQLCmd;
END;
Could someone please help me?
ThanksThanks Brendan for the reply. But, it neither does anything after I add a "/" on line9. Just wondering if the syntax of the proc is correct?
-
Parallel vs Series mode running queries in Stored Procedures
Experts,
My Sp is something like this:-
ALTER SP-NAME
AS
BEGIN
INSERT INTO TABLEA
INSERT INTO TABLEB
INSERT INTO TABLEC
END
Will all the 3 inserts statements will run in parallel when SP is executed?
if yes, how to run in serial mode within the same SP?
Thank You
Regards,
Kumar
Please do let us know your feedback. Thank You - KG, MCTSYou can design parallel load with SSIS: Designing Your SSIS Packages for Parallelism (SQL Server Video)
Kalman Toth Database & OLAP Architect
SQL Server 2014 Database Design
New Book / Kindle: Beginner Database Design & SQL Programming Using Microsoft SQL Server 2014 -
JDBC Sender With Stored Procedure & Context Handeling
Hi All,
In my scenario i am using stored Procedure in JDBC sender adapter for Fetching data,
I am fetching data from 3 tables kepping a one key element Exampkle <matnr> for each value in this <matnt> in table 1 i will fetch the corresponding records in table 2 and 3 ...
how can i use context in mapping such a sender structure to hendle the emplty value ...give me some idea...
if any one has come across such situation plz help me ....it very urgent .
thanks
ShakifHi,
Follow this
/people/siva.maranani/blog/2005/05/21/jdbc-stored-procedures
JDBC adapter
/people/saravanakumar.kuppusamy2/blog/2005/01/19/rdbms-system-integration-using-xi-30-jdbc-senderreceiver-adapter
stored procedure
/people/sriram.vasudevan3/blog/2005/02/14/calling-stored-procs-in-maxdb-using-sap-xi
Helpful link
http://help.sap.com/saphelp_nw04/helpdata/en/45/023c41325fa831e10000000a1550b0/frameset.htm
Might help you..
vasanth. -
Best Way to call Dynamically an stored procedure
Hi Guys,
Here my question... I need to call dynamically to an stored procedure...
- the stored procedure can change, the name , the number of parameters
- the called stored procedure can contain output parameters.
lv_sql := 'BEGIN '|| lv_program_name || ' ( ' || get_parameters(lv_program_name) || '); END;';
get_parameters function generates an string depeding on the number of parameters that this function reads from the
oracle dictionary (i.e: ':1,:2,:3,:4......... )
then the dynamyc code must be executed as follow
execute immediate lv_sql
using .................................?????????
The issue that I am facing is how to handle the "using clause".... since before that I ran the program I dont know how many parameters the program will have...
Please your help... (or suggestion to solve in another way)
...:::OKMMAN:::...About "Satyaki_De " comment,
Since I dont know the stored procedure to be called, I cant know the number of parameters and its type to be returned... I mean.. to use the clause "using ...." in static way...
By now, I am creating dinamically a stored procedure... I am building a stored procedure that calls to the "unknown" stored procedure... reading the data dictionary and building dynamically the "Using...." clause... but I dont like ... since probably in production enviroment I will not have that kind of grants....
Regarding the link... I didn't know that new type... ! That's will solve the type issue... but still is pending the number of variable to provide to the "using" clause...
...:::OKMMMAN:::...
Edited by: okmman_cl on Feb 11, 2009 1:59 PM -
Query in Stored Procedure accessing another schema
Hi - this is going to sound kind of strange and even i can't come up with an explanation. My JDK 1.1.7 applet uses a type 4 JDBC thin driver (i think v 8.04.06) to access an Oracle 7.3.4 database. We also have a link with full grants and synonymns to another Oracle schema in an Oracle 8 database. Has never been a problem - we can access anything we need to through queries or stored procedures from either of these databases.
So, i have a new stored procedure that needs to be called through JDBC that queries a table in the Oracle 8 database. For some reason, whenever i execute this stored procedure from java it hangs on this query and the instance needs to be restarted. If i execute that same stored procedure from SQL Plus, it runs fine.
I tried a little test. I put a straight query in my java code that goes directly to that table (no stored procedure involved). It runs great through java!
is this weird or what? my dbas have checked out all privelages and it seems that i have access to everything i could possibly need.
If anyone has any suggestions i would love to hear them.
thanks for your help...
Lori - [email protected]
nullYou can only access an object in another user's schema if you either:
(a) Specify the 'other' schema name explicitly: SCHEMA.OBJECT
(b) A synonymn has been created to access the object: CREATE SYNONYM OBJECT FOR SCHEMA.OBJECT.
The user requiring the synonym should create it, or the user owning the object can create a PUBLIC synonym, if they have the authority.
To check my hypothesis, try typing 'DESCRIBE procedure_name' from SQL*Plus as both users. -
Using Stored Procedure Universe in Reports
Hi Friends,
I got some issues using SP's in Universe and WebI Report.
Case #1:
Can we execute dynamic SQL using stored procedure universe..?
I use SQL server as the DB for my reports.I created a SP which will execute on getting a input value from the user.This input value will frame the SQL dynamically in the SP.for executing the dynamic SQL i use sp_executesql inside the SP.The SP wexecutes successfuly in the DB but when i try executing it in the Universe i get a error message as follows: "Exception : DBD,[Microsoft][SQL SErver Native Client 10.0][SQL Server]Incorrect syntax nesr 'FROM'.State:42000"
The script i used for creating SP for your reference:
CREATE PROCEDURE P_S_GetCodeValueList
@s_table nvarchar(75)
as
begin
declare @s_sqlCommand nvarchar(1000)
declare @s_tablename nvarchar(75)
declare @s_code nvarchar(75)
set @s_tablename=@s_table
set @s_code = '*'
set @s_sqlCommand= 'SELECT ' + @s_code + ' FROM ' + @s_tablename
exec sp_executesql @s_sqlCommand
end
Case #2:
AIl also tried creating reports using the SP Universe which needs to get the parameter when the user refesh the report.
But every time the report is refreshed the report fetches the data which was produced when the SP is executed in the Universe for the first time.
I need to get the prompt in the report , to which the user could give a value and the SP gets executed for that value.
Is there any option in BO to do this?
It will be very helpful if you could give me some work arounds on this.
Regards,
SugumarHi Sugumar,
I can answer you for your 2nd question:
When you create the Stored procedure in the Universe and test it on retreiving data by inserting variable input you can check if the user could insert new value for the SP parameters.
Hope this helps!
Regards
Giuseppe -
Using temporary tables in stored procedures
Suppose that I have created a temporary table in a stored procedure using an "EXECUTE IMMEDIATE" statement. When I compile the procedure, that table is not created yet, so the compiler says that the table does not exist.
What is the way of using temporary tables in stored procedures?It's a good practice to avoid using DDL statements being executed from stored procedures. "Truncate Table" via dynamic SQL from stored procedure is a different story and is useful in DSS environments.
But if you insist on "creating" tables using Dynamic SQL from Stored Procedures then you must also embed your DML statements in Dynamic SQL to avoid compilation errors.
Example:
Create or Replace Procedure Proc_TestDynamicSQL is
Begin
Execute Immediate 'Create table myTable as select * from user_tables' ;
Execute Immediate 'Update myTable set table_name = ''Test'' ' ; --two single quotes before and after the string "Test"
End;
In this case, Oracle wouldn't care about the table references during compilation. -
Hi All,
I need to create Report Models using stored procedures. But whenever I am going to create data sources for same, I am just getting tables and views to use. Please see the screenshot below:
Is there any way out to create data source based on stored procedure? Please help.
Thanks in Advance
Regards
KumudHi Kumud,
As per my understanding, it is not support to create a Datasource View (DSV) using stored procedures.
In a DataSource View, only views, tables or named queries can be used. We can use stored procedures in a query. No parameterized queries, parameterized stored procedures or parameterized UDFs can be used in a DSV named query. You can try to using below approach
to achieve what you are require:
To build views in our relational source and add the views to the datasource view to proceed with modelling.
There is a similar issue, you can refer to it.
http://social.msdn.microsoft.com/Forums/sqlserver/en-US/22207c21-03c7-4e5a-bb67-0372f29220a3/sql-server-reporting-services-2008-creating-report-models-using-stored-procedures
Regards,
Alisa Tang
Alisa Tang
TechNet Community Support
Maybe you are looking for
-
Web Service Operation Returning null
Hi All, I have a web service proxy generated from WSDL. Which is generated fine. Once i started using the operations in the Client program. the call to the webservice is successful but the return type(This is a complex type, referring to different el
-
How to update the apps while disable Settings General Restrictions Installing Apps ??
Hi I will give my old iPad to my mom and I would like to disable "Settings>General>Restrictions>Installing Apps" so that she or other famliy kids will not unintentionally install some bad/garbage apps. But I found a problem, without Apps Store, the
-
How to create cfc for this give solution
<cfcomponent> <cffunction name="doc" access="remote" returntype="Any" > <cfargument name="profile_id" type="any" required="true" default="" > <cfargument name="search_primary_storage_profile_id_only" type="numeric" required="true" > <cfargument n
-
I don't need iTunes to bounce and tell me its iMatch server can't work
This makes me so angry, this is like Windows quality software engineering. Don't tell me that your servers aren't working and can't scan my whole iTunes Library for iMatch. It's annoying, almost as annoying as those stupid Adobe Reader update popup
-
Problem with embedded data-sources.xml and custom UserManager
Hi all, Our application uses a custom UserManager, which is basically extended from the JDBC UserManager, declared as follows in orion-application.xml: <user-manager class="com.infocorpnow.a2g.security.oracle.A2GUserManager"> <property