Thx for the feedback
However I still am having problems!
On my form I have one PgStoredProc. As DFM this looks like:
Code: Select all
object PgStoredProc1: TPgStoredProc
StoredProcName = 'f_get_agent_switch_data'
Connection = PgConnection1
SQL.Strings = (
'SELECT f_get_agent_switch_data(:p_agent_id, :p_application_name)')
Left = 80
Top = 24
ParamData =
CommandStoredProcName = 'f_get_agent_switch_data:0'
end
As you can see there is a correct result (ftADT value) from the stored function when I push in the IDE the "execute" button in the params configuration dialog.
However I am unable to execute this in my code. My code looks like:
Code: Select all
try
PgStoredProcVoipData := TPgStoredProc.Create(nil);
with PgStoredProcVoipData do begin
Connection := PgConnection;
StoredProcName := 'f_get_agent_switch_data';
Sql.Clear;
Sql.Add('SELECT f_get_agent_switch_data(:p_agent_id, :p_application_name)');
Params.Clear;
Params.AddParam(Params.CreateParam(ftADT, 'result', ptResult));
Params.AddParam(Params.CreateParam(ftLargeint, 'p_agent_id', ptInput));
Params.AddParam(Params.CreateParam(ftString, 'p_application_name', ptInput));
ParamByName('p_agent_id').AsInteger := 1;
ParamByName('p_application_name').AsString := 'GEM78';
Execute;
try
ServerName := Fields[0].asString;
ServerIp := Fields[1].asString;
ServerPort := Fields[2].asInteger;
AgentExtension := Fields[3].asString;
AgentPassword := Fields[4].asString;
Result := True;
except
end;
Close;
end;
finally
PgStoredProcVoipData.Free;
end;
The exception is "List index out of bounds(0)"...
What am I doing wrong?
Thanks & cheers,
P.