I wrote a stored procedure in oracle to check weather given input file name exists in defined path. It is working fine. When i call this procedure in power-builder 12.0 i tested like this. First time i entered wrong file name it is works fine. Then i entered correct file name it is saying that Procedure has already been executed. How can i re-execute this procedure again. MY code to declare the procedure in package is
DECLARE PROC_FILE_EXISTS PROCEDURE FOR
HICSWIN_ORACLE.PACK_UPDATE_TSHML_HICSWIN20.PROC_CHECK_FILES_RELEVANCE
(
FILE_NAME => :as_file_name
) ;
EXECUTE PROC_FILE_EXISTS;
IF SQLCA.SqlCode < 0 THEN
MessageBox('eroor',SQLCA.SQLErrText)
MessageBox('Connection failed','An error occured while connecting to database, please contact your administrartor')
RETURN 0
end if
FYI i am using windows 7 with oracle 11g
You need to close the procedure call (in a way similar to a cursor use : Declare / Open / Fetch / Close):
close PROC_FILE_EXISTS;
Call it from a datastore. Create a new dw with a stored procedure source, and the string retrieval argument. PB includes all the appropriate cursor syntax automatically. Calling Oracle SPs may be more complex - I believe you have to return a ref cursor to call one from a dw...
Related
First of all my knowledge of Oracle is very limited.
I have inherited a large Delphi project using Oracle, it have been upgraded to Oracle Cloud. And now I have some problems calling a Stored procedure :
Lets start with the SP's (It is placed in a package )
PROCEDURE GetAccessObjects(AAccessObjects OUT CURSOR_TYPE);
Then the Delphi Code:
procedure TDBApi.GetAccessObjects(var ResultSet: TADOStoredProc);
var
SP: TDbStoredProc;
begin
SP := CreateStoredProc(SQLPackage + 'GetAccessObjects');
try
SP.MaxRecords := mrAll;
SP.Open;
ResultSet := SP;
except
SP.Free;
raise;
end;
end;
When executing the Delphi code I get the error
PLS-00306: wrong number or types of arguments in call to
'GETACCESSOBJECTS'
And calling the SP from SQL Developer (exec DDK.GetAccessObjects()) I get the same error.
I can read and understand the error message: Missing parameter. But what beats me is the fact that this code have been running for years. At least 5.
I have at least 10 SP's with this "problem" so its not a simple typo.
So in short how do I move on from here?
How do I call this SP?
Can I set some kind of global setting so I don't have to pass this parameter?
I am working on a system where Oracle 11g is the back end database.
I have very limited permissions on the database and as such all I can do is call procedures that reside in packages.
Gerally, these procedure return their result set via an OUT parameter of type sys_refcursor.
I can call them fine in C# and get data from the cursor via the C# OracleDataset type.
Here is my question.
I want to be able to run these procedures and see the results via SQL Developer.
I can execute the procedure fine, but seeing the contents of the sys_refcursor OUT parameter is boggling me.
I've done some gooling and people ar saying about creating type and other solutions I simply do not have the permissions to persue.
So, how can I possibly see the result set contained in a sys_refcursor?
So say I have a procedure with this signature....
procedure an_oracle_Proc(p_ref IN varchar2,
p_result_set OUT sys_refcursor);
I call it like this....
DECLARE
l_ref VARCHAR2(10);
l_result_set sys_refcursor;
BEGIN
oracle_pkg.an_oracle_Proc(p_ref => l_ref,
p_result_set => l_result_set);
--How to select from l_result_set with limited permissions
END
How can I look at the contents of l_result_Set?
This is repeating the answer I linked to before really but specifically for your code:
VARIABLE result_set refcursor;
DECLARE
l_ref VARCHAR2(10);
BEGIN
l_ref := 'whatever';
oracle_pkg.an_oracle_Proc(p_ref => l_ref,
p_result_set => :result_set);
END;
/
PRINT result_set
... and run all of that as a script from an SQL Worksheet. The contents of the ref cursor will be shown in the script output window.
Thought I'd have another look and found this - amazing what stepping away from the computer can do. ;)
I just have to select the appropriate variable on the left pane.
http://www.thatjeffsmith.com/archive/2011/12/sql-developer-tip-viewing-refcursor-output/
Still - it would be nice to write my own SQL to do this rather than using the execute window.
Sys_refcursor form an anonymous block is bit tricky. Use the sql-developer, explore the package or procedure , right click and execute the procedure/package.
Sql-developer will open an input/output UI where you can key in values. And you can see the output on the same UI as well. Let me know if you need more details. I was actually debugging the same a couple of weeks back successfully.
I have written following stored procedure to test procedure call from iReport designer.
Stored Procedure:
CREATE OR REPLACE PROCEDURE test(cursor1 out sys_refcursor) IS
BEGIN
OPEN cursor1 for
select person_id,first_name
from person
where rownum < 5;
END;
In my query window I am using following line to call this procedure.
{call test($P{cursor})}
where $P{cursor} is a parameter with class java.sql.ResultSet.
I have added ojdbc.jar file into my class path and connection is also successful.
When I run above statement for calling stored procedure it throws the error:
Error: java.sql.SqlException:Invalid column type
Can someone tell me what I did wrong here? Am i supposed to add any file or make any changes in the call to stored procedure?
The problem was in iReport field extractor. The solution for above problem is, we should analyse our stored procedure and create fields in iReport designer with the same name which are present in select clause of stored procedure.
After creating stored procedure, just drag and drop the fields on the report are and execute it. It will show the retrieved data.
This solution worked for me, so I am sharing it with you.
I'm trying to call an Oracle stored procedure that accepts no input parameters. However, when running the procedure, I get an error back that states
PLS-00306: wrong number or types of arguments in call to 'MY_PROC'
To call the proc, I'm just entering the following text into TOra:
BEGIN
SCHEMA.MY_PROC();
END;
I've also tried (same error though)
EXEC SCHEMA.MY_PROC();
I'm familiar with MSSQL and I'm able to execute SP with no problem using SQL server, but I can't figure out how to do the same with Oracle. I can't view the actual code for the stored procedure, but from the limited documentation I have, it appears it accepts no input parameters and the return value is a ref cursor. I have a feeling that I need to pass in a ref cursor somehow, but everything I've tried in that regard has not worked.
I just want to view the results of the SP as if I had done a SELECT statement, that is, with the records populating the data grid in the results panel in the TOra interface.
It sounds like the procedure does have an OUT parameter (in Oracle, procedures do not return anything but can have OUT and IN OUT parameters, functions return something). So you would have to pass in a variable for that OUT parameter. Something like
DECLARE
l_results SYS_REFCURSOR;
BEGIN
schema.my_proc( l_results );
END;
should successfully call the procedure. But then you want your GUI to display the results from that cursor. That, unfortunately, gets a little more complicated because now you're talking about a GUI-specific issue.
I don't use TOra, so I don't know what you need to do in TOra to get the cursor to display. In SQL*Plus (or SQL Developer, Oracle's free GUI), you could do something like
create or replace procedure my_proc( p_rc OUT SYS_REFCURSOR )
as
begin
open p_rc
for select 1 col1
from dual;
end;
/
variable rc refcursor;
exec my_proc( :rc );
print rc;
This creates a stored procedure with an OUT parameter that is a cursor, declares a host variable that can be passed in, and then prints the results.
I have an oracle stored proc with signiture: (part of package: Contractor)
PROCEDURE usp_sel_contractors(g_contractors OUT sel_contractor);
I am trying to execute it like:
execute Contractor.usp_sel_contractors;
I'm used to MSSqlServer. This seems like it should be strait forward.
I keep getting error:
Invalid Sql Statement
Thanks!
Assuming sel_contractor is a ref cursor type, you could do this in SQL Plus:
var rc refcursor
exec usp_sel_contractors(:rc)
print rc
I'm not sure why you'd be getting that specific error message, but the obvious problem is that the procedure has a parameter and you're not passing one. Since it's an OUT parameter you would need to pass a variable of the appropriate type which will be populated by the procedure.
For example:
DECLARE
my_contractors sel_contractor;
BEGIN
usp_sel_contractors( my_contractors );
// Do something with the contents of my_contractors here
END;
/