JMeter,JDBC Request,Stored Procedure,Oracle - stored-procedures

i need to call this PL\SQL function structured like this:
FUNCTION FunctionName ( p_lang_IN IN SESSIONS.s_lang%TYPE,
p_user_IN IN VARCHAR2,
p_pwd_IN IN VARCHAR2,
p_source_IN IN SESSION_SOURCE.ss_userid%TYPE,
p_sessionstring_OUT OUT SESSIONS.s_id%TYPE,
p_pwd_type IN NUMBER DEFAULT 0,
P_PSWD_STATUS OUT NUMBER
)
RETURN NUMBER;
I'm using a JDBC Request created like this:
enter image description here
I get the following error:
ORA-06550: line 1, column 7:
PLS-00221: 'FunctionName' is not a procedure or is undefined
ORA-06550: line 1, column 7:
PL/SQL: Statement ignored
I suppose an error in the syntax of the call ... but that is?
Thanks in advance
Bye

Related

Neo.ClientError.Procedure.ProcedureCallFailed: Failed to invoke procedure `apoc.do.when`: Caused by: org.neo4j.cypher.internal.v3_5.util.SyntaxExcepti

Can someone please help me with my probelm.
When i execute the below cypher query im getting exception as in the Title:
LOAD CSV WITH HEADERS FROM "file:///MNK/device.csv" AS line
MATCH (rSeq:Sequence{key:"runId_seq"})
OPTIONAL MATCH (l:Location{siteGaid:line.location_key}) WHERE NOT l:Model
WITH count(l) as i, line.location_key as key,line.location_key as sourceobjectId,
timestamp() as createdate,rSeq.runId as runId
CALL apoc.do.when(
i = 0,
'CREATE (a:locationServiceMigrationError
{errorCode: "missing_location",
errorDescription: "unable to find Location by its key",
matchingObjectKey: key,
srcObjectId: sourceobjectId,
type:"Location",
srcObjectName: "location_key",
sourceFileName: "device.csv",
scriptName:"device.cql",
createdDate:createdate,
runId:runId
}) RETURN a AS node',
'RETURN 0 AS result',
{key:key,
sourceobjectId:sourceobjectId,
createdate:createdate}
) YIELD value
RETURN count(value);
...Getting Error message like below
Neo.ClientError.Procedure.ProcedureCallFailed: Failed to invoke procedure apoc.do.when: Caused by: org.neo4j.cypher.internal.v3_5.util.SyntaxException: Variable runId not defined (line 11, column 11 (offset: 463))
...When i tried changing the 1st line with different file name as below then it is going fine.
LOAD CSV WITH HEADERS FROM "file:///MNK/location_coordinate_service.csv" AS line
.. Im not able to understand what exactly the issue is .
runId has to be passed into the parameter list too,
...,
{
key:key,
sourceobjectId:sourceobjectId,
createdate:createdate,
runId: runId
}

is it possible to assign dynamic value from request-path to `table` attribute for FormHandler gramex-config entry?

ref to FormHandler-param-doc
below is the sample gramex-config snippet:
dburl: postgresql://$db_name:$db_name#localhost:5432/$db_name
data_filter:
pattern: /$YAMLURL/data_filter/(\w+)
handler: FormHandler
kwargs:
url: $dburl
table: {_0}
modify: data_filter.by_month_date(data)
Is it possible to assign value dynamically for table attribute from part of request-URL path?
for a sample request like:
/data_filter/prod_rec_20?S_CODE=20&D_CODE=322&Market_Code=10753&Crop_Code=106
Getting the below error:
Traceback (most recent call last):
File "c:\programdata\anaconda3\lib\site-packages\gramex\handlers\formhandler.py", line 157, in get
result[key] = yield val
File "c:\programdata\anaconda3\lib\site-packages\tornado\gen.py", line 1133, in run
value = future.result()
File "c:\programdata\anaconda3\lib\concurrent\futures\_base.py", line 425, in result
return self.__get_result()
File "c:\programdata\anaconda3\lib\concurrent\futures\_base.py", line 384, in __get_result
raise self._exception
File "c:\programdata\anaconda3\lib\concurrent\futures\thread.py", line 57, in run
result = self.fn(*self.args, **self.kwargs)
File "c:\programdata\anaconda3\lib\site-packages\gramex\data.py", line 247, in filter
raise ValueError('No table: or query: specified')
ValueError: No table: or query: specified
Sure. Please see https://learn.gramener.com/guide/formhandler/#formhandler-parameters
You can specify table: '{_0}'. Then /data_filter/?table=prod_rec_20 would work.
table: {_0} without the quotes won't work, though. YAML interprets the {} as an object. You need to quote the '{_0}' for this to work. (I tested it, and it's working fine.

