in Delphi the procedure write can handle:
write(TF,st1)
and
write(TF,st1,st2,st3,st4);
I want to declare a procedure that can also do that, what is the syntax?
and the option of:
write(TF,[st1,st2,st3])
is less desirable, though I know how to do that.
the main purpose was to pass ShortString
s into function, that would make a read call from file, and would read at the length of the shortString
as defined. however after passing it as variant or in open array the shortString
loses its "size" and become 255, which making this pass unusable, for me.
but the answer is still got if you want to pass open array.
A parameter represents a value that the procedure expects you to supply when you call it. The procedure's declaration defines its parameters. You can define a procedure with no parameters, one parameter, or more than one. The part of the procedure definition that specifies the parameters is called the parameter list.
In this solution, you need to pass a single comma delimiter string to the stored procedure. Once it is passed, you need to convert the string parameter to xml variable and split it using comma delimiter and then you can query it.
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.
Just to complement Cosmin's answer: if the list of parameters are of different types, you could use an variant open array parameter (also know as "array of const"). More on Delphi documentation.
Example (from documentation):
function MakeStr(const Args: array of const): string;
var
I: Integer;
begin
Result := '';
for I := 0 to High(Args) do
with Args[I] do
case VType of
vtInteger: Result := Result + IntToStr(VInteger);
vtBoolean: Result := Result + BoolToStr(VBoolean);
vtChar: Result := Result + VChar;
vtExtended: Result := Result + FloatToStr(VExtended^);
vtString: Result := Result + VString^;
vtPChar: Result := Result + VPChar;
vtObject: Result := Result + VObject.ClassName;
vtClass: Result := Result + VClass.ClassName;
vtAnsiString: Result := Result + string(VAnsiString);
vtCurrency: Result := Result + CurrToStr(VCurrency^);
vtVariant: Result := Result + string(VVariant^);
vtInt64: Result := Result + IntToStr(VInt64^);
end;
end;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With