On 29 May 2013 10:05, Deane Yang <[email protected]> wrote:
> Does a query like this work in SOCI:
>
> select trades.price, bonds.coupon from trades, bonds where trades.id =
> bonds.id

I don't see why it should not work.
One of possible examples how to use SOCI with such query:

        session sql(backEnd, connectString);
        sql << "create table trades (id integer, p integer)";
        sql << "create table bonds (id integer, c integer)";
        sql << "insert into trades (id, p) values (1, 100)";
        sql << "insert into trades (id, p) values (2, 200)";
        sql << "insert into trades (id, p) values (3, 300)";
        sql << "insert into bonds (id, c) values (1, 7)";
        sql << "insert into bonds (id, c) values (3, 9)";

        auto init_fetch = 2U;
        std::vector<int> prices(init_fetch);
        std::vector<int> coupons(init_fetch);
        sql << "select trades.p, bonds.c "
            << "from trades, bonds where trades.id = bonds.id"
            , into(prices), into(coupons);

        std::transform(prices.cbegin(), prices.cend(), coupons.cbegin(),
            std::ostream_iterator<std::string>(std::cout, "\n"),
            [] (int p, int c) {
                return "price: " + std::to_string(p) +
                    ", coupon: " + std::to_string(c);
        });
        // price: 100, coupon: 7
        // price: 300, coupon: 9


p.s. Seems you've sent this post from different e-mail than the subscribed,
if you want me to whitelist this additional e-mail, just let me know.
Otherwise, it is held for moderation

Best regards,
--
Mateusz Loskot, http://mateusz.loskot.net

------------------------------------------------------------------------------
Introducing AppDynamics Lite, a free troubleshooting tool for Java/.NET
Get 100% visibility into your production application - at no cost.
Code-level diagnostics for performance bottlenecks with <2% overhead
Download for free and get started troubleshooting in minutes.
http://p.sf.net/sfu/appdyn_d2d_ap1
_______________________________________________
soci-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/soci-users

Reply via email to