Calling Oracle 11g Stored Procedure Using VB6

I have a simple Oracle procedure as below. I am trying to call the procedure using VB6 and extract the output from the procedure.
CREATE OR REPLACE PROCEDURE EXTRACTTXN (reportdate IN DATE, p_recordset OUT SYS_REFCURSOR) AS
BEGIN
OPEN p_recordset FOR
SELECT
TXN_ID,
TXN_ACTION,
TXN_STATUS,
TXN_DATE,
TXN_AMOUNT
FROM TRANSACTIONS
WHERE
TRUNC(TXN_DATE) = TRUNC(reportdate)
END EXTRACTTXN;
The VB Code goes like this;
Sub FetchTransactions(ByVal ReportDate As Date, cnnMine as ADODB.Connection)
On Error GoTo TrapErr
Dim cmdMine As ADODB.Command, rsMine As ADODB.Recordset
cmdMine.ActiveConnection = cnnMine
cmdMine.CommandTimeout = 300
cmdMine.CommandType = adCmdStoredProc
cmdMine.CommandText = "EXTRACTTXN"
cmdMine.Parameters.Append cmdMine.CreateParameter("reportdate", adDate, adParamInput, , Format(ReportDate, "DD-MMM-YYYY"))
cmdMine.Parameters.Append cmdMine.CreateParameter("p_recordset", adVariant, adParamOutput)
Set rsMine = cmdMine.Execute
Do While rsMine.EOF
Debug.Print rsMine!TXN_ID, rsMine!TXN_ACTION, rsMine!TXN_STATUS, rsMine!TXN_DATE, rsMine!TXN_AMOUNT
rsMine.MoveNext
Loop
rsMine.Close
Exit Sub
TrapErr:
MsgBox Err.Number & " - " & Err.Description, vbExclamation, App.ProductName
End Sub
While running the code, I get the following Error:
ORA-06550: line 1, column 7:
PLS-00306: wrong number or types of arguments in call to 'EXTRACTTXN'
ORA-06550: line 1, column 7:
PL/SQL: Statement ignored
Anything wrong in my code? Appreciate help.
Niz
The problem is that the types of your arguments as specified in your VB code don't match the types of the arguments as specified in your PL/SQL code. The most likely reason for your problem is that the Format function in VB6 returns a Variant type, not a Date type, and that Variant type is set to be a String type. See this for more information on the Format function.
In case you don't know, the way that Variant variables are set up is that they reserve 8 bytes to tell the world what the actual variable type is. So, if you pass your ReportDate in after applying the Format function to it, it will be a Variant that's telling the world it's a string. It's possible that the ADO Parameter object is happy with that (SQL Server is happy to parse properly-formatted strings into Date fields, after all) and Oracle isn't. In my limited experience with Oracle, I've found that it's fussier about that sort of thing than SQL Server.
Try losing the Format function and see if you at least get a different error.
I have managed to get this sorted. It's mainly due to me being new to Oracle and its complexity.
Here are the changes I made;
Stored Procedure Changes. Note that I have changed TRUNC(reportdate, 'DD') on the Where clause.
CREATE OR REPLACE PROCEDURE EXTRACTTXN (reportdate IN DATE, p_recordset OUT SYS_REFCURSOR) AS
BEGIN
OPEN p_recordset FOR
SELECT
TXN_ID,
TXN_ACTION,
TXN_STATUS,
TXN_DATE,
TXN_AMOUNT
FROM TRANSACTIONS
WHERE
TRUNC(TXN_DATE) = TRUNC(reportdate, 'DD')
END EXTRACTTXN;
VB Code Changes (Note that I have change the CommandText within parenthesis with a Call, removed the parameter name, changed the date format to DD/MMM/YYYY and removed the output parameter)
Sub FetchTransactions(ByVal ReportDate As Date, cnnMine as ADODB.Connection)
On Error GoTo TrapErr
Dim cmdMine As ADODB.Command, rsMine As ADODB.Recordset
cmdMine.ActiveConnection = cnnMine
cmdMine.CommandTimeout = 300
cmdMine.CommandType = adCmdStoredProc
cmdMine.CommandText = "{ call EXTRACTTXN}"
cmdMine.Parameters.Append cmdMine.CreateParameter(, adDate, adParamInput, , Format(ReportDate, "DD/MMM/YYYY"))
Set rsMine = cmdMine.Execute
Do While rsMine.EOF
Debug.Print rsMine!TXN_ID, rsMine!TXN_ACTION, rsMine!TXN_STATUS, rsMine!TXN_DATE, rsMine!TXN_AMOUNT
rsMine.MoveNext
Loop
rsMine.Close
Exit Sub
TrapErr:
MsgBox Err.Number & " - " & Err.Description, vbExclamation, App.ProductName
End Sub
The above worked perfectly.
Regards, Niz

