Testing a stored procedure in JMeter - format error - oracle

I am trying to test an Oracle Stored Procedure in JMeter. I have already done the configuration to the DB successfully, but when I call the stored procedure and send the parameters, I have a format error, apparently, the JMeter is not sending the parameters as I configure them.
SP-JMETER:
This is the error:
ERROR:
As you can see, the parameters reach the stored procedure, and it processes it, but apparently, I'm not sending them right.
In this way I execute the stored procedure in the PL/SQL Developer:
SP-PLSQLDEV:
And let me know if you need any more information.
w_trans_date: = substr (w_in, 1, 8); / * left (w_in, 8); */

Try to w_trans_date: = substr('28372873822327', 1, 8);
If this code will work properly, see on value in w_in variable.

I solved the issue by adding the following line to the INIT SQL STATEMENTS of the JDBC CONNECTION CONFIGURATION:
alter session set nls_date_format = 'dd / mm / yyyy'

Related

Why stored procedure stage in DataStage not working properly?

I need to use the stored procedure stage.
Currently I'm making just for an example for how to use it right.
CREATE OR REPLACE PROCEDURE "STG"."TRUNC_TEST"
AS
BEGIN
execute immediate 'truncate table TESTSP';
END;
That's my example of simple stored procedure.
My job design probably seen like this
Oracle Connector 1=>Transformer=>Oracle Connector 2=>Stored Procedure Stage
Oracle Connector 1 do Select, Oracle Connector 2 do Insert to TESTSP
My settings in the stored procedure stage
General : I've already put all the credential , with Transaction ISO as None
Syntax
Procedure Name : TRUNC_TEST
Procedure Type : Transform (i've also tried to change it to Target)
Database Procedure Type : Stored Procedure
Generate procedure call (checked)
Parameters
Empty
Error Codes
Empty
NLS Map
Project Default UTF-8
Advanced
Execution mode :Default(Sequential)
Combinability : Default
Configuration file : default
In the Input tabs
General
Execute Procedure for each row (checked)
Transaction size : 0
Partitioning
Collector type Auto
Columns
Just brought all the columns from Oracle connector 2
Advanced
Default
The job showing green line and success, but the SP isn't working. It should've been truncate the TESTSP table, but when I do a select *, the data is still there.
Maybe my stored procedure is wrong since I'm still learning how to make it? Or maybe there is something wrong with my 'Settings' in the stored procedure stage?
Every time you are running your job, you are just creating or replacing the SP definition.
You will have to call the SP in order to execute it.
That is the reason you are able to execute it outside.
I suggest you to create a generic SP in your database which will accept table name as parameter.
Once this is created, use SP stage to invoke the SP with column you want to truncate.
You can also use after SQL option in oracle connector to avoid extra SP stage.

Is there a way to embed an alter query into a oracle sql procedure?

I am trying to create a procedure that I can call upon that would alter the date format and I am having some issues and could use some help.
If I try this code:
create or replace PROCEDURE DATE_SESSION IS
BEGIN
ALTER SESSION SET NLS_date_format = 'MM/DD/YYYY';
END;
I get this error:
Error starting at line : 1 in command -
DATE_SESSION
Error report -
Unknown Command
And if I try this code:
create or replace PROCEDURE DATE_SESSION IS
BEGIN
EXECUTE IMMEDIATE 'ALTER SESSION SET NLS_date_format = 'MM/DD/YYYY';';
END;
And then execute it with:
DATE_SESSION
I get this error:
Error starting at line : 1 in command -
DATE_SESSION
Error report -
Unknown Command
Any insight would be greatly appreciated.
You have to use double apostrophe.
I don't recommend discarding the time component of dates values.
BEGIN
EXECUTE IMMEDIATE 'ALTER SESSION SET NLS_date_format=''MM/DD/YYYY''';
END;
If you're going to use a lot of dynamic SQL, it's worth learning the alternative quoting syntax. This syntax lets us embed code within code without doubling the number of single quotes. This makes the code more readable and easier to test.
create or replace procedure date_session is
begin
execute immediate
q'[
alter session set nls_date_format = 'MM/DD/YYYY'
]';
end;
/
However, I wonder if this question is an X-Y problem. Changing the date format is intended to be done so that different clients can view data in their preferred format. Setting the format inside a stored procedure makes me wonder if it's being set to fix some program that foolishly assumed a specific date format. You should never have to change the session level date format to make a program work. If that's the case here, it's better to modify the original program and remove any implicit date conversions. (On the other hand, we can't always control the source code, so these solutions are sometimes necessary.)

Oracle: Call SP with Out parameter

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?

Execution of oracle procedure multiple times in powerbuilder 12.0

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...

Execute Oracle Stored Proc

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;
/

Resources