Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Invoking procedure returned by function

Tags:

delphi

pascal

Having this:

procedure Foo;
begin
end;

function Bar: TProcedure;
begin
  Result := Foo;
end;

The following compiles:

var
  tmp: TProcedure;
begin
  tmp := Bar();
  tmp();

...but the following doesn't compile in Delphi:

Bar()();

Is there a reason for this "limitation"? Does Bar()(); syntax compile in some other "flavour" of Pascal? Would Bar()(); syntax compile in some other context?

like image 315
Pol Avatar asked Aug 12 '14 07:08

Pol


People also ask

Can we call stored procedure from function?

We cannot call store procedure within a function. However, we can call a function within a store procedure.

Does a procedure return a value?

A stored procedure does not have a return value but can optionally take input, output, or input-output parameters. A stored procedure can return output through any output or input-output parameter.

What is the right way of invoking the stored procedure?

Expand the database that you want, expand Programmability, and then expand Stored Procedures. Right-click the user-defined stored procedure that you want and select Execute Stored Procedure. In the Execute Procedure dialog box, specify a value for each parameter and whether it should pass a null value.

How do I return a stored procedure message?

In SQL Server Management Studio (SSMS), expand Programmability > Stored Procedures, right click a stored procedure and select Execute Stored Procedure. In the execute procedure page, enter the parameter @CustID value as 10 and click OK. It returns the following T-SQL statement with a variable @return_value.


1 Answers

Simply call as

TProcedure(Bar());
like image 80
Fenistil Avatar answered Sep 29 '22 05:09

Fenistil