I'm trying to call PL/SQL procedure from SoapUi with Groovy and I get error like: "..that function does not exist" I guess that this part of code is for calling PL/SQL functions, and when I check it with PL/SQL function - it works. Could anyone help with solution for calling PL/SQL procedure with Groovy?
Sample of code that works for calling PL/SQL Function:
sql.call("{? = call IFSUI_SG_CA_TEST_UTILS.getCustomerAccountData(?, ?, ?)}", [Sql.VARCHAR, customerNo, accountNo, accountIbanNo]) { result ->
log.info (results);
}
I finally finded it, here is example of calling PL/SQL procedure from Groovy with also IN OUT parameter, I hope that it will save time someone :)
With IN parameter:
sql.call("{call IFSUI_SG_CA_TEST_UTILS.getCustomerAccountData(?,?,?)}",
[customerNo,accountNo,accountIbanNo])
customerNo,... are variables
With IN OUT parameter:
sql.call("{call IFSUI_SG_CA_TEST_UTILS.getCustomerAccountData(?,?,?)}",
[Sql.inout(Sql.VARCHAR(customerNo)), Sql.inout(Sql.VARCHAR(accountNo)),
Sql.inout(Sql.VARCHAR(accountIbanNo))])
Related
I have this trigger in one of my scripts:
CREATE OR REPLACE TRIGGER MS_DB.DB_TR_IncrementTrialNumber BEFORE INSERT
ON MS_DB.DB_SUMMARY FOR EACH ROW
begin
UPDATE MS_DB.DB_Summary SET MS_DB.DB_Summary.TimesGenerated =
(Select COALESCE(MAX(TimesGenerated),0)+1
From MS_DB.DB_Summary
Where MS_DB.DB_Summary.StepID = :NEW.StepID And
MS_DB.DB_Summary.ValidationID = :NEW.ValidationID AND
MS_DB.DB_Summary.SummaryDate = :NEW.SummaryDate);
where MS_DB.DB_Summary.ID = :NEW.ID;
end;
/
I use TOAD for executing the the script.
When I use 'Execute as Script' button it works fine.
But when I run it in SQLPlus window I get this line :
SP2-0552: Bind variable "NEW" not declared
Any ideas why I am getting this?
Thanks
By default SQL*Plus treats a blank line as the end of a statement. The first line, the create, is never executed. The rest is executed as an anonymous block, and as it is no longer part of a trigger statement the NEW isn't recognised.
You can either remove the blank line before the begin, or do set sqlblanklines on before you start.
Does anyone know how to pass a local variable to PlatonScript procedure as an argument?
I just don't want to use global variables.
Thanks
When you create a procedure that has parameters you have to declare it like
<p_targetsData>
<![CDATA[START:p_targetsData(testvar1,testvar2)
testvar1 = "test"
testvar2 = 123
RETURN 1 ]]>
</p_targetsData>
when you want to call it and pass the parameters you write
#testvar1:STRING
#testvar2:INTEGER
CALL p_targetsData(testvar1,testvar2)
jPlaton uses calling by reference so after the CALL execution your variables will still have their real value
I've got a function in an oracle database. I need to call it from delphi. I use the following code:
procedure TForm1.Run;
var
q:TADOQuery;
begin
q:=TADOQuery.Create(nil);
q.Connection:=ADOConnection1;
q.ParamCheck:=false;
q.SQL.Add('BEGIN');
q.SQL.Add(' :RES:=Search(:P_DATE);');
q.SQL.Add('END;');
q.Parameters.AddParameter.Name:='P_DATE';
q.Parameters.ParamByName('P_DATE').Direction:=pdInput;
q.Parameters.ParamByName('P_DATE').DataType:=ftDate;
q.Parameters.ParamByName('P_DATE').Value:=Now;
q.Parameters.AddParameter.Name:='RES';
q.Parameters.ParamByName('RES').DataType:=ftFloat;
q.Parameters.ParamByName('RES').Direction:=pdOutput;
q.Parameters.ParamByName('RES').Value:=1;
q.ExecSQL;
//...
I get ora-06550 error, saying invalid number or type of parameters. If I change the P_DATE parameter to sysdate, i.e. :RES:=Search(sysdate);, it works fine.
So how can I pass an "in" parameter of type DATE to an oracle function from delphi?
Found ORA-06550 when Oracle stored function is called.. However this relates to Kylix Pascal IDE. Am I expected to meet the same behaviour for delphi? Didn't try to use oracle procedure instead of a function. Maybe this issue can be solved some how else...
Oracle doesn't have a date type for bind variables - you need to explicitly convert the bind variable to a date:
:res := search(to_date(:p_date, 'dd/mm/yyyy'));
You should then be able to pass your variable as a string matching the date format you've specified.
Try to send this parameter as a string:
.........
q.SQL.Add('BEGIN');
q.SQL.Add(' :RES:=Search(TO_DATE(:P_DATE,''YYYYMMDD''));');
q.SQL.Add('END;');
q.Parameters.AddParameter.Name:='P_DATE';
q.Parameters.ParamByName('P_DATE').Direction:=pdInput;
q.Parameters.ParamByName('P_DATE').DataType:=ftString;
q.Parameters.ParamByName('P_DATE').Value:=FormatDateTime('yyyymmdd',Now);
..........
You're doing it wrong (and I think you had a previous question deleted as being a duplicate that asked this same question (different function, but same idea) just a couple of days ago).
You're calling the function wrong in the first place.
.........
q.SQL.Add('BEGIN');
q.SQL.Add(' SELECT Search(TO_DATE(:P_DATE,''YYYYMMDD'')) FROM System.Dual;');
q.SQL.Add('END;');
q.Parameters.AddParameter.Name:='P_DATE';
q.Parameters.ParamByName('P_DATE').Direction:=pdInput;
q.Parameters.ParamByName('P_DATE').DataType:=ftDate;
q.Parameters.ParamByName('P_DATE').Value:=Now;
q.Open;
if not q.IsEmpty then // or not q.Eof
Res := q.Fields[0].AsFloat;
I'm calling a system stored procedure for full text search package. It generates terms used for full text search based on a sql literal.
ex: exec ctx_query.explain('index_name', 'full text filter', 'explain table') etc
I'm doing the following in my code:
using(OracleCommand command = new OracleCommand("ctx_query.explain", DataAccess.GetConnString()))
{
comm.Parameters.AddWithValue("index_name", "explain1");
//comm.Parameters.AddWithValue("text_query", "(test) OR (term1 ACCUM term2");
comm.Parameters.AddWithValue("text_query", txtUserInput.Text);
comm.Parameters.AddWithValue("explain_table", "explain_results");
comm.Parameters.AddWithValue("sharelevel", 0);
comm.Parameters.AddWithValue("explain_id", new Guid().ToString().Substring(0,30));
comm.ExecuteNonQuery();
}
The "text_query" parameter will be built from user input. Does the above prevent sql injection because the textUserInput.Text will be passed as a command parameter?
ctx_query.explain does not execute the query, it only examines it, so there is no SQL injection risk here.
Is there a way to use positional parameters when calling Oracle stored procedure using System.Data.OracleClient?
IDataParameter parameter = dbCommand.CreateParameter( );
parameter.Value = "Blah Blah";
parameter.Type = OracleType.Varchar;
dbCommand.Parameters.Add(parameter);
The code above creates a parameter and assigns "Parameter1" name to it. When stored proc is called Oracle gives "wrong number or types of arguments" error.
Solved problem by switching to provider from Oracle (Oracle.DataAccess)