I want to run simple procedure in TOAD
Hi guys ,I have already compiled the procedure .When i run it it gives me another window.please help me out .I will give you the procedure and what i get after i execute
This is the procedure
CREATE OR REPLACE PROCEDURE find_sname
(i_student_id IN NUMBER,
o_first_name OUT VARCHAR2,
o_last_name OUT VARCHAR2)
AS
BEGIN
SELECT first_name,last_name
INTO o_first_name,o_last_name
FROM student
WHERE student_id = i_student_id ;
EXCEPTION
WHEN OTHERS
THEN
DBMS_OUTPUT.PUT_LINE('Error in finding student_id:'||i_student_id);
END find_sname;
and this is what i get when i execute it
399 is th evalue of student_id
DECLARE
I_STUDENT_ID NUMBER;
O_FIRST_NAME VARCHAR2(200);
O_LAST_NAME VARCHAR2(200);
BEGIN
I_STUDENT_ID := 399;
O_FIRST_NAME := NULL;
O_LAST_NAME := NULL;
STUDENT.FIND_SNAME ( I_STUDENT_ID, O_FIRST_NAME, O_LAST_NAME );
COMMIT;
END;
please show me how i can just run that simple procedure
As your other two parameters are out parameters, at SQL* Plus prompt, declare variables. Something like this.
SQL>create or replace procedure sample_proc(v_in number,
2 v_out1 out number,
3 v_out2 out number)
4 as
5 begin
6 v_out1 := v_in * 10;
7 v_out2 := v_in + 10;
8 end;
9 /
Procedure created.
SQL>var a number
SQL>var b number
SQL>exec sample_proc(10, :a, :b)
PL/SQL procedure successfully completed.
SQL>print a
A
100
SQL>print b
B
20
SQL>Cheers
Sarma.
Similar Messages
-
Trying to run simple procedure in SQL Workshop
Hello,
I'd like to test how procedures work and APEX so I setup a simple one that I'd like to run in SQL Workshop (below). I try the follow to execute the procedure:
begin
MY_TEST_PROC;
end;
But it results in the following error:
ORA-06550: line 2, column 1:
PLS-00306: wrong number or types of arguments in call to 'MY_TEST_PROC'
ORA-06550: line 2, column 1:
PL/SQL: Statement ignored
I've spelled the procedure name correctly, and there are no input parameters required. Why is it erring?
Steve
Procedure:
create or replace procedure "MY_TEST_PROC"
*(p_contract_number OUT VARCHAR2)*
is
begin
select
contract_number
into
p_contract_number
from contracts
where id='5';
end;dbms_output will display a variable's contents. I don't recall if you need set serveroutput on for APEX SQL Workshop or not (I don't have it up right now)
set serveroutput on size 1000000
declare
result varchar2(4000);
begin
MY_TEST_PROC(result);
dbms_output.put_line('My proc result = '||result);
end;The documentation for all the variations of development (11gR2) is here: http://www.oracle.com/pls/db112/portal.portal_db?selected=5&frame= It can be overwhelming starting out. Since you are jumping into stored procedures with APEX, I suggest starting with the 2-day developers guide, then the PL/SQL Language Reference. -
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 -
Help on ORA-06550 & PLS-00363 Error while running a procedure from a packag
Greeting All,
I ran the following procedure from a package on a command line in sqlplus:
SQL> exec QUALITY_ASSURANCE.COPY_SW_RESOURCES(2009,2010,9508);Where '2009' is the old fiscal year, '2010' is the new fiscal year and '9508' is the error code passed from the calling program. But, I received the following error messages:
ERROR at line 1:
ORA-06550: line 1, column 53:
PLS-00363: expression '9508' cannot be used as an assignment target
ORA-06550: line 1, column 7:
PL/SQL: Statement ignored
Any thoughts, suggestions and/or advice to resolve these errors.
Thanks in advance.Orchid wrote:
Justin,
Thanks for your response and information. Yes, Theoa was correct the 3rd parameter is an OUT variable, and it is a numeric field. The procedure was called by a form as follows:
QUALITY_ASSURANCE.COPY_SW_RESOURCES(:BLK_CONTROL.FROMFY,:BLK_CONTROL.TOFY,V_ERR);But the form does not work so I am trying to isolate the problem by running the procedure by itself in sqlplus to make sure there is no problem with the procedure.
Yesterday, I was able to run the procedure in Toad for Oracle to a successful completion by providing the 3 parameters: (2009, 2010, null). Just wonder why I cannot run the same procedure with the same parameters on a command line in sqlplus as follows:
exec QUALITY_ASSURANCE.COPY_SW_RESOURCES(2009,2010,null);So, if I understand your suggestion correctly, in order to run the procedure with the 3 parameter successfully in sqlplus,
I have to declare the 3rd parameter in PL/SQL. That is to create a PL/SQL file as suggested and run the file, correct? CORRECT! -
Run a procedure based on a schedule
hi dear;
how can i schedule to run a process in specific time or every one interval of time?
regards;Dear John;
i mean a procedure in SDK and not in sql.
exp: the procedure is copying the open sales orders to invoices.
i want to run this procedure every 5 minutes automatically
how can i do it in SDK?
thank you and regards; -
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 -
I have few PDf files on my computer and I want to add them to my ipod touch, please tell me the procedure on how should I do that? Secondly I want to run these Pdf files through the ibook app, as it also have the Pdf file sections
You should be able to just place them in your Books library in iTunes and check to ensure that your Book library is configured to sync to your iPod when you sync your iPod to iTunes.
-
PLSQL WANTS TO RUN WINDOWS PROGRAM FROM PLSQL PROCEDURE
WANTS TO RUN WINDOWS PROGRAM FROM PLSQL PROCEDURE.
I want to run EXE file from pl/sql program , i have tried host it does
work in pl/sql .
Is there any Solution to this problem
Thank youHi,
It sounds like what you are trying to do, is run one mapping in a pre-mapping process of another mapping. You use a wrapper that implements sqlplus_exec_template.sql in PL/SQL. Is that correct?
I don't think that by the way you execute this mapping, it ends up in the context of the process flow. The reason is because according to Warehouse Builder the mapping is being invoked standalone (through the wrapper that implements the template). As a result, the context in which Warehouse Builder would log the messages is lost.
What I suggest you do (assuming I understand the problem correctly), is run the mapping as a separate mapping in the process flow. Because in the current release we do not support passing output parameters in the process flow, you will have to (temporarily) store the results of the first mapping in a table and pick it up from there in the other mapping. In the next major release (autumn 2004) we will support passing parameters between activities.
Thanks,
Mark. -
How to view the returned data from a stored procedure in TOAD?
Hi,
I created ref cursor in the stored procedure to return data. The stored procedure works fine, just want to view the result in TOAD. The BEGIN... EXEC... END can execute the stored procedure, but how to make the result display?
Thanks!Right click the editor and choose
"Prompt For Substitution Variables".
Run for example the following code:
DECLARE
PROCEDURE p (cur OUT sys_refcursor)
AS
BEGIN
OPEN cur FOR
SELECT *
FROM DUAL;
END p;
BEGIN
p (:cur);
END;
The result will display in Toad's Data Grid!
Regards Michael -
Running SQL Procedure with dg4msql errors: Function sequence error HY010
I am trying to execute a stored procedure on a SQL database and get the error Function sequence error HY010.
A simple query on a table returns teh expected result.
I have a single Win2008R2 server with MSSQL Express 2008 and Oracle 11gR2 (32bit not 64bit version of Oracle)
Below is the gateway init, listener and tnsnames files and the query I am trying to run:
-- initORIONWASP.ora --
HS_FDS_CONNECT_INFO=INGRDB//waspForGIS
HS_FDS_TRACE_LEVEL=OFF
HS_FDS_RECOVERY_ACCOUNT=RECOVER
HS_FDS_RECOVERY_PWD=RECOVER
HS_CALL_NAME=dbo.spTest;dbo.spQueryAsset;dbo.spQueryAssetDetails
HS_FDS_PROC_IS_FUNC=TRUE
HS_FDS_RESULTSET_SUPPORT=TRUE
-- Listener.ora -- (partial)
(SID_DESC =
(SID_NAME = ORIONWASP)
(ORACLE_HOME = C:\Oracle\product\11.2.0\dbhome_1)
(PROGRAM=dg4msql)
-- tnsnames.ora -- (partial)
ORIONWASP =
(DESCRIPTION=
(ADDRESS=(PROTOCOL=tcp)(HOST=INGRDB)(PORT=1521))
(CONNECT_DATA=(SID=ORIONWASP))
(HS=OK)
-- Simple Query --
Running select "Asset_ID" from asset@ORIONWASP; returns the correct result
Running select * from sys.procedures@ORIONWASP; returns a list of procedures including the procedure I want to run
-- This pl/sql block returns the error ******* identifier 'spTest@ORIONWASP' must be declared *******
declare
begin
"spTest"@ORIONWASP;
end;
-- This passthrough pl/sql block returns ******** [Oracle][ODBC SQL Server Driver]Function sequence error {HY010} ********
DECLARE
CRS BINARY_INTEGER;
RET BINARY_INTEGER;
v_COL1 VARCHAR2(50);
v_COL2 VARCHAR2(50);
BEGIN
CRS := DBMS_HS_PASSTHROUGH.OPEN_CURSOR@ORIONWASP;
DBMS_HS_PASSTHROUGH.PARSE@ORIONWASP(CRS, 'exec spTest');
BEGIN
RET := 0;
WHILE (TRUE)
LOOP
ret := DBMS_HS_PASSTHROUGH.FETCH_ROW@ORIONWASP(CRS, FALSE);
DBMS_HS_PASSTHROUGH.GET_VALUE@ORIONWASP(CRS, 1, v_COL1);
DBMS_HS_PASSTHROUGH.GET_VALUE@ORIONWASP(CRS, 2, v_COL2);
DBMS_OUTPUT.PUT_Line('Col1:'||v_COL1||' Col2:'||v_COL2);
END LOOP;
EXCEPTION
WHEN NO_DATA_FOUND THEN
BEGIN
DBMS_OUTPUT.PUT_LINE('End of Fetch');
DBMS_HS_PASSTHROUGH.CLOSE_CURSOR@ORIONWASP(CRS);
END;
END;
END;
/The gateway configuration file contains:
HS_FDS_PROC_IS_FUNC=TRUE
HS_FDS_RESULTSET_SUPPORT=TRUE
This setting commonly causes problems and you need to set
HS_FDS_PROC_IS_FUNC=TRUE
HS_FDS_RESULTSET_SUPPORT=FALSE
for normal procedure calls and
HS_FDS_PROC_IS_FUNC=FALSE
HS_FDS_RESULTSET_SUPPORT=TRUE
when calling the procedure with ref cursors.
There's a note in My Oracle Support that gives you examples how to call remote SQl Server procedures
Note.197192.1 Different Methods How To Call MS SQL Server Procedures Using TG4MSQL - DG4MSQL
and another one for the Sybase gateway but this code is similar for the SQL Server:
Article-ID: Note 351400.1
Title: How to Call a Remote Sybase Procedure Using TG4SYBS -
How to execute another schema procedure from toad?
Hi,
i want to execute procedure from another schema from toad. already i have created synonym for that procedure and provided execute permission.
how to execute procedure from toad?
Thanks,Hi,
The vendor of that product is running their own forums
http://toadfororacle.com/index.jspa
Not sure how they feel about
Handle: user2017273
Status Level: Newbie
Registered: Oct 4, 2009
Total Posts: 64
Total Questions: 44 *(36 unresolved)* -
How to execute procedure in toad software
hiii guy's i run my procedure on sql prompt and it run properly
but when i tried this on toad i got an problem
after compiling my procedure on toad
when i write
execute procedure_name(parameter1,parameter2);
then i get an error i.e
ORA-00900: invalid SQL statement
can someone tell me how to execute procedure on toad
thanks in adv...........how to execute procedure in toad softwareIn TOAD's schema browser you can go to the procedures tab - right click on the procedure in question and choose execute procedure - a window should pop up, where you can give optional parameters - the rest should be almost self explanatory ;)
-
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 -
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.
Maybe you are looking for
-
Spry Menu Bar Submenus Not Showing
Hi! This is the first time I have ever used Spry .My Horizontal Spry Menu Bar Submenus are not working in ANY browsers whatsoever and I'm not sure whats wrong. My website is www.poor2chic.com. I have pasted a copy of my SpryMenuBarHorizontal.css as w
-
Hi is possible to split up a video file into different parts using the netstream classes? I see youtube do this with large video files, for example, for video named goodvideo, it would stream goodvideo part1,goodvideo part2, goodvideo part3,etc but I
-
hi, I'm working with Antenna House Formatter. When I publish my XML files to PDF and open it with Adobe Reader, the internal links (Xrefs) do not work. When I use another PDF Reader, it works. Can you help me, please?
-
HI, What will be the sales flow in other countries in comparision to india( Say india scenario: s0-deli-biling-excise invoice-Register updation.) 1. sales flow 2 taxation/registers etc what will be the major difference.
-
My Macbook has a dialog box on the screen that indicates everything I do. Right now it says "Standard toolbar". When I try to get rid of it nothing happens. I've never seen this before and don't know ho to get rid of it.