Re: [IBPP-DISCUSS] Bind Parameters by name
IBPP is a C++ client class library for FirebirdSQL
Status: Inactive
Brought to you by:
epocman
|
From: Olivier M. <om...@in...> - 2015-10-04 11:20:47
|
> 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
|