Title: Sending Array of Variant to Server Post by: Theprasit on June 18, 2013, 08:49:33 AM I tried to send array of variant as remote function parameter using rtcArray but not success., e.g.
Sending -> OpenSql('Exec StoreProc1 :P1, :P2', [2, '300']); This will call function to execute store procedure (which return record set) on the server side but seem not to work. So, how to send this kind of data type among client and server? Regards, Title: Re: Sending Array of Variant to Server Post by: D.Tkalcec (RTC) on June 18, 2013, 10:08:00 AM You can not send "Variant" data types, because "Variant" is not a type. It is a container for a number of different data types. But, you can send your store procedure call parameters in an array or record where each element is of a different type, like ...
Code: with RtcClientModule.Prepare('OpenSql') do While you could also use the "Value" property, which reads and sets data using the Variant type, I do not recommend it, because type conversions are required ("Variant" can NOT be sent) and you won't know for sure what type your data ended up in. Best Regards, Danijel Tkalcec Title: Re: Sending Array of Variant to Server Post by: Theprasit on June 18, 2013, 12:14:00 PM WOW! very fast response :D
Per your example, this is fine but in actual requirement, the number of parameters is not fixed, that's why I intended to use open array to pass these parameters. I did some experiment and managed to resolve it by iterate open array value into rtcArray data type (using .asValue[]). I awarded with your mentioned about Variant but "OpenSql" is my generic function which receive any type of parameters for SQL statement. Do you have any ideas beside using .asValue[] ? Thank you and Regards, Title: Re: Sending Array of Variant to Server Post by: D.Tkalcec (RTC) on June 18, 2013, 12:36:56 PM If you are happy with "asValue", then use it. But I would recommend checking what type is actually being sent and then assigning the value using asInteger, asString, asText, asCardinal, asFloat, asDateTime, ... That's more work, but it ensures that you have covered all the types you need to support and that type conversions are done according to your requirements.
Best Regards, Danijel Tkalcec Title: Re: Sending Array of Variant to Server Post by: Theprasit on June 18, 2013, 01:14:09 PM Thank you for your suggestion, will seek for others alternative.
Best Regards, |