Calling a stored procedure in crystal report
I am using crystal reports 11 on the front end connected to mssql server in the back end and i have a stored procedure written in mssql and has a view created. i want to know how do i call a stored procedure from crystal report when i run my report and how to pass the values from my prompt to the stored procedure
As long as the stored procedure returns a result set, the procedure should look and act just like table and the report will know what parameters are need to execute the procedure. If this does not answer your question, please provide more specifics.
Similar Messages
-
Error connecting to stored procedure in crystal report
Hello
I'm using crystal reports 2008 with the latest service pack.
i'm trying to access stored procedure using the mysql jdbc driver 5.17. The crystal report has been designed which works fine with a login that created the stored procedure but when i try to run with another login that will used to run the crystal reports
The login has access to execute the stored procedure but entered in the crystal report it complains about
"User does not have access to metadata required to determine stored procedure parameter types. If rights cannot be granted, configure with {noAccessToProcedureBodies=true} to have driver generate parameters that represent INOUT strings irregardless of actual paramter types"Hi Sharon
Thanks for response.
I have checked that the user has permission to read and write. When i try and execute the stored procedure in the database by login with the user, it runs fine.
When i try and call the stored procedure from crystal reports it throws that error message.
regards
Naresh -
Stored Procedure for Crystal Reports
Hi All,
I developed this test stored procedure to see wheather we could a stored procedure for crystal reports. It compiled without any problem, but when I run it, it gives me error message. Here is the stored Procedure..
CREATE OR REPLACE PROCEDURE WOLD1SIM.TEST_PROCEDURE(
TEST_CURSOR IN OUT TEST_PACKAGE.TEST_TYPE,
TEST_PARAMETER IN TEST_TABLE.ID%TYPE)
AS
BEGIN
OPEN TEST_CURSOR FOR
SELECT *
FROM TEST_TABLE
WHERE TEST_TABLE.ID = TEST_PARAMETER;
END TEST_PROCEDURE;
And
This is the error message..
ERROR at line 2:
ORA-06550: line 2, column 1:
PLS-00201: identifier 'TEST_PROC' must be declared
ORA-06550: line 2, column 1:
PL/SQL: Statement ignored
I have created the package sucessfully.
I was wondering If any one of you can advice me where I am making the mistake.
Thank youCREATE OR REPLACE PROCEDURE WOLD1SIM.TEST_PROCEDURE(TEST_CURSOR IN OUT TEST_PACKAGE.TEST_TYPE,
TEST_PARAMETER IN TEST_TABLE.ID%TYPE)
...you have 2 parameters in your procedure WOLD1SIM.TEST_PROCEDURE(). you should also use two parameters when you execute the procedure. -
Using stored procedures within Crystal Reports
Hello all,
Background Information:
I am trying to teach myself how to execute a stored procedure within Crystal Reports. This is an aspect of Crystal that my work group has not utilized before and we're trying to gather information on the subject. We use Oracle to create and execute functions and procedures all the time, but I've never tried this within Crystal.
I use the "Add Command" functionality within Crystal on most of my reports so that I can taylor the sql to the report. I find this easier to do versus using the ODBC connection to the tables and writing the code through the Crystal Reports wizard. I also frequently use functions within these sql statements that are inserted in the Add Command.
What I'm trying to achieve:
I have a report that needs to run as a "trial", and then later as a committed "run". This is for a monthly billing system. Essentially, the user will run the report as the "trial", preview the data, make any necessay corrections, and then later, run the actual billing run. Within my application, the bills are not actually marked as "billed" until they are actually "billed', if that makes sense. As a result, the "trial" report will need to mark the bills as "billed", generate the report, and then rollback the data (so that the bills are not "billed". Once the actual billing reports are ran, the same report will run, but with a "commit" at the end of the report so that the bills are now "billed".
I'm trying simple tests and failing (i.e. taking baby steps to learn what capabilities Crystal has):
I created as simple of a procedure as I can envision. This procedure inserts the word "test" in one of my fields for a provided account number. When I try to run this procedure via Crystal (via New Report ->History->My ODBC Database link->Stored Procedures), Crystal asks for the account number parameter, as it should. But I then receive the error message:
Database Connector Error: '42000:[Microsoft][ODBC driver for Oracle]Syntax error or access violation'
The existing ODBC connection has work great for years and years to retrieve data from tables, but this is the first time I've tried to utilize procedures. Can anybody help? And can anybody explain what the Stored Procedures link is supposed to do? Am I going down the right path?
thanks,
NoelHello,
Make sure the Oracle client install path is in the PATH statement. And also make sure you are using an IN/OUT cursor. CR only reads the last SELECT statement. Search the Documents area on how to create a Stored Procedure.
Also, if you are using CR XI ( 11.0 ) then upgrade to CR XI R2 and apply all service packs ( SP 6 ). Go to this link: http://www.sdn.sap.com/irj/boc and download the trial version of CR XI R2 and use your XI keycode, then apply the patches which you can get to by clicking on the BusinessObjects tab above, then Downloads.
Direct link to the Trial version: http://www.sap.com/solutions/sapbusinessobjects/sme/freetrials/index.epx
It may fix your issue also.
Thanks again
Don -
Calling stored procedure into Crystal Report
Could any one help in suggesting how to call the stored procedure with parameters into crystal report?
i have tried using couple of methods
I have added this in add command option of Crystal report
Execute HRMS_DEVP.DPRC_GET_LEAVE_BAL(P_COMP_CODE,P_EMP_CODE,P_LV_CATG_CODE,P_DATE,P_BALANCE)
WHERE in p_balance i would be retrieving the output.
Second method i followed is
SELECT DFUN_GET_LEAVE_BAL(:P_COMP_CODE,:P_EMP_CODE,:P_LV_CATG_CODE,:P_DATE)FROM
DUAL;Hi,
Have you tried the 'get_value' function?..The syntax is
declare
l_dept number(5);
begin
l_dept := get_value('dept');
/* further process */
end;
where 'dept' is name of the bind variable.
-Krishnamurthy -
Stored Procedure in Crystal Report
Dear Experts,
I have created one Stored Procedure where Baseentry of invoice is the parameter. Now want to design a crystal report based on that. How to proceed? Please guide stpwise. I am using ODBC connection. And in Crystal report also the parameter should be the baseentry. How to integrate?
Regards,
Akash A.Hi Akash,
Using a Stored Procedure in Crystal
And with that little introduction, we finally get to the point of this articleu2014using stored procedures to simplify data queries for Crystal. Although we canu2019t make the above query into a database view, we can incorporate it into a stored procedure that returns a result set and then feed that stored procedure into Crystal no differently than we would feed a query based on views or tables.
Since stored procedures are so different between Oracle and SQLServer, weu2019ll first show you how to use a stored procedure in Crystal, given that it is already created. Then, weu2019ll separately show you how to create the procedure in SQLServer and Oracle.
When creating a Crystal Report, make it like any other report, except for the following.
1. When specifying a data source, instead of selecting Tables or Views, select Procedures, and then select the newly created procedure.
2. Crystal will immediately prompt you to enter values for the procedureu2019s input parameters. Do NOT do so; rather, check u201CSet as Nullu201D and click OK so Crystal will know to prompt for these as input parameters each time the report is run.
3. If you are using SQLServer, click on the Field Explorer and rename the fields to remove the u201C@u201D prefix that Crystal automatically adds to conform to SQLServer parameter/variable naming conventions. (This is not necessary if you are using Oracle.)
Then finish the report as you normally would. In our example, since all of the hard work was done in the query embedded inside of the stored procedure, the work in Crystal is trivial.
or check http://www.pdssoftware.com/newsletter/mar07/page6.htm
http://www.crystalreportsbook.com/Forum/forum_posts.asp?TID=2143
Thanks,
Neetu -
Error Calling Oracle Stored Procedure From Within Report
Hi,
I have a report that calls an oracle stored procedure which returns a ref cursor. The report is working ok in our development environment when called from our development website through .NET.
When the report is moved and accessed from our UAT website we get the following error :-
Failed to open a rowset. Details: ADO Error Code: 0x Source: Microsoft OLE DB Provider for Oracle Description: One or more errors occurred during processing of command. Failed to open a rowset. Details: ADO Error Code: 0x Source: Microsoft OLE DB Provider for Oracle Description: ORA-06550: line 1, column 7: PLS-00306: wrong number or types of arguments in call to 'RHS_GET_CAND_SECTION_REFS' ORA-06550: line 1, column 7: PL/SQL: Statement ignored Native Error: Failed to open a rowset. Error in File C:\WINDOWS\TEMP\temp_d663a952-bef6-4bf7-bf1a-5e288afdb612 {9B6DFB38-A436-4940-9D80-B4C23DFFFF19}.rpt: Failed to open a rowset.
If we open the report manually we are prompted to enter database connection info. If we enter the UAT connection details the report runs ok. If we save the report and try to open it from UAT website through .NET it now opens ok.
If we then move that same report back to the development environment and open from our development website it fails with the same error above.
Both connections are using Microsoft OLE DB drivers and the Oracle databases are the same version (10.2.0.1.0).
Is the connection information being stored in actual report and somehow being used when the report is opened through .NET?
Any help appreciated
Regards
PaulHi,
Please let me know if the issue occurs with the crystal reports designer, if you are facing issues with the .NET application then a need to create a post [here|SAP Crystal Reports, version for Visual Studio;.
Regards,
Hitesh -
Stored Procedure and Crystal Report
Hi,
I am using oracle 9i and trying to make a crystal report out of a stored procedure. I am using sys_refcursor type to return the record. I just wonder if it is at all possible to return two or more select statements from different tables using the stored procedure. Any help with an example will be highly appreciated.
This is my code :
CREATE OR REPLACE PROCEDURE "TEST"."PROC_TEST_1" (Test_Cursor
OUT sys_refcursor,
p_extract_date IN CHAR
AS
v_extract_date VARCHAR2(10);
BEGIN
OPEN Test_Cursor For
select emp_id,emp_name from employees;
--- this is what I want to send after sending employees records.
--- select emp_loan,emp_loan_type,emp_loan_date from emp_loans;
END PROC_TEST_1;
Thanks,
JSYou could do something like the following:
SQL> variable rc refcursor
SQL> exec open :rc for select d.*, CURSOR(select empno, ename from emp e where e.deptno = d.deptno) from dept d ;
PL/SQL procedure successfully completed.
SQL> print rc
DEPTNO DNAME LOC CURSOR(SELECTEMPNO,E
50 OPERATIONS MY LOC CURSOR STATEMENT : 4
CURSOR STATEMENT : 4
no rows selected
DEPTNO DNAME LOC CURSOR(SELECTEMPNO,E
10 ACCOUNTING NEW YORK CURSOR STATEMENT : 4
CURSOR STATEMENT : 4
EMPNO ENAME
7782 CLARK
7839 KING
7934 MILLER
3 rows selected.
20 RESEARCH DALLAS CURSOR STATEMENT : 4
CURSOR STATEMENT : 4
EMPNO ENAME
7369 SMITH
7566 JONES
7788 SCOTT
7876 ADAMS
7902 FORD
5 rows selected.
30 SALES CHICAGO CURSOR STATEMENT : 4
CURSOR STATEMENT : 4
EMPNO ENAME
7499 ALLEN
7521 WARD
7654 MARTIN
7698 BLAKE
7844 TURNER
7900 JAMES
6 rows selected.
40 OPERATIONS BOSTON CURSOR STATEMENT : 4
CURSOR STATEMENT : 4
no rows selected
5 rows selected.
SQL>you could also have your procedure return more than one SYS_REFCURSOR as OUT parameter. You would have to see how the caller will be able to handle this type of syntax.
Others may provide better/easier solutions. -
Unable to get the data from ms sql stored procedures using crystal report 10
Dear,
I am using the crystal report 10 and MS SQL 2000. I created stored procedures and after making the connection, i am unbale the data from that procedure. When i run stored procedure on MS SQL server it works fine.
Please help me.
Best Regards
Pankaj
[email protected]Dear,
I am using the crystal report 10 and MS SQL 2000. I created stored procedures and after making the connection, i am unbale the data from that procedure. When i run stored procedure on MS SQL server it works fine.
Please help me.
Best Regards
Pankaj
[email protected] -
How to use stored procedure in crystal report for eclipse
Hi;
I am working on crystal report for eclipse 2.0 and trying to use stored procedure in report .It is created from Oracle but it is not showing any dependencies
CREATE OR REPLACE procedure ACT_DB.getCostTransferDetails
p_In_Contract_ID varchar2 DEFAULT '*',
p_In_Status_ID varchar2 DEFAULT '*',
p_In_COST_TRAN_DATE varchar2 DEFAULT '*',
p_In_DEPT_ID varchar2 DEFAULT '*',
p_In_PROJECT_ID varchar2 DEFAULT '*',
p_In_EMPLOYEE_ID varchar2 DEFAULT '*',
p_Out_CostTransfer_Cusor OUT COST_TRANSFER_PACKAGE.COST_TRANSFER_TYPE
AS
BEGIN
OPEN p_Out_CostTransfer_Cusor FOR
SELECT
header.cost_tran_id,
header.cost_tran_date,
header.total_credit_amount,
header.total_debit_amount,
header.transfer_status,
header.updated_by,
header.added_by,
header.trf_over_ninety_days,
header.business_unit_id,
header.equip_approval,
header.batch_desc,
details.opr_unit_id,
status.status_id,
details.fund_code_id,
details.prgm_code_id,
details.class_id,
details.activity_id,
details.product_id,
details.status_id,
details.transaction_amount,
details.jrnl_date,
details.adjust_prcnt,
details.adjust_amnt,
details.details_equip_approval,
details.detail_desc,
details.account_id,
details.project_id,
details.dept_id,
details.contract_id,
details.reason_code_id,
details.jrnl_id,
employee.f_name,
employee.l_name,
employee.employee_id,
project.project_id,
project.project_status,
--header.transfer_status,
contracts.contract_desc
FROM header, details, status, employee, department, project, contracts
WHERE (header.cost_tran_id = details.cost_tran_id)
AND (header.cost_tran_date = details.cost_tran_date)
AND (header.transfer_status = status.status_id)
AND (department.dept_id = details.dept_id)
AND (department.dept_id = employee.dept_id)
AND (project.project_id = details.project_id)
AND (contracts.contract_id = details.contract_id)
AND (details.Contract_ID = p_In_Contract_ID OR p_In_Contract_ID ='*' )
AND (header.TRANSFER_STATUS = p_In_Status_ID OR p_In_Status_ID ='*' )
AND (TO_CHAR(details.COST_TRAN_DATE, 'MM/DD/YYYY') = p_In_COST_TRAN_DATE OR p_In_COST_TRAN_DATE ='*' )
AND (details.DEPT_ID = p_In_DEPT_ID OR p_In_DEPT_ID ='*' )
AND (details.PROJECT_ID = p_In_PROJECT_ID OR p_In_PROJECT_ID ='*' )
AND (header.ADDED_BY = p_In_EMPLOYEE_ID OR '*'=p_In_EMPLOYEE_ID )
Can any another way to make procedure
Thanx
Regards ,
AmolHi Amol,
Are you able to execute your stored procedure from oracle?.
- If "Yes" then use the Crystal Report XIR2 Designer to create the report.
- Import this report in the Crystal Report For Eclipse Workbench.
- The latest version for Crystal Report For Eclipse is SP1.
Please let me know the results.
Thanks,
Neeraj -
How to pass parameter from 1 stored procedure to another stored procedure inside crystal report
Hi
I have several stored procedure in my Crystal Report. I am wondering if it is possible for me to pass a parameter to one of the stored procedure and to use the result of that stored procedure E.g. CustomerCode. To another 2 stored procedure to generate the report dynamically?
I have 3 stored procedure
The 1st one is used to gather information and process the calculation
another 2 stored procedure is used for generate the graph and both of them required to take 2 parameters. The 1st stored procedure will require 1 parameter (E.G. Reference Code) and will return a set of information including the data that could be use on the other 2 stored procedures.
After I added these 2 stored procedure, it requires me to pass 3 parameters to the report. I would like to know if I could only pass the Reference Code for stored procedure 1 and use it to retrieve the information for the other 2 parameter?
Thanks in advance
ChiHi Chi
To pass parameter from 1 stored procedure to another stored procedure, you will have to create sub report. In your case you will have to create 2 sub reports for 2nd and 3rd stored procedure and link those sub reports with the main report using Reference Code field in order to pass the values.
After creating the report when you will refresh the report, it will ask 4 parameters, one parameter for main report, one for the first subreport and two for second subreport to fetch the data correctly.
Regards
Poonam Thorat. -
How run stored procedure in Crystal report?
I have table from query in report, but first I need to run stored procedure in report.
How I need to do it?previous post not correct
this is correct
When I need to run my report
1) I need to run storeed procedure ( the stored procedure will update some tables)
I just used Add Command and added stored procedure in Database Fields, but I think the procedure doesn't work in report. Maybe I need add new commant and write there:
exec ProcedureName par1 par2
or
exec ProcedureName (par1={?parameter1} par2={?parameter2})
It's doesn't work. What I need to do?
2) I use some query in report
ex.
select t1.col1, t2.col2, t6.col3 t1.col7 t4.col1
from t1, t2, t6, t4, r4, ju, hh
where hh.col11={?parameter1}
and ju.col3=6
and r4.col3={?parameter2}
group by .....
order by ......
How I need to create me report? What I need to do first?
If parameter in stored procedure par1={?parameter1} in query
and par2={?parameter2} -
Calling a stored procedure from Reports
I am trying to call a stored procedure using oracle reports in the afterparameter code. My code is:
v_ain := sp_get_ain(:P_session_id);
Can someone help me out by telling what is wrong. I keep getting an error stating that sp_get_ain needs to be declared.?!I am creating a function and a stored procedure and calling them
in afterparameter report trigger.
-------------------Create function ----------------
create or replace function get_name( emp_id number) return varchar2 is
v_name varchar2(20);
begin
select name into v_name
from sample_table
where employ_id = emp_id ;
return(v_name); ---------This is the way to return value from function.
exception
when no_data_found then
return('Name not found.');
when others then
return('Other error found.');
end ;
==================================================================================
------------------------Create procedure ------------------------------------
create or replace procedure get_name( emp_id number, return_name out varchar2) is
v_name varchar2(20);
begin
select name into v_name
from sample_table
where employ_id = emp_id ;
return_name := v_name ; --Assign out parameter value from procedure.
exception
when no_data_found then
return_name := 'Name not found.';
when others then
return_name := 'Other error found.';
end ;
============================================================================
-----------------Call function and procedure from report ---------------------
In formula column or any report trigger you can use this code.
v_function_return_name varchar2(20);
v_procedure_return_name varchar2(20);
v_employ_id number(10);
begin
v_employ_id := 101 ;
v_function_return_name := get_name(v_employ_id ); --- call function
get_name(v_employ_id , v_procedure_return_name ); -- call procedure
end;
Here v_function_return_name has same value as v_procedure_return_name,
these are the values returned from function and procedure.
--Anita -
Error while accessing oracle packaged procedure in crystal report./ How to
Hi,
When i tried to call a packaged procedure in crystal reports for .net, i am unable to access it.
i am getting error as 'unknown query engine'
In that packaged procedure i have a two IN parameters and one OUT TABLE parameter ( which is declared in package specification )
And when selecting the packaged procedure in crystal report,the wizard shows all the parameters like the IN parameters, and when i just leave it blank. i unable to set into report.
ie., the OUT table type is shown as IN paramters (Actually it is an output and has field fields in it.)
And No fields are coming in the Fields Explorer of crystal reports in .net.
can you provide any help.
thanks and regards
Mohan Raj K.
Actually using vs.net 2005 prof.
Message was edited by:
mohanraj_kActually the OUT Parameter type in the stored
procedure is showing as IN Parameters and asking
for input values in the crystal report creation
wizard(while selecting the
database,connection,storedprocedures/qualifiers).That sounds like a problem on the .net / crystal report creation wizard side of things. Oracle no doubt recognises them as OUT parameters, so it's not Oracle at fault. I would guess the .net stuff is just querying the data dictionary to see what parameters there are rather than differentiating between the INs and OUTs. -
Call a pl/sql stored procedure from a report link
Hello everyone:
I have a report with a link in a column, which takes you to another page and passes values to that page, but also need the link, run a stored procedure before going to the other page.
In the Forum I found cases similar to this, but none of the examples is clear to me how I do this. It seems that the target of the link should be URL, and also I have to call the stored procedure with a javascript function.
My questions are:
- Is this the best method to make what I need?
- How should be the syntax of the link that takes me to another page and run the "stored procedure"
- How and where I put the function "javascript" to run the "stored procedure"
BDD: Oracle 11 g
Apex version 4.1
Best regards
GerardHi,
Change the link to call an apex.submit process. (javascript).
Edit:
I've set up a basic example.
Region 1 (just so you can see the value getting set):
select :P27_HIDDEN item_Value
from dual
Region 2:
select rownum id, dbms_random.string('U', 12) sss
from dual
connect by level <= 20
item attributes for ID:
Target: URL
URL: javascript:apex.submit({request:'NAVIGATE', set:{'P27_HIDDEN':#ID#}});
(P27_HIDDEN is just a hidden item i created)
http://apex.oracle.com/pls/apex/f?p=54920:27
Edit2:
In your case, then you can just have a page process based on conditions request = expression1, expression1: NAVIGATE..... then a page branch to go to the desired page, also with the same conditions
Edit3:
Im not sure what examples you are referring to , as you didn't supply any links; but you mention calling the stored procedure from javascript, so would likely involve some AJAX, but imo not necessary.
Maybe you are looking for
-
SSRS Cascading parameters : results error
Good day all, Any thoughts would be appreciated: I have set up two embedded datasets: -one called 'GetTaskID', which generates a list of all Distinct 'TaskID' s with 'CreationDate' between two date parameters (@Start and @End) provided by the user.
-
I'm trying to import IDOC from SAP, but i'm getting "login failed (authorization insufficient)" error. But i'm able to login into SAP GUI using the same login info. What authorizations/roles i should have on SAP and XI system for IDOC transfers? Than
-
Upgrading my MPB.. Please help me decide with the graphics card
Hi Guys I have got a late 2007 model MBP Santa Rosa 2.2 Ghz 2 Gb RAM and 128 Mb NVIDIA GeForce 8600M GT video card I am planning to upgrade my MBP. I just want to know that how is the performance of NVIDIA GeForce 9400M integrated graphics processor
-
Why can't I use a PIN for encryption?
I had to do a factory restore in order to accept the 4.4.4 update. Since then, I have tried to encrypt my device. Previously, my device was encrypted with a PIN instead of a password. The instructions clearly state you can use a PIN or a password, bu
-
i am not able to activate the GPS in my e63 . Kindly help. MODERATOR'S NOTE: Edited: Personal E-mail address removed. Please be informed that personal/contact information are not allowed to be posted in this forum for your privacy and security purpos