How to run a procedure
hello folks,
i want to run a procedure stored in oracle...follwing is the sample procedure....
create or replace procedure test_sample
cv_1 in out sys_refcursor
as
begin
open cv_1 for
select * from visit;
end;
when i run the procedure, it only shows that...+anonymous bolck completed+.... but it never shows the output
(assuming that table visit have around 20 columns)
do i need to create another cursor for displaying the result(records)?
plz help....
SQL> select * from v$version;
BANNER
Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - 64bi
PL/SQL Release 10.2.0.4.0 - Production
CORE 10.2.0.4.0 Production
TNS for 64-bit Windows: Version 10.2.0.4.0 - Production
NLSRTL Version 10.2.0.4.0 - Production
SQL> var my_cursor refcursor;
SQL> create or replace procedure test_proc(p_Cursor_Handle in out sys_refcursor)
2 is
3 begin
4 open p_Cursor_handle
5 for
6 select * from dual;
7 end;
8 /
Procedure created.
SQL> exec test_proc(:my_cursor);
PL/SQL procedure successfully completed.
SQL> print :my_cursor;
D
XCheck this link for more information.
http://download.oracle.com/docs/cd/E11882_01/appdev.112/e17126/static.htm#LNPLS572
Regards
Raj
Similar Messages
-
Procedure test_proc(Req_Hdr_id IN VARCHAR2, uname IN VARCHAR2
is
l_request_id NUMBER:=0;
p_resp_appl_id NUMBER :=401;
p_resp_id NUMBER := 20634;
p_user_id NUMBER := 5993;
BEGIN
update xxkfupm01.kfupm_mcr_request_header
set status='Under_Proc'
where request_hdr_id=Req_Hdr_id;
commit;
This is procedure is define in package .how to run this procedure.
Regards
Arif
Edited by: user11309801 on Jan 2, 2011 9:38 PMTry This:-
DECLARE
req_hdr_id VARCHAR2 (200);
uname VARCHAR2 (200);
BEGIN
req_hdr_id := NULL;
uname := NULL;
<<PackageName>>.test_proc (req_hdr_id, uname);
COMMIT;
END;
Also ,add exceptions in the procedure. -
How to run stored procedure in run-time not in design
hello:
I have download the ODT software
and i installed VS 2003 environment
amd i have oracle 9i on the server and oralce client on my computer
and I know how to run the ODT inside the VS2003 and how to use it
I built a package and inside it a procedure that does not take any parameter
PROCEDURE "TEST1" IS
BEGIN
insert into emp (empno,ename)
values (3003,'jon');
END "TEST1";
this procedure is valid and I can run it in ODT (by right click over the procedure name and select "Run")
but when I drag it and drop this procedure on a form in application I have a dialog with errors that's not understandable
for example:
ORA-06550: line 1, column 27
PLS-00315: PL/SQL TABLE Declarations must currently use binary_integer indexes
and many other errors
ok I want to know how I can call the procedure in the code and give to it the in parameters and then get the out parameters
I hope to find replay
thank youHi,
You have to take care of certain measures other thatn just drag and drop the Oracle procedure to the .NET form.
Following is a simple code to call an Oracle procedure from the C#.Net form
============================================================
using System;
using System.Collections;
using System.ComponentModel;
using System.Drawing;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
using System.Data;
using Oracle.DataAccess.Client;
using Oracle.DataAccess.Types;
namespace TEST1
public class CallingProcs : System.Web.UI.Page
protected System.Web.UI.WebControls.Button Button1;
protected System.Web.UI.WebControls.TextBox txtYear;
OracleConnection conn;
private void Page_Load(object sender, System.EventArgs e)
// Put user code to initialize the page here
string oradb = "Data Source=ORA1;User Id=SCOTT;Password=TIGER;";
conn = new OracleConnection(oradb);
conn.Open();
#region Web Form Designer generated code
override protected void OnInit(EventArgs e)
// CODEGEN: This call is required by the ASP.NET Web Form Designer.
InitializeComponent();
base.OnInit(e);
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
this.Button1.Click += new System.EventHandler(this.Button1_Click);
this.Load += new System.EventHandler(this.Page_Load);
#endregion
private void Button1_Click(object sender, System.EventArgs e)
//OracleCommand dbcmd = new OracleCommand();
OracleCommand dbcmd = conn.CreateCommand ();
dbcmd.CommandType = CommandType.StoredProcedure;
dbcmd.CommandText = "TEST1";
try
dbcmd.ExecuteNonQuery ();
Response.Write("Excecuted succesfully");
catch(Exception ex)
Response.Write(ex.Message);
============================================================
Most of the above code is generated automatically. I am using Visual Studio .NET 2003 , C# for it.
The design view of the form contains a button named 'Button1' and the code is aimed to call the procedure 'TEST1' on clicking the button.
Hope this will give you a start to using oracle from .NET -
How to run stored procedure in DOS command line????
Hi,
I want to run a stored procedure in DOS command line?
(My_Stored_Procedure is the stored procedure that I want to run )
This is what I did in DOS prompt
C:\>sqlplus scott/tiger exec lMy_Stored_Procedure <Return>
Obviously it is NOT working. Please send me the correct way to fix this.
Thanks so much in advance for helping.
CuongBilly Verreynne wrote:
BluShadow wrote:
True Billy, but even Windows hasn't completely got away from using the "DOS" word...Yeah - the command line/shell environment is based on that of the old DOS command interpreter. But Microsoft does not make the mistake of call it DOS.
In fact, with earlier versions of Windows NT, a 16bit DOS real-mode virtual machine was supported. This was very kewl.
Running a large BBS with multiple nodes back then required a DOS machine per node, an IPX network, and a Novell file server.Novell Netwars. ;)
Ahhhh! good old DOS... so many good programs written at that low level, outside the Windoze environment.Yeah.. cut my teeth on writing code for DOS. Still have all my old BIOS and assembler manuals for it. Wrote my own screen s/w (write to a buffer and then move it into the video buffer, instead of writing char wise to the video buffer via interrupts), mucking about with my own concurrent threading model (using very simplistic cooperative multitasking) and so on. Heck, wrote tons of s/w on DOS... :-)Yeah I've still got a copy of my old machine code programs for writing to buffers and screen memory switching for smooth animation. Run them nowadays and they run like sh!t off a shovel. And all my old coursework including writing an interpreted language and multi-window (dos based windows) editor, parser and the code to execute the language and display the output. Oooo, and so much other stuff.
Awesome back then as you got really intimate with the o/s and hardware. This is sorely lacking today in environments like Java. And I think the reason why so much code written today is less than optimal - to put it kindly.Exactly. Started for me on the Sinclair zx81 (writing Basic), then the Sinclair Spectrum (Basic and Assembly), then Sinclair QL (yes I really had one!) and then the BBC Master 128K (where I got to writing my own rom filing system and creating my own eproms, to integrate with the word processor for additional printing features etc. as well as storing games on rom for speedy loading - and I still have it and it still works!)
It's that level of working with the underlying memory and assembly language that gives you the understanding of how values are passed between code using the stack and registers, and how memory allocation and referencing is done etc. As you say... it's missed in a lot of todays teaching, which just seems too high level and misses the basic concepts of things such as datatypes and why they are different. I bet half the modern programmers wouldn't have a clue how to do multiplication or division of binary numbers using the carry flag. -
How to run database procedure in oracle form
Hi,
I have created a database procedure, it run successfully at server side, but I need to run it on oracle form, how I'll do ?
Thanks
BalochBaloch,
Essentially, you call your database stored procedure the same way in Forms as you do in SQL Plus. The difference is that you need to call the procedure in a Forms Trigger versus a SQLPLus prompt. The Forms user must have execute privileges to the stored procedure as well. The Forms trigger depends on when and where you need the procedure to run. For example, if you need the procedure run in conjunction with a button pressed in your form, you would code your When-Button-Pressed trigger to call the stored procedure. If the db user is different fro.m the Forms user, make sure you fully qualify the call to the procedure.
Here is a small code sample to demonstrate:
/* Sample When-Button-Pressed trigger */
BEGIN
IF <Condition is true> THEN
/* Call Database procedure */
SCHEMA.PROCEDURE_NAME(<any procedure parameters here>);
END IF;
END;This is a very basic example, but it should make the concept clear. ;)
Hope this helps,
Craig B-)
If someone's response is helpful or correct, please mark it accordingly.
Edited by: CraigB on Jul 22, 2010 10:57 AM
Edited by: CraigB on Jul 22, 2010 11:02 AM
Edited by: CraigB on Jul 22, 2010 11:04 AM
Edited by: CraigB on Jul 22, 2010 11:04 AM -
How to run stored procedure IC Data / to define according script logic file
We want to execute the stored procedure IC Data before the IC Booking. Could anybody tell me, how we have to define the script logic file in detail?
We try it with this code (that runs without any error, but 0 rows are calculated, 0 rows are updated)
*Run_stored_procedure=spicdata('%App%','%C_Category_Set%','%time_set%','','%entity_set%','','','Input','I','%logtable%','%scopetable%')
*commit
We also had tried with this code:
*Run_stored_procedure=spicdata('%App%','%C_Category_Set%','%time_set%','','%entity_set%','','','','','%logtable%','%scopetable%')
*commitstep 1.
Create a store procedure in back end.
step2.
Create a ssis package to execute the store procdure.
step3.
call this ssis pacakge in the data manager package and run the package. -
How to Run Stored Procedures from Teststand
I am trying to get teststand to run an SQL stored procedure but I always get the following error
Error executing substep 'Post'.
The following SQL command failed: 'EXECUTE cdt_st_test...'
Native error code -2147217900 0x80040e14
Microsoft OLE DB Provider for SQL Server:
Syntax error or access violation
It is a test stored procedure that doesn't pass any parameters.
Which steps must I use and how do I pass parameters.I have sussed it now. I was setting the "Command Type" to stored procedure instead of default. I changed it back and did "EXECUTE cdt_st_test" and it works. I have also added the parameters there as well.
-
How to run process_rtg procedure
hi,
i got this procedure "process_rtg" from BOM_RTG_PUB API,
but i'm not able to run it
please help me out!!!There is an example of printing the results of a refcursor in sqlplus
Re: How to test pl/sql procedure by passing parameters -
How to run a procedure before executing the report in BI Publisher
Dear All,
I got a requirement when I should execute a procedure before running the report.
Here is my requirement
I have created a temp table and created a stored procedure (temp_proc) which will insert sysdate value.
create table temp (emp_name varchar(10));
create or replace procedure temp_proc
is
begin
insert into temp values(sysdate);
commit;
end;
I have written a query in the Data Model section with a new Dataset as SQL Query Type. Now I want to run this report so that the procedure should be executed and it should insert a value in the temp table. I cannot create a datatemplate instead of sql query as it will consume more time.
I am using BI Publisher 10.1.3.4.2 Standalone version. Please help me out.Hi,
better to ask a question about BI Publisher in BI Publisher Forum than here in Reports Forum.
You can create a template in your rtf wich you reference in your header. With BI Desktop in Winword you can use a different header for first page than the others.
Regards
Rainer -
/*it shows an warning */
--how to remove this warning
CREATE PROCEDURE EMP_TITLE_GENERATOR (EMP_GENDER IN CHAR (1),EMP_TITLE OUT VARCHAR2)
IS
BEGIN
EMP_TITLE:=DECODE(EMP_GENDER,'M','Mr','F','Ms','INVALID');
EXCEPTION
WHEN OTHERS THEN
DBMS_OUTPUT.PUT_LINE(SQLERRM);
END;
Edited by: 923746 on Apr 18, 2012 7:58 PM
Edited by: 923746 on Apr 18, 2012 7:59 PMConnected to:
Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production
With the Partitioning, OLAP and Data Mining options
SQL> CREATE PROCEDURE EMP_TITLE_GENERATOR (EMP_GENDER IN VARCHAR2,EMP_TITLE OUT VARCHAR2)
2 IS
3 begin
4 select DECODE(EMP_GENDER,'M','Mr','F','Ms','INVALID') into emp_title from dual;
5 EXCEPTION
6 WHEN OTHERS THEN
7 dbms_output.put_line(sqlerrm);
8 END;
9 /
Procedure created.
SQL> set serveroutput on
SQL> DECLARE
2 EMP_GENDER VARCHAR2(200);
3 EMP_TITLE VARCHAR2(200);
4 BEGIN
5 EMP_GENDER := 'F';
6
7 EMP_TITLE_GENERATOR(
8 EMP_GENDER => EMP_GENDER,
9 EMP_TITLE => EMP_TITLE
10 );
11 DBMS_OUTPUT.PUT_LINE('EMP_TITLE = ' || EMP_GENDER);
12 DBMS_OUTPUT.PUT_LINE('EMP_TITLE = ' || EMP_TITLE);
13 END;
14 /
EMP_TITLE = F
EMP_TITLE = Ms
PL/SQL procedure successfully completed.
SQL> -
How to run trigger/procedure into debug mode
Hi,
I have created trigger. i would like to run this into debug mode. Please suggest that how to do through sqldeveloper or sql command prompt.
Regards,
Venkat- install PL/SQL developer (trial available at www.allroundautomations.com)
- connect to your DB
- in the tree on your left right click your trigger and select "Add debug information"
- open a new test window (file - new - test window)
- -- Created on 20-2-2012 by RMARTENS
declare
-- Local variables here
i integer;
begin
-- Test statements here
insert into table (col1, col2) values ('cal1', 'val2');
end;- now click the "Start debugger" button and you'll be able to step into all the steps.
- the idea is that you do a "step into" on your insert statement (which offcourse you need to alter according to your table)
good luck!
Regards,
Richard
blog: http://blog.warp11.nl
twitter: @rhjmartens
If this question is answered, please mark the thread as closed and assign points where earned..
Edited by: rima on 20-feb-2012 11:37 -
How to run package procedure using Crontab
Below is my crontab script to run . It is working fine in if I run it manually like
sh crontest
but if i call it in crontab , only echo is working , oracle commands are not working.
my crontab command is -> * * * * * sh /home/oracle/cron/crontest
crontest
#!/bin/sh
echo "Procedure start successfully : $(date) " >> /home/oracle/pro_test
sqlplus -s orpheus/frs@frs_ods<<END
set serveroutput on
exec pkg_orph_adhoc.pro_ca('3478409644','2011-07-01','2011-10-31');
insert into tt values(sysdate);
commit;
exit;
END
********************************************That's correct because crontab does not process your login scripts and hence does not know the Oracle environment. You need to set it up, see below example. Make sure to use the correct SID, which is case sensitive. Note the space between the dot (.) and oraenv to source execute the script, which should be in /usr/local/bin. At a bare minimum you will need to setup ORACLE_HOME and add ORACLE_HOME/bin to your path, which "oraenv" will take care off and more. Oraenv needs ORACLE_SID when in non-interactive mode.
#!/bin/sh
ORACLE_SID=test
ORAENV_ASK=NO
. oraenv -s
sqlplus -s /nolog <<-EOF
set pages 0 feed off
connect / as sysdba
select status from v\$instance;
exit
EOF
# END -
How to run the procedure in SQL editor
Schema Temp, Package Name = Pk_DRmanagement
PROCEDURE LoadCardRefundRequests(v_streamer_batch_id IN NUMBER,
vDebugLevel IN NUMBER DEFAULT 0, RowsProcessed OUT NUMBER )
I use the following in SQL editor to compile and encounter problem. Can you help me with the correct implementation
begin
declare vCnt number;
execute vCnt := Temp.Pk_DRmanagement.LoadCardRefundRequests(10407, 0);
end;
Thanks
Just Do Itdeclare
vCnt number;
begin
Temp.Pk_DRmanagement.LoadCardRefundRequests(10407, vCnt );
end; -
How to run a stored procedure in TOAD
Hello,
I created a simple stored procedure in the procedure editor in TOAD. It's just a simple 'Hello World' output statement. Here is the code:
create or replace procedure new_proc is
greetings varchar2(20);
begin
greetings := 'Hello World';
dbms_output.put_line(greetings);
end;
The procedure created fine, but when I try to call it in the procedure editor or in the SQL Editor, both tools act as if the procedure cannot be found, and I get an error message.
In SQL Editor, I type in:
exec new_proc;
and it says that "new_proc" is invalid.
Does anyone know how to run this procedure in TOAD?
Thanks,
Peter
Message was edited by:
P. SwansonDon't know about TOAD but this is how it is in SQL*Plus.
SQL> create or replace procedure new_proc is
2 greetings varchar2(20);
3 begin
4 greetings := 'Hello World';
5 dbms_output.put_line(greetings);
6 end;
7 /
Procedure created.
SQL> set serveroutput on
SQL>
SQL> exec new_proc ;
Hello World
PL/SQL procedure successfully completed.
SQL>Message was edited by:
Kamal Kishore -
How to run a stored procedure in TOAD 9.0
Dear Friends,
I am using TOAD 9.0 .
Running a procedure but getting the error ..
create or replace PROCEDURE UPD_TBL(I_table_name IN VARCHAR2) IS
CURSOR c_columns is select column_name from ALL_TAB_COLUMNS where
TABLE_NAME = I_table_name;
BEGIN
FOR rec in c_columns
LOOP
IF ( rec.COLUMN_NAME = 'X_NNM_TYPE_CD' ) THEN
UPDATE I_table_name set X_NNM_TYPE_CD = REPLACE (X_NNM_TYPE_CD, '-', '_')
WHERE INSTR (X_NNM_TYPE_CD, '-') > 0 ;
ELSIF ( rec.COLUMN_NAME = 'X_REVENUE_TYPE_CD' ) THEN
UPDATE I_table_name set X_REVENUE_TYPE_CD = REPLACE (X_REVENUE_TYPE_CD, '-', '_')
WHERE INSTR (X_REVENUE_TYPE_CD, '-') > 0 ;
END IF;
END LOOP;
EXCEPTION
when OTHERS then
NULL;
END UPD_TBL;
ERROR: TABLE OR VIEW DOES NOT EXIST.
Please let me know how to run the procedure in toad.
thanks/kumarKumar,
At a minimum, you would need to remove both the exception handler in your procedure and the exception handler in your anonymous block. As has been mentioned before, the code
EXCEPTION
WHEN OTHERS THEN
NULL;
END;is almost always a bug. In your case, your code is almost certainly generating an exception and your exception handler is silently catching and ignoring that exception. If you care whether or not any rows are updated, that is a bug.
Once you remove the exception handlers, you'll very likely discover that the SQL statements you are generating and executing dynamically are malformed. Off the top of my head, it would appear that there is no space between the table name and the SET keyword in the string you are constructing. That means that if I_TABLE_NAME is 'EMP', for example, you'd construct a statement like
UPDATE empSET x_nnm_typ_cd = ...'Oracle would interpret empSET as the table name, it would interpret X_NNM_TYP_CD as a table alias, and then it would encounter the equals sign unexpectedly and generate a syntax error. You'd need to insert a space after the table name and before the SET keyword (note where folks inserted extra spaces in their sample code).
In general, you are probably better served by having a local variable that you use to build up the SQL statement. That way, you can print (or log) the SQL statement that is constructed. When you encounter a syntax error at runtime, that will generally make debugging easier. So you'd probably want something like
l_sql_stmt VARCHAR2(1000);
BEGIN
FOR rec IN cur_c_columns LOOP
IF (rec.column_name = 'X_NNM_TYPE_CD') THEN
l_sql_stmt :=
'UPDATE '||i_table_name||
' SET x_nnm_type_cd = REPLACE(x_nnm_type_cd, ''-'', ''_'')'||
'WHERE INSTR(x_nnm_type_cd, ''-'') > 0';
dbms_output.put_line( l_sql_stmt );
EXECUTE IMMEDIATE l_sql_stmt;
...When you get a syntax error, you can then take a look at the SQL statement that was generated and debug the problem more easily.
Justin
Maybe you are looking for
-
How do I get iCloud Drive in the Finder window?
I have just installed Yosemite on my early 2009 iMac and want to use iCloud drive. I have been using iCloud up till now and have an iPhone 5 running iOS 8 with iCloud drive enabled and an iPad 3 also running iOS8 with iCloud drive enabled. I have up
-
I lost the music on my pc when I had to reformat the disk. Is there any way to transfer the music from the Ipod to the pc? I am told that if I try to sync the music that it will erase all the music on my Ipod.
-
I took a trip for thanksgiving and stayed at a hotel. Since returning home my computer is acting very strangely. Here is a log of what has happened so far. I am grateful for any help I can get! Friday night @hotel: all looks fine. shutdown as normal,
-
USB drives aren't recognized in Windows after Yosemite update.
On my Windows partition, my flash drives aren't recognized anymore. I've tried installing the Windows Support Software. That doesn't seem to do it.
-
Mac book pro won't detect my external superdrive
I just got a 2012 macbook pro. it has the 10.9.4 update. it doesn't come with a superdrive so i bought an external one. it worked for one day but when i tried to plug it in today nothing happened. The Mac didn't even recognize it. when I opened the D