How to create a stored procedure and use it in Crystal reports
Hi All,
Can anyone explain me how to create a stored procedure and use that stored procedure in Crystal reports. As I have few doubts in this process, It would be great if you can explain me with a small stored proc example.
Thanks in advance.
If you are using MSSQL SERVER then try creating a stored procedure like this
create proc Name
select * from Table
by executing this in sql query analyzer will create a stored procedure that returns all the data from Table
here is the syntax to create SP
Syntax
CREATE PROC [ EDURE ] procedure_name [ ; number ]
[ { @parameter data_type }
[ VARYING ] [ = default ] [ OUTPUT ]
] [ ,...n ]
[ WITH
{ RECOMPILE | ENCRYPTION | RECOMPILE , ENCRYPTION } ]
[ FOR REPLICATION ]
AS sql_statement [ ...n ]
Now Create new report and create new connection to your database and select stored procedure and add it to the report that shows all the columns and you can place the required fields in the report and refresh the report.
Regards,
Raghavendra
Edited by: Raghavendra Gadhamsetty on Jun 11, 2009 1:45 AM
Similar Messages
-
How to create stored procedures and use those in Crystal reports
Hi All,
Can anyone explain me how to create a stored procedure and use that stored procedure in Crystal reports. As I have few doubts in this process, It would be great if you can explain me with a small stored proc example.
Thanks in advance.Hello,
There is a document explainining how to use Oracle stored proc with Crystal reports.
Check at:
https://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/1084c536-711e-2b10-e48a-924a60745253
It is for older version but it should work and you can refer to it to get general idea how to start with it. It has a sample oracle stored proc and how to connect it from Crystal Reports. -
Get Error on using Stored Procedure to use it in Crystal Reports XI
Post Author: Krüger
CA Forum: Integrated Solutions
Hello, I need your help please. I use Oracle 10 and now write a correct compiled stored procedure: this procedure is really simple how you can see:set pagesize 50000set linesize 1000set wrap offset head offset feedback offset trimspool onset serveroutput onset verify offcreate or replace procedure GetFirmenNachMontag is lutype varchar2(10);BEGINDECLAREbegin lutype:='Test'; dbms_output.put_line(lutype);END;END; In using in sql directly it is really all fine. But when I want to integrat it in a simple report in Crystal I get the error unknow databank connector error. I hope that somebody can help me please. With best regardsM.KrügerIf you are using MSSQL SERVER then try creating a stored procedure like this
create proc Name
select * from Table
by executing this in sql query analyzer will create a stored procedure that returns all the data from Table
here is the syntax to create SP
Syntax
CREATE PROC [ EDURE ] procedure_name [ ; number ]
[ { @parameter data_type }
[ VARYING ] [ = default ] [ OUTPUT ]
] [ ,...n ]
[ WITH
{ RECOMPILE | ENCRYPTION | RECOMPILE , ENCRYPTION } ]
[ FOR REPLICATION ]
AS sql_statement [ ...n ]
Now Create new report and create new connection to your database and select stored procedure and add it to the report that shows all the columns and you can place the required fields in the report and refresh the report.
Regards,
Raghavendra
Edited by: Raghavendra Gadhamsetty on Jun 11, 2009 1:45 AM -
Calling a stored procedures and using its output parameters in a report
Hi,,
I have a procedure defined in a package on the database. This procedure returns a number of output parameters. How do I call this procedure and use the output parameters in my report ?
Thanks, MarkDepends on the level at which the procedure has to be called. If its at report-level, call the Form in the BEFORE-REPORT-trigger (or AFTER-PARAMFORM) and store the out-values in Placeholder-columns. These you can use anywhere in your report.
-
How to create java stored procedure from oracle(Dastageer)
how to create java stored procedure from oracle-please help me to create the procedure.
Hi,
This forum is exclusively for discussions related to Sun Java Studio Creator. Please post your question in the appropriate forum.
Thanks,
RK. -
Stored Procedure for displaying data in Crystal Reports
Hi I am new to Oracle & Crystal Reports,so can any one please give me sample stored procedure to display data in Crystal report from Oracle by passing rwo input values.
from site:-
Crystal Reports will only support the return of a single refcursor from Oracle. Even the latest and greatest version 10 doesn't allow you to return more than one recordset at a time. You could add one more step to your procedure that would join up the output of the multiple refcursors into a PL/SQL table and then fetch the result set out through a single refcursor. That way you are using temporary space that will be cleaned up as soon as the connection is terminated and will only be returning a single refcursor -
How to embed the Word Document and PDF file into Crystal report?
How to embed the Word Document and PDF file into Crystal report?
I have word doc which having 10 pages. I need to show all of the 10 pages at a time. I tried OLE object but problem is it shows only one page.
Is there any solution to show word doc / PDF file in CR?Symptom :
When embedding a pdf document into a Crystal Report, only the one page shows.
Reproducing the Issue
Environment:
Crystal Reports OLE object
Cause
An OLE object only displays the first page.
Resolution
Embed multiple objects, one for each page
Or
Use a hyperlink to the object instead
Hope this helps!
Regards,
Vinay -
How to Create a Stored Procedure
Hi,
how can we create a new stored procedure using a text editor and the saving it as a file. Please assume that i am just a beginner with oracle.You can create the stored procedure in a text editor, then run the saved file via SQL*Plus. If you have saved the file you can use the @ symbol to have Oracle run the script.
c:\> sqlplus <<user name>>/<<password>>@<<TNS alias>>
SQL> @<<path to file>>will start SQL*Plus and run the script you just created.
Justin
Distributed Database Consulting, Inc.
http://www.ddbcinc.com/askDDBC -
How to create a stored procedure that accepts an array of args from Java?
I am to be creating a stored procedure that accepts an array of arguments from Java. How to create this? thanks
SamNot a PL/SQL question really, but a Java one. The client call is done via ThinJDBC/OCI to PL/SQL, This call must be valid and match the parameters and data types of the PL/SQL procedure.
E.g. Let's say I define the following array (collection) structure in Oracle:
SQL> create or replace type TStrings as table of varchar2(4000);
Then I use this as dynamic array input for a PL/SQL proc:
create or replace procedure foo( string_array IN TStrings )...
The client making the call to PL/SQL needs to ensure that it passes a proper TStrings array structure.. The Oracle Call Interface (OCI) supports this on the client side - allowing the client to construct an OCI variable that can be passed as a TStrings data type to SQL. Unsure just what JDBC supports in this regard.
An alternative method, and a bit of a dirty hack, is to construct the array dynamically - but as this does not use bind variables, it is not a great idea.
E.g. the client does the call as follows: begin
foo( TStrings( 'Tom', 'Dick', 'Harry' ) );
end;Where the TStrings constructor is created by the client by stringing together variables to create a dynamic SQL statement. A bind var call would look like this instead (and scale much better on the Oracle server side):begin
foo( :MYSTRINGS );
end;I'm pretty sure these concepts are covered in the Oracle Java Developer manuals... -
Hi guys, I'm trying to create a Stored procedure that will automatically add all 3 After triggers when executed on any given database, can someone please explain and give an example on how do I go about doing this ? I'd also like it to raise any errors
that may come across, thanks in advance.Lets start with the question why do you need the triggers at all. Since SQL Server 2005 we can use an OUTPUT clause.
This code can be re-written in SQL Server 2005 using the OUTPUT clause like below:
create table itest ( i int identity not null primary key, j int not null unique )
create table #new ( i int not null, j int not null)
insert into itest (j)
output inserted.i, inserted.j into #new
select o.object_id from sys.objects as o
select * from #new
drop table #new, itest;
go
Now from this example, you can see the integration of OUTPUT clause with existing DML syntax.
Another common scenario is auditing of data in a table using triggers. In this case, the trigger uses information from the inserted and updated tables to add rows into the audit tables. The example below shows code that uses OUTPUT clause in UPDATE and DELETE
statements to insert rows into an audit table.
create table t ( i int not null );
create table t_audit ( old_i int not null, new_i int null );
insert into t (i) values( 1 );
insert into t (i) values( 2 );
update t
set i = i + 1
output deleted.i, inserted.i into t_audit
where i = 1;
delete from t
output deleted.i, NULL into t_audit
where i = 2;
select * from t;
select * from t_audit;
drop table t, t_audit;
go
Best Regards,Uri Dimant SQL Server MVP,
http://sqlblog.com/blogs/uri_dimant/
MS SQL optimization: MS SQL Development and Optimization
MS SQL Consulting:
Large scale of database and data cleansing
Remote DBA Services:
Improves MS SQL Database Performance
SQL Server Integration Services:
Business Intelligence -
How to call a stored procedure that use a type defined in a package?
Hi all,
this is stored procedure:
GET_GIORNATAEVENTO( in_nome_servizio IN VARCHAR2,
out_dati_aggiornati OUT TAB_VARCHAR2);
TAB VARCHAR2 is defined in the package specification:
TYPE tab_varchar2 IS TABLE OF VARCHAR2(5) INDEX BY BINARY_INTEGER;
and this is the name of the package: PKG_SERVIZI_MMSPUSH.
This is my php script:
<?php
// Connect to database...
$c=OCILogon("venus_vfl", "venus_vfl", "venvi");
if ( ! $c ) {
echo "Connessione non riuscita: " . var_dump( OCIError() );
die();
echo "<br>PKG_SERVIZI_MMSPUSH.GET_GIORNATAEVENTO</br> ";
echo "<br> </br>";
// Call database procedure...
$in_servizio = "MOTO";
$s = OCIParse($c, "begin PKG_SERVIZI_MMSPUSH.GET_GIORNATAEVENTO(:bind1, :bind2); end;");
OCIBindByName($s, ":bind1", $in_servizio);
OCIBindByName($s, ":bind2", $out_esito);
OCIExecute($s,OCI_DEFAULT);
echo "OUT_DATI_AGGIORNATI= " . $out_esito;
// Logoff from Oracle
OCILogoff($c);
?>
How to test stored procedure to get the output parameter?
Thanks in advance.Thanks,
but I need to test stored procedures that uses type defined in the package.
e.g.
if I have s.p.
PROCEDURE get_risultati_squadra
( in_squadra IN VARCHAR2,
out_serie OUT tab_varchar2_5,
out_tiporisultato OUT tab_varchar2_5,
out_n_giornata OUT tab_varchar2_5,
out_squadre OUT tab_varchar2_200,
out_risultato OUT tab_varchar2_10,
out_marcatore OUT tab_varchar2_50,
out_punti OUT tab_varchar2_3,
out_rimbalzista OUT tab_varchar2_50,
out_rimbalzi OUT tab_varchar2_3,
out_esito OUT tab_varchar2_2);
I have to define every type external to the package, in this case five new TYPE !!
Is there another way to solve this problem?
Thanks -
How to create a stored procedure in a dynamic schema
Hi,
I want to create a stored procedure in a dynamic shcema (schema name will be known at run time). Can any one guide me on this.
I tried using define var1=schema1; and then in create or replace procedure &var1.porcName( ) but it is not working
ThanksSQL> alter session set current_schema=<my schema>;
Now create the stored procedure. It will be created in the session's current schema. -
Fields in Stored Procedure does not appear in Crystal reports 2008.
hi,
I am now using crystal reports 2008 evaluation copy for 30 days. I am trying to create a stored procedure with parameter, here is my sample Stored Procedure code;
DELIMITER $$
DROP PROCEDURE IF EXISTS `puerto`.`SP_FindEmployees`$$
CREATE DEFINER=`root`@`localhost` PROCEDURE `SP_FindEmployees`(SIDNo VARCHAR(10))
BEGIN
SELECT * FROM employees WHERE IDNo=SIDNo;
END$$
DELIMITER ;
when i try to call the procedure in sqlyog here is my sample code;
CALL sp_findemployees('0000000001')
it is successfull, but when i try to connect it with crystal reports 2008 I got no fields in my stored procedure andi got this error message ;
"Database Connector: 'HY00:[MySQL][ODBC 3.51 Driver][mysqld-5.1.33-community]incorect number of arguments for procedure puerto.sp_findemployees; expected 1, got 0 [Database vendor code: 1318]"
CR2008 was not asking a parameter values.
But when I try using stored procedure that i've made in MSSQL, CR2008 asking parameters and succefully created the reports needed.
My Objective is to make a stored procedure in MySQL by using select statement and filter it with parameter(s) that I will pass and CR2008 will use this stored procedure.
i also try the view with this code below and it was successfull in CR2008.
DELIMITER $$
DROP VIEW IF EXISTS `puerto`.`ep_employees`$$
CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `ep_employees` AS (SELECT `employees`.`IDNo` AS `IDNo`,`employees`.`FullName` AS `FullName` FROM `employees`)$$
DELIMITER ;hi,
Crystal Reports 2008 and MySQL 5 , ODBC driver 3.5 and ODBC driver 5.1.
I use ODBC connector 3.5 because I got errors in ODBC drivers in 5.1.
Do you have step by step procedure for creating add command dialog box?
I try creating the add command dialog box
here's my sample sql statement i don't know if its correct because no data appearing in my crystal report
Select * from employees where idno=@IDNo
in Command Parameter Dialog Box
Parameter Name = @IDNo
Prompting Text = @IDNo
Value Type = String
DefaultValue = 0
thanks! -
How to use a stored procedure as a datasource in Crystal Report for Eclipse
Hi All,
I've written a stored procedure in oracle 10g with few input parameters and one refcursor output parameter. I want to use this stored procedure as a data source for creating a report in "Crystal Report For Eclipse 3.6.0".
When I tried to add this stored procedure to the report using the connection explorer, I don't see any option to do this. But when I try to add any table, it shows options like "Add to the current report"....
Can anybody assist me how to use a stored procedure as a data source in "Crystal Report For Eclipse"?
Which driver should I use to connect to the oracle database? I tried using JDBC Driver for Oracle.
Thanks in advance.Did you solve your problem? How did you do?
-
How to create minimal stored procedure?
What is the preferred way of creating stored procedures? Can I use SQL Developer or SQLPlus?
I'm running version 11.2.0.1.0.
Here is my attempt in SQLDeveloper:
CREATE OR REPLACE PROCEDURE hello ()
BEGIN
dbms_output.put_line('Hello, World!');
END;
SET SERVEROUTPUT ON;
SELECT hello() from DUAL;
When I hit F5 it says
Warning: execution completed with warning
PROCEDURE hello Compiled.
When I select the last line and hit F9 I get a dialog box that says:
An error was encountered performing the requested operation:
ORA-00904: "HELLO" invalid identifier
00904.0000 - "%s: invalid identifier"
*Cause:
*Action:
Vendor code 904 Error at line:8 column 7
I tried using SQL plus but since I'm having trouble just logging in, I already posted my query in the SQLPlus forum.
Thanks,
siegfrieduser8816970 wrote:
What is the preferred way of creating stored procedures? Can I use SQL Developer or SQLPlus? Yes.
A "minimal" procedure would be:
create or replace procedure TestProc as
begin
null;
end;Also get the whole pascalcase, camelcase and lowercase correct. Do not code in uppercase - it not only looks stupid, it contravenes programming standards that existed since the 70's and are still applicable and used today. From Microsoft's .Net to Java and /C/C++ and Pascal/Delphi and Visual Basic and most other languages. It is just plain silly to code in uppercase. Cobol standards do not apply today and were intended for punch cards - which is why I find this whole code-reserve-words-in-uppercase approach used in PL/SQL, flawed and idiotic.
When I select the last line and hit F9 I get a dialog box that says:
An error was encountered performing the requested operation:That is because PL/SQL procedures need to be executed via an anonymous PL./SQL block. You need use (enter) the following code block on the client side to be send to Oracle for parsing and execution:
begin
Hello;
end;Some clients, like SQL*Plus, supports a client EXEC command. This takes the parameter supplied to the EXEC command and wrap that into an anonymous block like above.
You can only execute PL/SQL functions via the SQL language. Quite important that you do not confuse languages at this level. Some clients (like SQL*Plus) have their own client commands like EXEC and HOST and SPOOL. These client commands are not PL/SQL or SQL.
PL/SQL and SQL are also two different languages. PL/SQL combines Programming Language with SQL in a very integrated and transparent way. However. PL is executed by the PL engine and SQL is executed by the SQL engine.
Lastly, make sure you understand what DBMS_OUTPUT does. It does not write anything to the client's display device. It is server code running in a server process. It cannot hack across the network to do stuff on the client - like reading a file or displaying something.
The put_line() procedure of DBMS_OUTPUT writes text data into a static PL/SQL variable. The more you write into it, the more expensive server memory is consumed by that server process. When the server process has completed the client call (SQL statement or PL/SQL call), the client can then interrogate this buffer variable, read it, display the contents itself, and clear the buffer variable.
It's important to understand what client-server is and how it applies to what you are doing using Oracle as a server.
Maybe you are looking for
-
i am not able to browse through safari with my wifi connection, its asking for usernsme and password please help me whath is the issue
-
How can i get my movies and episodes back on my account?
all my stuff has been lost on itune there is no way to get it back my last computer crashed and i only have this one i need help retriving my old purches.
-
Check if VI is a control (.ctl)
Given an array of VI references, is there a method to determine which VIs are actually controls (.ctl files)? (Other than getting the path and checking that the file extension is .ctl. I was hoping for a more direct way. ) Thanks, Joel Solved! Go
-
How can i configure my listener, i can't connect with my appilcation please help ?? i have oracle 10G , and i don't know nothing about the listner
-
Acrobat 7 Convert Word to PDF Alignment Issue
Recently we have been using Acrobat 7 and occassionally when converted to a PDF, the words move. Below are screen shots of where the text has to be in Word in order for the text to be in the right spot for the PDF. This is the first time it was thi