Re: [IBPP-DISCUSS] Bind Parameters by name
IBPP is a C++ client class library for FirebirdSQL
Status: Inactive
Brought to you by:
epocman
|
From: Lucas S. <luc...@gm...> - 2016-04-09 00:47:44
|
Hello Again, sorry for the long time...
Olivier Mascia, I want your opinion... in the parameters list, do you think
to be preferable to use case sensitive or insensitive?
because the code to compare the insensitive strings... well... I didn't
liked it, here it is:
(PS: I don't work to much with C++, so I know this isn't the best
options... Any idea/help is welcome)
bool icasecmp(const std::string& l, const std::string& r);
bool icasecmp(const std::wstring& l, const std::wstring& r);
bool icasecmp(const std::string& l, const std::string& r)
{
return l.size() == r.size()
&& equal(l.cbegin(), l.cend(), r.cbegin(),
[](std::string::value_type l1, std::string::value_type r1)
{ return std::toupper(l1) == std::toupper(r1); });
}
bool icasecmp(const std::wstring& l, const std::wstring& r)
{
return l.size() == r.size()
&& equal(l.cbegin(), l.cend(), r.cbegin(),
[](std::wstring::value_type l1, std::wstring::value_type r1)
{ return std::towupper(l1) == std::towupper(r1); });
}
Thanks!
On Mon, Oct 5, 2015 at 8:51 PM, Lucas Schatz <luc...@gm...> wrote:
> Good idea! But first, I'll do the part that I'm supposed to do, after
> that,we can talk more about your idea!
> To do this work properly, I'll need to know if the statement is an (update
> or )insert, update or delete, because the structure will be different in
> DDLs (I can't replace parameters in DDLs)
> For now, I'm simply looking for the first valid word [INSERT, UPDATE,
> DELETE, WITH, EXECUTE P(ROCEDURE)]...
> But I don't think that this solution is good enough/elegant. If you have
> an sugestion, I'll be glad
>
> Thanks!
>
>
>
>
>
> On Sun, Oct 4, 2015 at 8:20 AM, Olivier Mascia <om...@in...> wrote:
>
>> > Le 3 oct. 2015 à 23:15, Lucas Schatz <luc...@gm...> a écrit :
>> >
>> > Hi, is there interest to add support to add parameters by name, instead
>> of
>> > just "?"
>> > I'm doing this by myself, but I want to know if IBPP team has interest
>> in
>> > the patch.
>> >
>> > It will work like this example:
>> >
>> > statement->Prepare("INSERT INTO TEST_TABLE (ID, COLUMN2, COL3, ABC)
>> > VALUES (:IDVALUE, :COL2, ?, :ABC)");
>> > st2->Set("IDVALUE", 1);
>> > st2->Set("COL2", "AAAA");
>> > st2->Set(3, 12.34); # Regular use
>> > st2->Set("abc", 12344.0); # Case insensitive
>>
>> Hello, yes, why not, thanks in advance.
>>
>> Though it was never programmed / finalized, another idea along the same
>> lines was this:
>>
>> statement->Prepare("INSERT INTO TEST_TABLE (ID, COLUMN2, COL3, ABC)
>> VALUES (?, "data", ?, ?)");
>> st2->Set("ID", 1);
>> st2->Set(3, 12.34); # Regular use
>> st2->Set("abc", 12344.0); # Case insensitive
>>
>> It allows to re-use the column names from the INTO part of the statement
>> to match them to the '?' instead of assigning yet other pseudo variable
>> names. I intentionally added a constant data in the VALUES part, because
>> this is something which happen and must be accounted for. It too implies to
>> parse correctly the statement, which is something that the current IBPP
>> implementation doesn't have to do (merely count the '?' to optimize some
>> resources allocation, which is not a proper parse.
>>
>> --
>> Meilleures salutations, Vriendelijke groeten, Best Regards,
>>
>> Olivier Mascia (from mobile device)
>> tipgroup.com/om
>>
>>
>> ------------------------------------------------------------------------------
>> _______________________________________________
>> ibpp-discuss mailing list
>> Post to ibp...@li...
>> Settings https://lists.sourceforge.net/lists/listinfo/ibpp-discuss
>> http://www.ibpp.org
>
>
>
|