Firebird "insert ... returning" into a variable using stored procedure

I'm using Firebird 2.x and I have made a stored procedure to insert a record if it doesn't exist and return its ID into a variable.
But when I execute, it turns out that the following error occurs:
Dynamic SQL Error. SQL error code = -104. Unexpected end of command - line 2, column 76.
Full source code of my SP following:
CREATE PROCEDURE INSERT_ADMIN_OFFICE
AS
DECLARE VARIABLE OFF_ID BIGINT;
DECLARE VARIABLE PER_ID BIGINT;
DECLARE VARIABLE EMP_ID BIGINT;
DECLARE VARIABLE AP_ID BIGINT;
BEGIN
IF (NOT EXISTS(SELECT * FROM OFFICE OFF WHERE OFF.DESCRIPTION LIKE '%Administrador%')) THEN
INSERT INTO OFFICE (DESCRIPTION) VALUES ('Administrador') RETURNING ID INTO :OFF_ID;
ELSE
SELECT OFF.ID FROM OFFICE OFF WHERE OFF.DESCRIPTION LIKE '%Administrador%' INTO :OFF_ID;
INSERT INTO PERSON (NAME, BIRTH_DATE, ADDRESS, DISTRICT, CITY, STATE) VALUES ('Intellitools Desenvolvimento de Software Ltda.', '01/01/2007', 'Rua Nunes Machado, 472 - Cj 503', 'Centro', 'Curitiba', 'PR') RETURNING ID INTO :PER_ID;
INSERT INTO USER_PASSPORT (PERSON_ID, USER_NAME, PWD, TYPE) VALUES (:PER_ID, 'intellitools', 123, 1);
INSERT INTO EMPLOYEE (OFFICE_ID, PERSON_ID) VALUES (:OFF_ID, :PER_ID) RETURNING ID INTO :EMP_ID;
INSERT INTO ACCESS_PROFILE (DESCRIPTION) VALUES ('Administrador Geral') RETURNING ID INTO :AP_ID;
INSERT INTO REL_EMPLOYEE_ACCESS_PROFILE (EMPLOYEE_ID, ACCESS_PROFILE_ID) VALUES (:EMP_ID, :AP_ID);
SUSPEND;
END
;
I notice that this error is because of the INTO on the INSERT but I can't find another way to do that.
I appreciate your help!
Just remove SUSPEND and your proc will execute like a charm. For a one time actions I would suggest EXECUTE BLOCK instead of creating stored procedure.

vb6 does not recognize the error when there is a result set

I have a stored procedure which
returns a result set with the error
message, when an error occurs. If it
executes without any error, the result
set is empty (Command(s) completed
successfully)
On the vb6 side, I execute the sp and
check whether there is an error by
If Err <> 0 Then
' do sth
End If
But, when there is a result set, the
Err is always 0.
How should I handle this situation?
Sorry for inadequate explanation.
Here are my scripts:
--my sample table
create table #InvoiceDocument (InvoiceID int, ItemID int, Price float, DocStatus bit)
--my test values
insert into #InvoiceDocument (InvoiceID, ItemID, Price)
values (1, 1, 2.5), (1, 2, 5.0), (1,5, null)
--my sample procedure
create procedure sp_ApproveInvoice #InvoiceID int
as
begin
set nocount on
select * into #temp
from #InvoiceDocument
where Price is null and InvoiceID = #InvoiceID
if exists (select 1 from #temp)
begin
select InvoiceID, ItemID, Price from #temp
RAISERROR ('There are non priced items. Invoice can not be approved!',16, 1)
return
end
update #InvoiceDocument
set DocStatus = 1
where InvoiceID = #InvoiceID
end
when I execute this:
sp_ApproveInvoice 1
It both generates a resultset (Results), and an error message (Messages).
On the vb6 side, vb6 can not catch the error here.
You need to RAISERROR in the stored proc to set the error.
Or use output parameters. Or the RETURN statement
Or add logic to distinguish "success" and "fail" recordsets in the client code.
Currently, Err has no meaning because there is no error state
Personally, I use RAISERROR as per my question here with this template
Your particular case cannot be caught with Err since your stored procedure is not generating any error in the traditional sense---it's either giving an empty result set or a normal result set. How can VB know the semantics of a non-empty result set?
For this to work, you either need to change your stored procedure to raise error OR you need to check the result set returned by the stored procedure directly in your code (nothing to do with Err).

Resources