OLTPゲーム

最近、高性能アプリケーションの実装のテーマがHabréで一般的になりました。 また、この方向で少し実験し、研究の現在の結果を共有することにしました。



件名「Hello、world!」は最も単純なOLTPシステムです。











このようなシステムでは、パフォーマンスとフォールトトレランスの要件が重要です。 したがって、問題の解決策の検索は、C、C ++、fastcgi、nginx、lighttpd、oracleの方向で実行されました。 まず、これらのテクノロジーでOLTPを構築するさまざまなオプションを試し、パフォーマンスとピーク負荷を測定することに興味がありました。





そして、問題の条件



次の形式のトランザクションを処理する必要があります:transfer X cu (お金、あなたはどう思いましたか)アカウントAからアカウントBへ。



リクエストは次の形式です



server.com/paysys.request?account=123&operator=456&money=789

つまり、オペレーター456のアカウントからユーザー123のアカウントに789のお金を転送します。



データベースには3つのプレートのみがあります。





(図1. DB構造)



トランザクション手順は、データベース構造よりもそれほど複雑ではありません。

procedure PROCESS_TRANS(p_account_id in number, p_operator_id in number, p_sum in number, o_result out number) is l_cnt number; cursor cur_account is select id from pay_account where id = p_account_id for update of balance; cursor cur_operator is select id from pay_operator where id = p_operator_id and total >= p_sum for update of total; begin o_result := -1; -- tansaction begins select count (1) -- if such operator exist? into l_cnt from pay_operator opr where opr.id = p_operator_id; if (l_cnt != 1) then o_result := -2; -- Operator not found! return ; end if ; open cur_account; open cur_operator; fetch cur_account into l_cnt; -- need to fetch to update rows later fetch cur_operator into l_cnt; -- 0/1 row in cursor as selected by prim_key if cur_account%notfound then o_result := -3; -- Account not found! elsif cur_operator%notfound then o_result := -4; -- Operator has not enough money else update pay_account set balance = (balance + p_sum) where current of cur_account; update pay_operator set total = (total - p_sum) where current of cur_operator; insert into pay_transaction ( id, account_id, operator_id, money, datetime ) values ( pay_transaction_seq.nextval, p_account_id, p_operator_id, p_sum, sysdate ); commit ; o_result := 1; -- transaction successfully finished! end if ; close cur_account; close cur_operator; end ; * This source code was highlighted with Source Code Highlighter .



  1. procedure PROCESS_TRANS(p_account_id in number, p_operator_id in number, p_sum in number, o_result out number) is l_cnt number; cursor cur_account is select id from pay_account where id = p_account_id for update of balance; cursor cur_operator is select id from pay_operator where id = p_operator_id and total >= p_sum for update of total; begin o_result := -1; -- tansaction begins select count (1) -- if such operator exist? into l_cnt from pay_operator opr where opr.id = p_operator_id; if (l_cnt != 1) then o_result := -2; -- Operator not found! return ; end if ; open cur_account; open cur_operator; fetch cur_account into l_cnt; -- need to fetch to update rows later fetch cur_operator into l_cnt; -- 0/1 row in cursor as selected by prim_key if cur_account%notfound then o_result := -3; -- Account not found! elsif cur_operator%notfound then o_result := -4; -- Operator has not enough money else update pay_account set balance = (balance + p_sum) where current of cur_account; update pay_operator set total = (total - p_sum) where current of cur_operator; insert into pay_transaction ( id, account_id, operator_id, money, datetime ) values ( pay_transaction_seq.nextval, p_account_id, p_operator_id, p_sum, sysdate ); commit ; o_result := 1; -- transaction successfully finished! end if ; close cur_account; close cur_operator; end ; * This source code was highlighted with Source Code Highlighter .



  2. procedure PROCESS_TRANS(p_account_id in number, p_operator_id in number, p_sum in number, o_result out number) is l_cnt number; cursor cur_account is select id from pay_account where id = p_account_id for update of balance; cursor cur_operator is select id from pay_operator where id = p_operator_id and total >= p_sum for update of total; begin o_result := -1; -- tansaction begins select count (1) -- if such operator exist? into l_cnt from pay_operator opr where opr.id = p_operator_id; if (l_cnt != 1) then o_result := -2; -- Operator not found! return ; end if ; open cur_account; open cur_operator; fetch cur_account into l_cnt; -- need to fetch to update rows later fetch cur_operator into l_cnt; -- 0/1 row in cursor as selected by prim_key if cur_account%notfound then o_result := -3; -- Account not found! elsif cur_operator%notfound then o_result := -4; -- Operator has not enough money else update pay_account set balance = (balance + p_sum) where current of cur_account; update pay_operator set total = (total - p_sum) where current of cur_operator; insert into pay_transaction ( id, account_id, operator_id, money, datetime ) values ( pay_transaction_seq.nextval, p_account_id, p_operator_id, p_sum, sysdate ); commit ; o_result := 1; -- transaction successfully finished! end if ; close cur_account; close cur_operator; end ; * This source code was highlighted with Source Code Highlighter .



  3. procedure PROCESS_TRANS(p_account_id in number, p_operator_id in number, p_sum in number, o_result out number) is l_cnt number; cursor cur_account is select id from pay_account where id = p_account_id for update of balance; cursor cur_operator is select id from pay_operator where id = p_operator_id and total >= p_sum for update of total; begin o_result := -1; -- tansaction begins select count (1) -- if such operator exist? into l_cnt from pay_operator opr where opr.id = p_operator_id; if (l_cnt != 1) then o_result := -2; -- Operator not found! return ; end if ; open cur_account; open cur_operator; fetch cur_account into l_cnt; -- need to fetch to update rows later fetch cur_operator into l_cnt; -- 0/1 row in cursor as selected by prim_key if cur_account%notfound then o_result := -3; -- Account not found! elsif cur_operator%notfound then o_result := -4; -- Operator has not enough money else update pay_account set balance = (balance + p_sum) where current of cur_account; update pay_operator set total = (total - p_sum) where current of cur_operator; insert into pay_transaction ( id, account_id, operator_id, money, datetime ) values ( pay_transaction_seq.nextval, p_account_id, p_operator_id, p_sum, sysdate ); commit ; o_result := 1; -- transaction successfully finished! end if ; close cur_account; close cur_operator; end ; * This source code was highlighted with Source Code Highlighter .



  4. procedure PROCESS_TRANS(p_account_id in number, p_operator_id in number, p_sum in number, o_result out number) is l_cnt number; cursor cur_account is select id from pay_account where id = p_account_id for update of balance; cursor cur_operator is select id from pay_operator where id = p_operator_id and total >= p_sum for update of total; begin o_result := -1; -- tansaction begins select count (1) -- if such operator exist? into l_cnt from pay_operator opr where opr.id = p_operator_id; if (l_cnt != 1) then o_result := -2; -- Operator not found! return ; end if ; open cur_account; open cur_operator; fetch cur_account into l_cnt; -- need to fetch to update rows later fetch cur_operator into l_cnt; -- 0/1 row in cursor as selected by prim_key if cur_account%notfound then o_result := -3; -- Account not found! elsif cur_operator%notfound then o_result := -4; -- Operator has not enough money else update pay_account set balance = (balance + p_sum) where current of cur_account; update pay_operator set total = (total - p_sum) where current of cur_operator; insert into pay_transaction ( id, account_id, operator_id, money, datetime ) values ( pay_transaction_seq.nextval, p_account_id, p_operator_id, p_sum, sysdate ); commit ; o_result := 1; -- transaction successfully finished! end if ; close cur_account; close cur_operator; end ; * This source code was highlighted with Source Code Highlighter .



  5. procedure PROCESS_TRANS(p_account_id in number, p_operator_id in number, p_sum in number, o_result out number) is l_cnt number; cursor cur_account is select id from pay_account where id = p_account_id for update of balance; cursor cur_operator is select id from pay_operator where id = p_operator_id and total >= p_sum for update of total; begin o_result := -1; -- tansaction begins select count (1) -- if such operator exist? into l_cnt from pay_operator opr where opr.id = p_operator_id; if (l_cnt != 1) then o_result := -2; -- Operator not found! return ; end if ; open cur_account; open cur_operator; fetch cur_account into l_cnt; -- need to fetch to update rows later fetch cur_operator into l_cnt; -- 0/1 row in cursor as selected by prim_key if cur_account%notfound then o_result := -3; -- Account not found! elsif cur_operator%notfound then o_result := -4; -- Operator has not enough money else update pay_account set balance = (balance + p_sum) where current of cur_account; update pay_operator set total = (total - p_sum) where current of cur_operator; insert into pay_transaction ( id, account_id, operator_id, money, datetime ) values ( pay_transaction_seq.nextval, p_account_id, p_operator_id, p_sum, sysdate ); commit ; o_result := 1; -- transaction successfully finished! end if ; close cur_account; close cur_operator; end ; * This source code was highlighted with Source Code Highlighter .



  6. procedure PROCESS_TRANS(p_account_id in number, p_operator_id in number, p_sum in number, o_result out number) is l_cnt number; cursor cur_account is select id from pay_account where id = p_account_id for update of balance; cursor cur_operator is select id from pay_operator where id = p_operator_id and total >= p_sum for update of total; begin o_result := -1; -- tansaction begins select count (1) -- if such operator exist? into l_cnt from pay_operator opr where opr.id = p_operator_id; if (l_cnt != 1) then o_result := -2; -- Operator not found! return ; end if ; open cur_account; open cur_operator; fetch cur_account into l_cnt; -- need to fetch to update rows later fetch cur_operator into l_cnt; -- 0/1 row in cursor as selected by prim_key if cur_account%notfound then o_result := -3; -- Account not found! elsif cur_operator%notfound then o_result := -4; -- Operator has not enough money else update pay_account set balance = (balance + p_sum) where current of cur_account; update pay_operator set total = (total - p_sum) where current of cur_operator; insert into pay_transaction ( id, account_id, operator_id, money, datetime ) values ( pay_transaction_seq.nextval, p_account_id, p_operator_id, p_sum, sysdate ); commit ; o_result := 1; -- transaction successfully finished! end if ; close cur_account; close cur_operator; end ; * This source code was highlighted with Source Code Highlighter .



  7. procedure PROCESS_TRANS(p_account_id in number, p_operator_id in number, p_sum in number, o_result out number) is l_cnt number; cursor cur_account is select id from pay_account where id = p_account_id for update of balance; cursor cur_operator is select id from pay_operator where id = p_operator_id and total >= p_sum for update of total; begin o_result := -1; -- tansaction begins select count (1) -- if such operator exist? into l_cnt from pay_operator opr where opr.id = p_operator_id; if (l_cnt != 1) then o_result := -2; -- Operator not found! return ; end if ; open cur_account; open cur_operator; fetch cur_account into l_cnt; -- need to fetch to update rows later fetch cur_operator into l_cnt; -- 0/1 row in cursor as selected by prim_key if cur_account%notfound then o_result := -3; -- Account not found! elsif cur_operator%notfound then o_result := -4; -- Operator has not enough money else update pay_account set balance = (balance + p_sum) where current of cur_account; update pay_operator set total = (total - p_sum) where current of cur_operator; insert into pay_transaction ( id, account_id, operator_id, money, datetime ) values ( pay_transaction_seq.nextval, p_account_id, p_operator_id, p_sum, sysdate ); commit ; o_result := 1; -- transaction successfully finished! end if ; close cur_account; close cur_operator; end ; * This source code was highlighted with Source Code Highlighter .



  8. procedure PROCESS_TRANS(p_account_id in number, p_operator_id in number, p_sum in number, o_result out number) is l_cnt number; cursor cur_account is select id from pay_account where id = p_account_id for update of balance; cursor cur_operator is select id from pay_operator where id = p_operator_id and total >= p_sum for update of total; begin o_result := -1; -- tansaction begins select count (1) -- if such operator exist? into l_cnt from pay_operator opr where opr.id = p_operator_id; if (l_cnt != 1) then o_result := -2; -- Operator not found! return ; end if ; open cur_account; open cur_operator; fetch cur_account into l_cnt; -- need to fetch to update rows later fetch cur_operator into l_cnt; -- 0/1 row in cursor as selected by prim_key if cur_account%notfound then o_result := -3; -- Account not found! elsif cur_operator%notfound then o_result := -4; -- Operator has not enough money else update pay_account set balance = (balance + p_sum) where current of cur_account; update pay_operator set total = (total - p_sum) where current of cur_operator; insert into pay_transaction ( id, account_id, operator_id, money, datetime ) values ( pay_transaction_seq.nextval, p_account_id, p_operator_id, p_sum, sysdate ); commit ; o_result := 1; -- transaction successfully finished! end if ; close cur_account; close cur_operator; end ; * This source code was highlighted with Source Code Highlighter .



  9. procedure PROCESS_TRANS(p_account_id in number, p_operator_id in number, p_sum in number, o_result out number) is l_cnt number; cursor cur_account is select id from pay_account where id = p_account_id for update of balance; cursor cur_operator is select id from pay_operator where id = p_operator_id and total >= p_sum for update of total; begin o_result := -1; -- tansaction begins select count (1) -- if such operator exist? into l_cnt from pay_operator opr where opr.id = p_operator_id; if (l_cnt != 1) then o_result := -2; -- Operator not found! return ; end if ; open cur_account; open cur_operator; fetch cur_account into l_cnt; -- need to fetch to update rows later fetch cur_operator into l_cnt; -- 0/1 row in cursor as selected by prim_key if cur_account%notfound then o_result := -3; -- Account not found! elsif cur_operator%notfound then o_result := -4; -- Operator has not enough money else update pay_account set balance = (balance + p_sum) where current of cur_account; update pay_operator set total = (total - p_sum) where current of cur_operator; insert into pay_transaction ( id, account_id, operator_id, money, datetime ) values ( pay_transaction_seq.nextval, p_account_id, p_operator_id, p_sum, sysdate ); commit ; o_result := 1; -- transaction successfully finished! end if ; close cur_account; close cur_operator; end ; * This source code was highlighted with Source Code Highlighter .



  10. procedure PROCESS_TRANS(p_account_id in number, p_operator_id in number, p_sum in number, o_result out number) is l_cnt number; cursor cur_account is select id from pay_account where id = p_account_id for update of balance; cursor cur_operator is select id from pay_operator where id = p_operator_id and total >= p_sum for update of total; begin o_result := -1; -- tansaction begins select count (1) -- if such operator exist? into l_cnt from pay_operator opr where opr.id = p_operator_id; if (l_cnt != 1) then o_result := -2; -- Operator not found! return ; end if ; open cur_account; open cur_operator; fetch cur_account into l_cnt; -- need to fetch to update rows later fetch cur_operator into l_cnt; -- 0/1 row in cursor as selected by prim_key if cur_account%notfound then o_result := -3; -- Account not found! elsif cur_operator%notfound then o_result := -4; -- Operator has not enough money else update pay_account set balance = (balance + p_sum) where current of cur_account; update pay_operator set total = (total - p_sum) where current of cur_operator; insert into pay_transaction ( id, account_id, operator_id, money, datetime ) values ( pay_transaction_seq.nextval, p_account_id, p_operator_id, p_sum, sysdate ); commit ; o_result := 1; -- transaction successfully finished! end if ; close cur_account; close cur_operator; end ; * This source code was highlighted with Source Code Highlighter .



  11. procedure PROCESS_TRANS(p_account_id in number, p_operator_id in number, p_sum in number, o_result out number) is l_cnt number; cursor cur_account is select id from pay_account where id = p_account_id for update of balance; cursor cur_operator is select id from pay_operator where id = p_operator_id and total >= p_sum for update of total; begin o_result := -1; -- tansaction begins select count (1) -- if such operator exist? into l_cnt from pay_operator opr where opr.id = p_operator_id; if (l_cnt != 1) then o_result := -2; -- Operator not found! return ; end if ; open cur_account; open cur_operator; fetch cur_account into l_cnt; -- need to fetch to update rows later fetch cur_operator into l_cnt; -- 0/1 row in cursor as selected by prim_key if cur_account%notfound then o_result := -3; -- Account not found! elsif cur_operator%notfound then o_result := -4; -- Operator has not enough money else update pay_account set balance = (balance + p_sum) where current of cur_account; update pay_operator set total = (total - p_sum) where current of cur_operator; insert into pay_transaction ( id, account_id, operator_id, money, datetime ) values ( pay_transaction_seq.nextval, p_account_id, p_operator_id, p_sum, sysdate ); commit ; o_result := 1; -- transaction successfully finished! end if ; close cur_account; close cur_operator; end ; * This source code was highlighted with Source Code Highlighter .



  12. procedure PROCESS_TRANS(p_account_id in number, p_operator_id in number, p_sum in number, o_result out number) is l_cnt number; cursor cur_account is select id from pay_account where id = p_account_id for update of balance; cursor cur_operator is select id from pay_operator where id = p_operator_id and total >= p_sum for update of total; begin o_result := -1; -- tansaction begins select count (1) -- if such operator exist? into l_cnt from pay_operator opr where opr.id = p_operator_id; if (l_cnt != 1) then o_result := -2; -- Operator not found! return ; end if ; open cur_account; open cur_operator; fetch cur_account into l_cnt; -- need to fetch to update rows later fetch cur_operator into l_cnt; -- 0/1 row in cursor as selected by prim_key if cur_account%notfound then o_result := -3; -- Account not found! elsif cur_operator%notfound then o_result := -4; -- Operator has not enough money else update pay_account set balance = (balance + p_sum) where current of cur_account; update pay_operator set total = (total - p_sum) where current of cur_operator; insert into pay_transaction ( id, account_id, operator_id, money, datetime ) values ( pay_transaction_seq.nextval, p_account_id, p_operator_id, p_sum, sysdate ); commit ; o_result := 1; -- transaction successfully finished! end if ; close cur_account; close cur_operator; end ; * This source code was highlighted with Source Code Highlighter .



  13. procedure PROCESS_TRANS(p_account_id in number, p_operator_id in number, p_sum in number, o_result out number) is l_cnt number; cursor cur_account is select id from pay_account where id = p_account_id for update of balance; cursor cur_operator is select id from pay_operator where id = p_operator_id and total >= p_sum for update of total; begin o_result := -1; -- tansaction begins select count (1) -- if such operator exist? into l_cnt from pay_operator opr where opr.id = p_operator_id; if (l_cnt != 1) then o_result := -2; -- Operator not found! return ; end if ; open cur_account; open cur_operator; fetch cur_account into l_cnt; -- need to fetch to update rows later fetch cur_operator into l_cnt; -- 0/1 row in cursor as selected by prim_key if cur_account%notfound then o_result := -3; -- Account not found! elsif cur_operator%notfound then o_result := -4; -- Operator has not enough money else update pay_account set balance = (balance + p_sum) where current of cur_account; update pay_operator set total = (total - p_sum) where current of cur_operator; insert into pay_transaction ( id, account_id, operator_id, money, datetime ) values ( pay_transaction_seq.nextval, p_account_id, p_operator_id, p_sum, sysdate ); commit ; o_result := 1; -- transaction successfully finished! end if ; close cur_account; close cur_operator; end ; * This source code was highlighted with Source Code Highlighter .



  14. procedure PROCESS_TRANS(p_account_id in number, p_operator_id in number, p_sum in number, o_result out number) is l_cnt number; cursor cur_account is select id from pay_account where id = p_account_id for update of balance; cursor cur_operator is select id from pay_operator where id = p_operator_id and total >= p_sum for update of total; begin o_result := -1; -- tansaction begins select count (1) -- if such operator exist? into l_cnt from pay_operator opr where opr.id = p_operator_id; if (l_cnt != 1) then o_result := -2; -- Operator not found! return ; end if ; open cur_account; open cur_operator; fetch cur_account into l_cnt; -- need to fetch to update rows later fetch cur_operator into l_cnt; -- 0/1 row in cursor as selected by prim_key if cur_account%notfound then o_result := -3; -- Account not found! elsif cur_operator%notfound then o_result := -4; -- Operator has not enough money else update pay_account set balance = (balance + p_sum) where current of cur_account; update pay_operator set total = (total - p_sum) where current of cur_operator; insert into pay_transaction ( id, account_id, operator_id, money, datetime ) values ( pay_transaction_seq.nextval, p_account_id, p_operator_id, p_sum, sysdate ); commit ; o_result := 1; -- transaction successfully finished! end if ; close cur_account; close cur_operator; end ; * This source code was highlighted with Source Code Highlighter .



  15. procedure PROCESS_TRANS(p_account_id in number, p_operator_id in number, p_sum in number, o_result out number) is l_cnt number; cursor cur_account is select id from pay_account where id = p_account_id for update of balance; cursor cur_operator is select id from pay_operator where id = p_operator_id and total >= p_sum for update of total; begin o_result := -1; -- tansaction begins select count (1) -- if such operator exist? into l_cnt from pay_operator opr where opr.id = p_operator_id; if (l_cnt != 1) then o_result := -2; -- Operator not found! return ; end if ; open cur_account; open cur_operator; fetch cur_account into l_cnt; -- need to fetch to update rows later fetch cur_operator into l_cnt; -- 0/1 row in cursor as selected by prim_key if cur_account%notfound then o_result := -3; -- Account not found! elsif cur_operator%notfound then o_result := -4; -- Operator has not enough money else update pay_account set balance = (balance + p_sum) where current of cur_account; update pay_operator set total = (total - p_sum) where current of cur_operator; insert into pay_transaction ( id, account_id, operator_id, money, datetime ) values ( pay_transaction_seq.nextval, p_account_id, p_operator_id, p_sum, sysdate ); commit ; o_result := 1; -- transaction successfully finished! end if ; close cur_account; close cur_operator; end ; * This source code was highlighted with Source Code Highlighter .



  16. procedure PROCESS_TRANS(p_account_id in number, p_operator_id in number, p_sum in number, o_result out number) is l_cnt number; cursor cur_account is select id from pay_account where id = p_account_id for update of balance; cursor cur_operator is select id from pay_operator where id = p_operator_id and total >= p_sum for update of total; begin o_result := -1; -- tansaction begins select count (1) -- if such operator exist? into l_cnt from pay_operator opr where opr.id = p_operator_id; if (l_cnt != 1) then o_result := -2; -- Operator not found! return ; end if ; open cur_account; open cur_operator; fetch cur_account into l_cnt; -- need to fetch to update rows later fetch cur_operator into l_cnt; -- 0/1 row in cursor as selected by prim_key if cur_account%notfound then o_result := -3; -- Account not found! elsif cur_operator%notfound then o_result := -4; -- Operator has not enough money else update pay_account set balance = (balance + p_sum) where current of cur_account; update pay_operator set total = (total - p_sum) where current of cur_operator; insert into pay_transaction ( id, account_id, operator_id, money, datetime ) values ( pay_transaction_seq.nextval, p_account_id, p_operator_id, p_sum, sysdate ); commit ; o_result := 1; -- transaction successfully finished! end if ; close cur_account; close cur_operator; end ; * This source code was highlighted with Source Code Highlighter .



  17. procedure PROCESS_TRANS(p_account_id in number, p_operator_id in number, p_sum in number, o_result out number) is l_cnt number; cursor cur_account is select id from pay_account where id = p_account_id for update of balance; cursor cur_operator is select id from pay_operator where id = p_operator_id and total >= p_sum for update of total; begin o_result := -1; -- tansaction begins select count (1) -- if such operator exist? into l_cnt from pay_operator opr where opr.id = p_operator_id; if (l_cnt != 1) then o_result := -2; -- Operator not found! return ; end if ; open cur_account; open cur_operator; fetch cur_account into l_cnt; -- need to fetch to update rows later fetch cur_operator into l_cnt; -- 0/1 row in cursor as selected by prim_key if cur_account%notfound then o_result := -3; -- Account not found! elsif cur_operator%notfound then o_result := -4; -- Operator has not enough money else update pay_account set balance = (balance + p_sum) where current of cur_account; update pay_operator set total = (total - p_sum) where current of cur_operator; insert into pay_transaction ( id, account_id, operator_id, money, datetime ) values ( pay_transaction_seq.nextval, p_account_id, p_operator_id, p_sum, sysdate ); commit ; o_result := 1; -- transaction successfully finished! end if ; close cur_account; close cur_operator; end ; * This source code was highlighted with Source Code Highlighter .



  18. procedure PROCESS_TRANS(p_account_id in number, p_operator_id in number, p_sum in number, o_result out number) is l_cnt number; cursor cur_account is select id from pay_account where id = p_account_id for update of balance; cursor cur_operator is select id from pay_operator where id = p_operator_id and total >= p_sum for update of total; begin o_result := -1; -- tansaction begins select count (1) -- if such operator exist? into l_cnt from pay_operator opr where opr.id = p_operator_id; if (l_cnt != 1) then o_result := -2; -- Operator not found! return ; end if ; open cur_account; open cur_operator; fetch cur_account into l_cnt; -- need to fetch to update rows later fetch cur_operator into l_cnt; -- 0/1 row in cursor as selected by prim_key if cur_account%notfound then o_result := -3; -- Account not found! elsif cur_operator%notfound then o_result := -4; -- Operator has not enough money else update pay_account set balance = (balance + p_sum) where current of cur_account; update pay_operator set total = (total - p_sum) where current of cur_operator; insert into pay_transaction ( id, account_id, operator_id, money, datetime ) values ( pay_transaction_seq.nextval, p_account_id, p_operator_id, p_sum, sysdate ); commit ; o_result := 1; -- transaction successfully finished! end if ; close cur_account; close cur_operator; end ; * This source code was highlighted with Source Code Highlighter .



  19. procedure PROCESS_TRANS(p_account_id in number, p_operator_id in number, p_sum in number, o_result out number) is l_cnt number; cursor cur_account is select id from pay_account where id = p_account_id for update of balance; cursor cur_operator is select id from pay_operator where id = p_operator_id and total >= p_sum for update of total; begin o_result := -1; -- tansaction begins select count (1) -- if such operator exist? into l_cnt from pay_operator opr where opr.id = p_operator_id; if (l_cnt != 1) then o_result := -2; -- Operator not found! return ; end if ; open cur_account; open cur_operator; fetch cur_account into l_cnt; -- need to fetch to update rows later fetch cur_operator into l_cnt; -- 0/1 row in cursor as selected by prim_key if cur_account%notfound then o_result := -3; -- Account not found! elsif cur_operator%notfound then o_result := -4; -- Operator has not enough money else update pay_account set balance = (balance + p_sum) where current of cur_account; update pay_operator set total = (total - p_sum) where current of cur_operator; insert into pay_transaction ( id, account_id, operator_id, money, datetime ) values ( pay_transaction_seq.nextval, p_account_id, p_operator_id, p_sum, sysdate ); commit ; o_result := 1; -- transaction successfully finished! end if ; close cur_account; close cur_operator; end ; * This source code was highlighted with Source Code Highlighter .



  20. procedure PROCESS_TRANS(p_account_id in number, p_operator_id in number, p_sum in number, o_result out number) is l_cnt number; cursor cur_account is select id from pay_account where id = p_account_id for update of balance; cursor cur_operator is select id from pay_operator where id = p_operator_id and total >= p_sum for update of total; begin o_result := -1; -- tansaction begins select count (1) -- if such operator exist? into l_cnt from pay_operator opr where opr.id = p_operator_id; if (l_cnt != 1) then o_result := -2; -- Operator not found! return ; end if ; open cur_account; open cur_operator; fetch cur_account into l_cnt; -- need to fetch to update rows later fetch cur_operator into l_cnt; -- 0/1 row in cursor as selected by prim_key if cur_account%notfound then o_result := -3; -- Account not found! elsif cur_operator%notfound then o_result := -4; -- Operator has not enough money else update pay_account set balance = (balance + p_sum) where current of cur_account; update pay_operator set total = (total - p_sum) where current of cur_operator; insert into pay_transaction ( id, account_id, operator_id, money, datetime ) values ( pay_transaction_seq.nextval, p_account_id, p_operator_id, p_sum, sysdate ); commit ; o_result := 1; -- transaction successfully finished! end if ; close cur_account; close cur_operator; end ; * This source code was highlighted with Source Code Highlighter .



  21. procedure PROCESS_TRANS(p_account_id in number, p_operator_id in number, p_sum in number, o_result out number) is l_cnt number; cursor cur_account is select id from pay_account where id = p_account_id for update of balance; cursor cur_operator is select id from pay_operator where id = p_operator_id and total >= p_sum for update of total; begin o_result := -1; -- tansaction begins select count (1) -- if such operator exist? into l_cnt from pay_operator opr where opr.id = p_operator_id; if (l_cnt != 1) then o_result := -2; -- Operator not found! return ; end if ; open cur_account; open cur_operator; fetch cur_account into l_cnt; -- need to fetch to update rows later fetch cur_operator into l_cnt; -- 0/1 row in cursor as selected by prim_key if cur_account%notfound then o_result := -3; -- Account not found! elsif cur_operator%notfound then o_result := -4; -- Operator has not enough money else update pay_account set balance = (balance + p_sum) where current of cur_account; update pay_operator set total = (total - p_sum) where current of cur_operator; insert into pay_transaction ( id, account_id, operator_id, money, datetime ) values ( pay_transaction_seq.nextval, p_account_id, p_operator_id, p_sum, sysdate ); commit ; o_result := 1; -- transaction successfully finished! end if ; close cur_account; close cur_operator; end ; * This source code was highlighted with Source Code Highlighter .



  22. procedure PROCESS_TRANS(p_account_id in number, p_operator_id in number, p_sum in number, o_result out number) is l_cnt number; cursor cur_account is select id from pay_account where id = p_account_id for update of balance; cursor cur_operator is select id from pay_operator where id = p_operator_id and total >= p_sum for update of total; begin o_result := -1; -- tansaction begins select count (1) -- if such operator exist? into l_cnt from pay_operator opr where opr.id = p_operator_id; if (l_cnt != 1) then o_result := -2; -- Operator not found! return ; end if ; open cur_account; open cur_operator; fetch cur_account into l_cnt; -- need to fetch to update rows later fetch cur_operator into l_cnt; -- 0/1 row in cursor as selected by prim_key if cur_account%notfound then o_result := -3; -- Account not found! elsif cur_operator%notfound then o_result := -4; -- Operator has not enough money else update pay_account set balance = (balance + p_sum) where current of cur_account; update pay_operator set total = (total - p_sum) where current of cur_operator; insert into pay_transaction ( id, account_id, operator_id, money, datetime ) values ( pay_transaction_seq.nextval, p_account_id, p_operator_id, p_sum, sysdate ); commit ; o_result := 1; -- transaction successfully finished! end if ; close cur_account; close cur_operator; end ; * This source code was highlighted with Source Code Highlighter .



  23. procedure PROCESS_TRANS(p_account_id in number, p_operator_id in number, p_sum in number, o_result out number) is l_cnt number; cursor cur_account is select id from pay_account where id = p_account_id for update of balance; cursor cur_operator is select id from pay_operator where id = p_operator_id and total >= p_sum for update of total; begin o_result := -1; -- tansaction begins select count (1) -- if such operator exist? into l_cnt from pay_operator opr where opr.id = p_operator_id; if (l_cnt != 1) then o_result := -2; -- Operator not found! return ; end if ; open cur_account; open cur_operator; fetch cur_account into l_cnt; -- need to fetch to update rows later fetch cur_operator into l_cnt; -- 0/1 row in cursor as selected by prim_key if cur_account%notfound then o_result := -3; -- Account not found! elsif cur_operator%notfound then o_result := -4; -- Operator has not enough money else update pay_account set balance = (balance + p_sum) where current of cur_account; update pay_operator set total = (total - p_sum) where current of cur_operator; insert into pay_transaction ( id, account_id, operator_id, money, datetime ) values ( pay_transaction_seq.nextval, p_account_id, p_operator_id, p_sum, sysdate ); commit ; o_result := 1; -- transaction successfully finished! end if ; close cur_account; close cur_operator; end ; * This source code was highlighted with Source Code Highlighter .



  24. procedure PROCESS_TRANS(p_account_id in number, p_operator_id in number, p_sum in number, o_result out number) is l_cnt number; cursor cur_account is select id from pay_account where id = p_account_id for update of balance; cursor cur_operator is select id from pay_operator where id = p_operator_id and total >= p_sum for update of total; begin o_result := -1; -- tansaction begins select count (1) -- if such operator exist? into l_cnt from pay_operator opr where opr.id = p_operator_id; if (l_cnt != 1) then o_result := -2; -- Operator not found! return ; end if ; open cur_account; open cur_operator; fetch cur_account into l_cnt; -- need to fetch to update rows later fetch cur_operator into l_cnt; -- 0/1 row in cursor as selected by prim_key if cur_account%notfound then o_result := -3; -- Account not found! elsif cur_operator%notfound then o_result := -4; -- Operator has not enough money else update pay_account set balance = (balance + p_sum) where current of cur_account; update pay_operator set total = (total - p_sum) where current of cur_operator; insert into pay_transaction ( id, account_id, operator_id, money, datetime ) values ( pay_transaction_seq.nextval, p_account_id, p_operator_id, p_sum, sysdate ); commit ; o_result := 1; -- transaction successfully finished! end if ; close cur_account; close cur_operator; end ; * This source code was highlighted with Source Code Highlighter .



  25. procedure PROCESS_TRANS(p_account_id in number, p_operator_id in number, p_sum in number, o_result out number) is l_cnt number; cursor cur_account is select id from pay_account where id = p_account_id for update of balance; cursor cur_operator is select id from pay_operator where id = p_operator_id and total >= p_sum for update of total; begin o_result := -1; -- tansaction begins select count (1) -- if such operator exist? into l_cnt from pay_operator opr where opr.id = p_operator_id; if (l_cnt != 1) then o_result := -2; -- Operator not found! return ; end if ; open cur_account; open cur_operator; fetch cur_account into l_cnt; -- need to fetch to update rows later fetch cur_operator into l_cnt; -- 0/1 row in cursor as selected by prim_key if cur_account%notfound then o_result := -3; -- Account not found! elsif cur_operator%notfound then o_result := -4; -- Operator has not enough money else update pay_account set balance = (balance + p_sum) where current of cur_account; update pay_operator set total = (total - p_sum) where current of cur_operator; insert into pay_transaction ( id, account_id, operator_id, money, datetime ) values ( pay_transaction_seq.nextval, p_account_id, p_operator_id, p_sum, sysdate ); commit ; o_result := 1; -- transaction successfully finished! end if ; close cur_account; close cur_operator; end ; * This source code was highlighted with Source Code Highlighter .



  26. procedure PROCESS_TRANS(p_account_id in number, p_operator_id in number, p_sum in number, o_result out number) is l_cnt number; cursor cur_account is select id from pay_account where id = p_account_id for update of balance; cursor cur_operator is select id from pay_operator where id = p_operator_id and total >= p_sum for update of total; begin o_result := -1; -- tansaction begins select count (1) -- if such operator exist? into l_cnt from pay_operator opr where opr.id = p_operator_id; if (l_cnt != 1) then o_result := -2; -- Operator not found! return ; end if ; open cur_account; open cur_operator; fetch cur_account into l_cnt; -- need to fetch to update rows later fetch cur_operator into l_cnt; -- 0/1 row in cursor as selected by prim_key if cur_account%notfound then o_result := -3; -- Account not found! elsif cur_operator%notfound then o_result := -4; -- Operator has not enough money else update pay_account set balance = (balance + p_sum) where current of cur_account; update pay_operator set total = (total - p_sum) where current of cur_operator; insert into pay_transaction ( id, account_id, operator_id, money, datetime ) values ( pay_transaction_seq.nextval, p_account_id, p_operator_id, p_sum, sysdate ); commit ; o_result := 1; -- transaction successfully finished! end if ; close cur_account; close cur_operator; end ; * This source code was highlighted with Source Code Highlighter .



  27. procedure PROCESS_TRANS(p_account_id in number, p_operator_id in number, p_sum in number, o_result out number) is l_cnt number; cursor cur_account is select id from pay_account where id = p_account_id for update of balance; cursor cur_operator is select id from pay_operator where id = p_operator_id and total >= p_sum for update of total; begin o_result := -1; -- tansaction begins select count (1) -- if such operator exist? into l_cnt from pay_operator opr where opr.id = p_operator_id; if (l_cnt != 1) then o_result := -2; -- Operator not found! return ; end if ; open cur_account; open cur_operator; fetch cur_account into l_cnt; -- need to fetch to update rows later fetch cur_operator into l_cnt; -- 0/1 row in cursor as selected by prim_key if cur_account%notfound then o_result := -3; -- Account not found! elsif cur_operator%notfound then o_result := -4; -- Operator has not enough money else update pay_account set balance = (balance + p_sum) where current of cur_account; update pay_operator set total = (total - p_sum) where current of cur_operator; insert into pay_transaction ( id, account_id, operator_id, money, datetime ) values ( pay_transaction_seq.nextval, p_account_id, p_operator_id, p_sum, sysdate ); commit ; o_result := 1; -- transaction successfully finished! end if ; close cur_account; close cur_operator; end ; * This source code was highlighted with Source Code Highlighter .



  28. procedure PROCESS_TRANS(p_account_id in number, p_operator_id in number, p_sum in number, o_result out number) is l_cnt number; cursor cur_account is select id from pay_account where id = p_account_id for update of balance; cursor cur_operator is select id from pay_operator where id = p_operator_id and total >= p_sum for update of total; begin o_result := -1; -- tansaction begins select count (1) -- if such operator exist? into l_cnt from pay_operator opr where opr.id = p_operator_id; if (l_cnt != 1) then o_result := -2; -- Operator not found! return ; end if ; open cur_account; open cur_operator; fetch cur_account into l_cnt; -- need to fetch to update rows later fetch cur_operator into l_cnt; -- 0/1 row in cursor as selected by prim_key if cur_account%notfound then o_result := -3; -- Account not found! elsif cur_operator%notfound then o_result := -4; -- Operator has not enough money else update pay_account set balance = (balance + p_sum) where current of cur_account; update pay_operator set total = (total - p_sum) where current of cur_operator; insert into pay_transaction ( id, account_id, operator_id, money, datetime ) values ( pay_transaction_seq.nextval, p_account_id, p_operator_id, p_sum, sysdate ); commit ; o_result := 1; -- transaction successfully finished! end if ; close cur_account; close cur_operator; end ; * This source code was highlighted with Source Code Highlighter .



  29. procedure PROCESS_TRANS(p_account_id in number, p_operator_id in number, p_sum in number, o_result out number) is l_cnt number; cursor cur_account is select id from pay_account where id = p_account_id for update of balance; cursor cur_operator is select id from pay_operator where id = p_operator_id and total >= p_sum for update of total; begin o_result := -1; -- tansaction begins select count (1) -- if such operator exist? into l_cnt from pay_operator opr where opr.id = p_operator_id; if (l_cnt != 1) then o_result := -2; -- Operator not found! return ; end if ; open cur_account; open cur_operator; fetch cur_account into l_cnt; -- need to fetch to update rows later fetch cur_operator into l_cnt; -- 0/1 row in cursor as selected by prim_key if cur_account%notfound then o_result := -3; -- Account not found! elsif cur_operator%notfound then o_result := -4; -- Operator has not enough money else update pay_account set balance = (balance + p_sum) where current of cur_account; update pay_operator set total = (total - p_sum) where current of cur_operator; insert into pay_transaction ( id, account_id, operator_id, money, datetime ) values ( pay_transaction_seq.nextval, p_account_id, p_operator_id, p_sum, sysdate ); commit ; o_result := 1; -- transaction successfully finished! end if ; close cur_account; close cur_operator; end ; * This source code was highlighted with Source Code Highlighter .



  30. procedure PROCESS_TRANS(p_account_id in number, p_operator_id in number, p_sum in number, o_result out number) is l_cnt number; cursor cur_account is select id from pay_account where id = p_account_id for update of balance; cursor cur_operator is select id from pay_operator where id = p_operator_id and total >= p_sum for update of total; begin o_result := -1; -- tansaction begins select count (1) -- if such operator exist? into l_cnt from pay_operator opr where opr.id = p_operator_id; if (l_cnt != 1) then o_result := -2; -- Operator not found! return ; end if ; open cur_account; open cur_operator; fetch cur_account into l_cnt; -- need to fetch to update rows later fetch cur_operator into l_cnt; -- 0/1 row in cursor as selected by prim_key if cur_account%notfound then o_result := -3; -- Account not found! elsif cur_operator%notfound then o_result := -4; -- Operator has not enough money else update pay_account set balance = (balance + p_sum) where current of cur_account; update pay_operator set total = (total - p_sum) where current of cur_operator; insert into pay_transaction ( id, account_id, operator_id, money, datetime ) values ( pay_transaction_seq.nextval, p_account_id, p_operator_id, p_sum, sysdate ); commit ; o_result := 1; -- transaction successfully finished! end if ; close cur_account; close cur_operator; end ; * This source code was highlighted with Source Code Highlighter .



  31. procedure PROCESS_TRANS(p_account_id in number, p_operator_id in number, p_sum in number, o_result out number) is l_cnt number; cursor cur_account is select id from pay_account where id = p_account_id for update of balance; cursor cur_operator is select id from pay_operator where id = p_operator_id and total >= p_sum for update of total; begin o_result := -1; -- tansaction begins select count (1) -- if such operator exist? into l_cnt from pay_operator opr where opr.id = p_operator_id; if (l_cnt != 1) then o_result := -2; -- Operator not found! return ; end if ; open cur_account; open cur_operator; fetch cur_account into l_cnt; -- need to fetch to update rows later fetch cur_operator into l_cnt; -- 0/1 row in cursor as selected by prim_key if cur_account%notfound then o_result := -3; -- Account not found! elsif cur_operator%notfound then o_result := -4; -- Operator has not enough money else update pay_account set balance = (balance + p_sum) where current of cur_account; update pay_operator set total = (total - p_sum) where current of cur_operator; insert into pay_transaction ( id, account_id, operator_id, money, datetime ) values ( pay_transaction_seq.nextval, p_account_id, p_operator_id, p_sum, sysdate ); commit ; o_result := 1; -- transaction successfully finished! end if ; close cur_account; close cur_operator; end ; * This source code was highlighted with Source Code Highlighter .



  32. procedure PROCESS_TRANS(p_account_id in number, p_operator_id in number, p_sum in number, o_result out number) is l_cnt number; cursor cur_account is select id from pay_account where id = p_account_id for update of balance; cursor cur_operator is select id from pay_operator where id = p_operator_id and total >= p_sum for update of total; begin o_result := -1; -- tansaction begins select count (1) -- if such operator exist? into l_cnt from pay_operator opr where opr.id = p_operator_id; if (l_cnt != 1) then o_result := -2; -- Operator not found! return ; end if ; open cur_account; open cur_operator; fetch cur_account into l_cnt; -- need to fetch to update rows later fetch cur_operator into l_cnt; -- 0/1 row in cursor as selected by prim_key if cur_account%notfound then o_result := -3; -- Account not found! elsif cur_operator%notfound then o_result := -4; -- Operator has not enough money else update pay_account set balance = (balance + p_sum) where current of cur_account; update pay_operator set total = (total - p_sum) where current of cur_operator; insert into pay_transaction ( id, account_id, operator_id, money, datetime ) values ( pay_transaction_seq.nextval, p_account_id, p_operator_id, p_sum, sysdate ); commit ; o_result := 1; -- transaction successfully finished! end if ; close cur_account; close cur_operator; end ; * This source code was highlighted with Source Code Highlighter .



  33. procedure PROCESS_TRANS(p_account_id in number, p_operator_id in number, p_sum in number, o_result out number) is l_cnt number; cursor cur_account is select id from pay_account where id = p_account_id for update of balance; cursor cur_operator is select id from pay_operator where id = p_operator_id and total >= p_sum for update of total; begin o_result := -1; -- tansaction begins select count (1) -- if such operator exist? into l_cnt from pay_operator opr where opr.id = p_operator_id; if (l_cnt != 1) then o_result := -2; -- Operator not found! return ; end if ; open cur_account; open cur_operator; fetch cur_account into l_cnt; -- need to fetch to update rows later fetch cur_operator into l_cnt; -- 0/1 row in cursor as selected by prim_key if cur_account%notfound then o_result := -3; -- Account not found! elsif cur_operator%notfound then o_result := -4; -- Operator has not enough money else update pay_account set balance = (balance + p_sum) where current of cur_account; update pay_operator set total = (total - p_sum) where current of cur_operator; insert into pay_transaction ( id, account_id, operator_id, money, datetime ) values ( pay_transaction_seq.nextval, p_account_id, p_operator_id, p_sum, sysdate ); commit ; o_result := 1; -- transaction successfully finished! end if ; close cur_account; close cur_operator; end ; * This source code was highlighted with Source Code Highlighter .



  34. procedure PROCESS_TRANS(p_account_id in number, p_operator_id in number, p_sum in number, o_result out number) is l_cnt number; cursor cur_account is select id from pay_account where id = p_account_id for update of balance; cursor cur_operator is select id from pay_operator where id = p_operator_id and total >= p_sum for update of total; begin o_result := -1; -- tansaction begins select count (1) -- if such operator exist? into l_cnt from pay_operator opr where opr.id = p_operator_id; if (l_cnt != 1) then o_result := -2; -- Operator not found! return ; end if ; open cur_account; open cur_operator; fetch cur_account into l_cnt; -- need to fetch to update rows later fetch cur_operator into l_cnt; -- 0/1 row in cursor as selected by prim_key if cur_account%notfound then o_result := -3; -- Account not found! elsif cur_operator%notfound then o_result := -4; -- Operator has not enough money else update pay_account set balance = (balance + p_sum) where current of cur_account; update pay_operator set total = (total - p_sum) where current of cur_operator; insert into pay_transaction ( id, account_id, operator_id, money, datetime ) values ( pay_transaction_seq.nextval, p_account_id, p_operator_id, p_sum, sysdate ); commit ; o_result := 1; -- transaction successfully finished! end if ; close cur_account; close cur_operator; end ; * This source code was highlighted with Source Code Highlighter .



  35. procedure PROCESS_TRANS(p_account_id in number, p_operator_id in number, p_sum in number, o_result out number) is l_cnt number; cursor cur_account is select id from pay_account where id = p_account_id for update of balance; cursor cur_operator is select id from pay_operator where id = p_operator_id and total >= p_sum for update of total; begin o_result := -1; -- tansaction begins select count (1) -- if such operator exist? into l_cnt from pay_operator opr where opr.id = p_operator_id; if (l_cnt != 1) then o_result := -2; -- Operator not found! return ; end if ; open cur_account; open cur_operator; fetch cur_account into l_cnt; -- need to fetch to update rows later fetch cur_operator into l_cnt; -- 0/1 row in cursor as selected by prim_key if cur_account%notfound then o_result := -3; -- Account not found! elsif cur_operator%notfound then o_result := -4; -- Operator has not enough money else update pay_account set balance = (balance + p_sum) where current of cur_account; update pay_operator set total = (total - p_sum) where current of cur_operator; insert into pay_transaction ( id, account_id, operator_id, money, datetime ) values ( pay_transaction_seq.nextval, p_account_id, p_operator_id, p_sum, sysdate ); commit ; o_result := 1; -- transaction successfully finished! end if ; close cur_account; close cur_operator; end ; * This source code was highlighted with Source Code Highlighter .



  36. procedure PROCESS_TRANS(p_account_id in number, p_operator_id in number, p_sum in number, o_result out number) is l_cnt number; cursor cur_account is select id from pay_account where id = p_account_id for update of balance; cursor cur_operator is select id from pay_operator where id = p_operator_id and total >= p_sum for update of total; begin o_result := -1; -- tansaction begins select count (1) -- if such operator exist? into l_cnt from pay_operator opr where opr.id = p_operator_id; if (l_cnt != 1) then o_result := -2; -- Operator not found! return ; end if ; open cur_account; open cur_operator; fetch cur_account into l_cnt; -- need to fetch to update rows later fetch cur_operator into l_cnt; -- 0/1 row in cursor as selected by prim_key if cur_account%notfound then o_result := -3; -- Account not found! elsif cur_operator%notfound then o_result := -4; -- Operator has not enough money else update pay_account set balance = (balance + p_sum) where current of cur_account; update pay_operator set total = (total - p_sum) where current of cur_operator; insert into pay_transaction ( id, account_id, operator_id, money, datetime ) values ( pay_transaction_seq.nextval, p_account_id, p_operator_id, p_sum, sysdate ); commit ; o_result := 1; -- transaction successfully finished! end if ; close cur_account; close cur_operator; end ; * This source code was highlighted with Source Code Highlighter .



  37. procedure PROCESS_TRANS(p_account_id in number, p_operator_id in number, p_sum in number, o_result out number) is l_cnt number; cursor cur_account is select id from pay_account where id = p_account_id for update of balance; cursor cur_operator is select id from pay_operator where id = p_operator_id and total >= p_sum for update of total; begin o_result := -1; -- tansaction begins select count (1) -- if such operator exist? into l_cnt from pay_operator opr where opr.id = p_operator_id; if (l_cnt != 1) then o_result := -2; -- Operator not found! return ; end if ; open cur_account; open cur_operator; fetch cur_account into l_cnt; -- need to fetch to update rows later fetch cur_operator into l_cnt; -- 0/1 row in cursor as selected by prim_key if cur_account%notfound then o_result := -3; -- Account not found! elsif cur_operator%notfound then o_result := -4; -- Operator has not enough money else update pay_account set balance = (balance + p_sum) where current of cur_account; update pay_operator set total = (total - p_sum) where current of cur_operator; insert into pay_transaction ( id, account_id, operator_id, money, datetime ) values ( pay_transaction_seq.nextval, p_account_id, p_operator_id, p_sum, sysdate ); commit ; o_result := 1; -- transaction successfully finished! end if ; close cur_account; close cur_operator; end ; * This source code was highlighted with Source Code Highlighter .



  38. procedure PROCESS_TRANS(p_account_id in number, p_operator_id in number, p_sum in number, o_result out number) is l_cnt number; cursor cur_account is select id from pay_account where id = p_account_id for update of balance; cursor cur_operator is select id from pay_operator where id = p_operator_id and total >= p_sum for update of total; begin o_result := -1; -- tansaction begins select count (1) -- if such operator exist? into l_cnt from pay_operator opr where opr.id = p_operator_id; if (l_cnt != 1) then o_result := -2; -- Operator not found! return ; end if ; open cur_account; open cur_operator; fetch cur_account into l_cnt; -- need to fetch to update rows later fetch cur_operator into l_cnt; -- 0/1 row in cursor as selected by prim_key if cur_account%notfound then o_result := -3; -- Account not found! elsif cur_operator%notfound then o_result := -4; -- Operator has not enough money else update pay_account set balance = (balance + p_sum) where current of cur_account; update pay_operator set total = (total - p_sum) where current of cur_operator; insert into pay_transaction ( id, account_id, operator_id, money, datetime ) values ( pay_transaction_seq.nextval, p_account_id, p_operator_id, p_sum, sysdate ); commit ; o_result := 1; -- transaction successfully finished! end if ; close cur_account; close cur_operator; end ; * This source code was highlighted with Source Code Highlighter .



  39. procedure PROCESS_TRANS(p_account_id in number, p_operator_id in number, p_sum in number, o_result out number) is l_cnt number; cursor cur_account is select id from pay_account where id = p_account_id for update of balance; cursor cur_operator is select id from pay_operator where id = p_operator_id and total >= p_sum for update of total; begin o_result := -1; -- tansaction begins select count (1) -- if such operator exist? into l_cnt from pay_operator opr where opr.id = p_operator_id; if (l_cnt != 1) then o_result := -2; -- Operator not found! return ; end if ; open cur_account; open cur_operator; fetch cur_account into l_cnt; -- need to fetch to update rows later fetch cur_operator into l_cnt; -- 0/1 row in cursor as selected by prim_key if cur_account%notfound then o_result := -3; -- Account not found! elsif cur_operator%notfound then o_result := -4; -- Operator has not enough money else update pay_account set balance = (balance + p_sum) where current of cur_account; update pay_operator set total = (total - p_sum) where current of cur_operator; insert into pay_transaction ( id, account_id, operator_id, money, datetime ) values ( pay_transaction_seq.nextval, p_account_id, p_operator_id, p_sum, sysdate ); commit ; o_result := 1; -- transaction successfully finished! end if ; close cur_account; close cur_operator; end ; * This source code was highlighted with Source Code Highlighter .



  40. procedure PROCESS_TRANS(p_account_id in number, p_operator_id in number, p_sum in number, o_result out number) is l_cnt number; cursor cur_account is select id from pay_account where id = p_account_id for update of balance; cursor cur_operator is select id from pay_operator where id = p_operator_id and total >= p_sum for update of total; begin o_result := -1; -- tansaction begins select count (1) -- if such operator exist? into l_cnt from pay_operator opr where opr.id = p_operator_id; if (l_cnt != 1) then o_result := -2; -- Operator not found! return ; end if ; open cur_account; open cur_operator; fetch cur_account into l_cnt; -- need to fetch to update rows later fetch cur_operator into l_cnt; -- 0/1 row in cursor as selected by prim_key if cur_account%notfound then o_result := -3; -- Account not found! elsif cur_operator%notfound then o_result := -4; -- Operator has not enough money else update pay_account set balance = (balance + p_sum) where current of cur_account; update pay_operator set total = (total - p_sum) where current of cur_operator; insert into pay_transaction ( id, account_id, operator_id, money, datetime ) values ( pay_transaction_seq.nextval, p_account_id, p_operator_id, p_sum, sysdate ); commit ; o_result := 1; -- transaction successfully finished! end if ; close cur_account; close cur_operator; end ; * This source code was highlighted with Source Code Highlighter .



  41. procedure PROCESS_TRANS(p_account_id in number, p_operator_id in number, p_sum in number, o_result out number) is l_cnt number; cursor cur_account is select id from pay_account where id = p_account_id for update of balance; cursor cur_operator is select id from pay_operator where id = p_operator_id and total >= p_sum for update of total; begin o_result := -1; -- tansaction begins select count (1) -- if such operator exist? into l_cnt from pay_operator opr where opr.id = p_operator_id; if (l_cnt != 1) then o_result := -2; -- Operator not found! return ; end if ; open cur_account; open cur_operator; fetch cur_account into l_cnt; -- need to fetch to update rows later fetch cur_operator into l_cnt; -- 0/1 row in cursor as selected by prim_key if cur_account%notfound then o_result := -3; -- Account not found! elsif cur_operator%notfound then o_result := -4; -- Operator has not enough money else update pay_account set balance = (balance + p_sum) where current of cur_account; update pay_operator set total = (total - p_sum) where current of cur_operator; insert into pay_transaction ( id, account_id, operator_id, money, datetime ) values ( pay_transaction_seq.nextval, p_account_id, p_operator_id, p_sum, sysdate ); commit ; o_result := 1; -- transaction successfully finished! end if ; close cur_account; close cur_operator; end ; * This source code was highlighted with Source Code Highlighter .



  42. procedure PROCESS_TRANS(p_account_id in number, p_operator_id in number, p_sum in number, o_result out number) is l_cnt number; cursor cur_account is select id from pay_account where id = p_account_id for update of balance; cursor cur_operator is select id from pay_operator where id = p_operator_id and total >= p_sum for update of total; begin o_result := -1; -- tansaction begins select count (1) -- if such operator exist? into l_cnt from pay_operator opr where opr.id = p_operator_id; if (l_cnt != 1) then o_result := -2; -- Operator not found! return ; end if ; open cur_account; open cur_operator; fetch cur_account into l_cnt; -- need to fetch to update rows later fetch cur_operator into l_cnt; -- 0/1 row in cursor as selected by prim_key if cur_account%notfound then o_result := -3; -- Account not found! elsif cur_operator%notfound then o_result := -4; -- Operator has not enough money else update pay_account set balance = (balance + p_sum) where current of cur_account; update pay_operator set total = (total - p_sum) where current of cur_operator; insert into pay_transaction ( id, account_id, operator_id, money, datetime ) values ( pay_transaction_seq.nextval, p_account_id, p_operator_id, p_sum, sysdate ); commit ; o_result := 1; -- transaction successfully finished! end if ; close cur_account; close cur_operator; end ; * This source code was highlighted with Source Code Highlighter .



  43. procedure PROCESS_TRANS(p_account_id in number, p_operator_id in number, p_sum in number, o_result out number) is l_cnt number; cursor cur_account is select id from pay_account where id = p_account_id for update of balance; cursor cur_operator is select id from pay_operator where id = p_operator_id and total >= p_sum for update of total; begin o_result := -1; -- tansaction begins select count (1) -- if such operator exist? into l_cnt from pay_operator opr where opr.id = p_operator_id; if (l_cnt != 1) then o_result := -2; -- Operator not found! return ; end if ; open cur_account; open cur_operator; fetch cur_account into l_cnt; -- need to fetch to update rows later fetch cur_operator into l_cnt; -- 0/1 row in cursor as selected by prim_key if cur_account%notfound then o_result := -3; -- Account not found! elsif cur_operator%notfound then o_result := -4; -- Operator has not enough money else update pay_account set balance = (balance + p_sum) where current of cur_account; update pay_operator set total = (total - p_sum) where current of cur_operator; insert into pay_transaction ( id, account_id, operator_id, money, datetime ) values ( pay_transaction_seq.nextval, p_account_id, p_operator_id, p_sum, sysdate ); commit ; o_result := 1; -- transaction successfully finished! end if ; close cur_account; close cur_operator; end ; * This source code was highlighted with Source Code Highlighter .



  44. procedure PROCESS_TRANS(p_account_id in number, p_operator_id in number, p_sum in number, o_result out number) is l_cnt number; cursor cur_account is select id from pay_account where id = p_account_id for update of balance; cursor cur_operator is select id from pay_operator where id = p_operator_id and total >= p_sum for update of total; begin o_result := -1; -- tansaction begins select count (1) -- if such operator exist? into l_cnt from pay_operator opr where opr.id = p_operator_id; if (l_cnt != 1) then o_result := -2; -- Operator not found! return ; end if ; open cur_account; open cur_operator; fetch cur_account into l_cnt; -- need to fetch to update rows later fetch cur_operator into l_cnt; -- 0/1 row in cursor as selected by prim_key if cur_account%notfound then o_result := -3; -- Account not found! elsif cur_operator%notfound then o_result := -4; -- Operator has not enough money else update pay_account set balance = (balance + p_sum) where current of cur_account; update pay_operator set total = (total - p_sum) where current of cur_operator; insert into pay_transaction ( id, account_id, operator_id, money, datetime ) values ( pay_transaction_seq.nextval, p_account_id, p_operator_id, p_sum, sysdate ); commit ; o_result := 1; -- transaction successfully finished! end if ; close cur_account; close cur_operator; end ; * This source code was highlighted with Source Code Highlighter .



  45. procedure PROCESS_TRANS(p_account_id in number, p_operator_id in number, p_sum in number, o_result out number) is l_cnt number; cursor cur_account is select id from pay_account where id = p_account_id for update of balance; cursor cur_operator is select id from pay_operator where id = p_operator_id and total >= p_sum for update of total; begin o_result := -1; -- tansaction begins select count (1) -- if such operator exist? into l_cnt from pay_operator opr where opr.id = p_operator_id; if (l_cnt != 1) then o_result := -2; -- Operator not found! return ; end if ; open cur_account; open cur_operator; fetch cur_account into l_cnt; -- need to fetch to update rows later fetch cur_operator into l_cnt; -- 0/1 row in cursor as selected by prim_key if cur_account%notfound then o_result := -3; -- Account not found! elsif cur_operator%notfound then o_result := -4; -- Operator has not enough money else update pay_account set balance = (balance + p_sum) where current of cur_account; update pay_operator set total = (total - p_sum) where current of cur_operator; insert into pay_transaction ( id, account_id, operator_id, money, datetime ) values ( pay_transaction_seq.nextval, p_account_id, p_operator_id, p_sum, sysdate ); commit ; o_result := 1; -- transaction successfully finished! end if ; close cur_account; close cur_operator; end ; * This source code was highlighted with Source Code Highlighter .



  46. procedure PROCESS_TRANS(p_account_id in number, p_operator_id in number, p_sum in number, o_result out number) is l_cnt number; cursor cur_account is select id from pay_account where id = p_account_id for update of balance; cursor cur_operator is select id from pay_operator where id = p_operator_id and total >= p_sum for update of total; begin o_result := -1; -- tansaction begins select count (1) -- if such operator exist? into l_cnt from pay_operator opr where opr.id = p_operator_id; if (l_cnt != 1) then o_result := -2; -- Operator not found! return ; end if ; open cur_account; open cur_operator; fetch cur_account into l_cnt; -- need to fetch to update rows later fetch cur_operator into l_cnt; -- 0/1 row in cursor as selected by prim_key if cur_account%notfound then o_result := -3; -- Account not found! elsif cur_operator%notfound then o_result := -4; -- Operator has not enough money else update pay_account set balance = (balance + p_sum) where current of cur_account; update pay_operator set total = (total - p_sum) where current of cur_operator; insert into pay_transaction ( id, account_id, operator_id, money, datetime ) values ( pay_transaction_seq.nextval, p_account_id, p_operator_id, p_sum, sysdate ); commit ; o_result := 1; -- transaction successfully finished! end if ; close cur_account; close cur_operator; end ; * This source code was highlighted with Source Code Highlighter .



  47. procedure PROCESS_TRANS(p_account_id in number, p_operator_id in number, p_sum in number, o_result out number) is l_cnt number; cursor cur_account is select id from pay_account where id = p_account_id for update of balance; cursor cur_operator is select id from pay_operator where id = p_operator_id and total >= p_sum for update of total; begin o_result := -1; -- tansaction begins select count (1) -- if such operator exist? into l_cnt from pay_operator opr where opr.id = p_operator_id; if (l_cnt != 1) then o_result := -2; -- Operator not found! return ; end if ; open cur_account; open cur_operator; fetch cur_account into l_cnt; -- need to fetch to update rows later fetch cur_operator into l_cnt; -- 0/1 row in cursor as selected by prim_key if cur_account%notfound then o_result := -3; -- Account not found! elsif cur_operator%notfound then o_result := -4; -- Operator has not enough money else update pay_account set balance = (balance + p_sum) where current of cur_account; update pay_operator set total = (total - p_sum) where current of cur_operator; insert into pay_transaction ( id, account_id, operator_id, money, datetime ) values ( pay_transaction_seq.nextval, p_account_id, p_operator_id, p_sum, sysdate ); commit ; o_result := 1; -- transaction successfully finished! end if ; close cur_account; close cur_operator; end ; * This source code was highlighted with Source Code Highlighter .



  48. procedure PROCESS_TRANS(p_account_id in number, p_operator_id in number, p_sum in number, o_result out number) is l_cnt number; cursor cur_account is select id from pay_account where id = p_account_id for update of balance; cursor cur_operator is select id from pay_operator where id = p_operator_id and total >= p_sum for update of total; begin o_result := -1; -- tansaction begins select count (1) -- if such operator exist? into l_cnt from pay_operator opr where opr.id = p_operator_id; if (l_cnt != 1) then o_result := -2; -- Operator not found! return ; end if ; open cur_account; open cur_operator; fetch cur_account into l_cnt; -- need to fetch to update rows later fetch cur_operator into l_cnt; -- 0/1 row in cursor as selected by prim_key if cur_account%notfound then o_result := -3; -- Account not found! elsif cur_operator%notfound then o_result := -4; -- Operator has not enough money else update pay_account set balance = (balance + p_sum) where current of cur_account; update pay_operator set total = (total - p_sum) where current of cur_operator; insert into pay_transaction ( id, account_id, operator_id, money, datetime ) values ( pay_transaction_seq.nextval, p_account_id, p_operator_id, p_sum, sysdate ); commit ; o_result := 1; -- transaction successfully finished! end if ; close cur_account; close cur_operator; end ; * This source code was highlighted with Source Code Highlighter .



  49. procedure PROCESS_TRANS(p_account_id in number, p_operator_id in number, p_sum in number, o_result out number) is l_cnt number; cursor cur_account is select id from pay_account where id = p_account_id for update of balance; cursor cur_operator is select id from pay_operator where id = p_operator_id and total >= p_sum for update of total; begin o_result := -1; -- tansaction begins select count (1) -- if such operator exist? into l_cnt from pay_operator opr where opr.id = p_operator_id; if (l_cnt != 1) then o_result := -2; -- Operator not found! return ; end if ; open cur_account; open cur_operator; fetch cur_account into l_cnt; -- need to fetch to update rows later fetch cur_operator into l_cnt; -- 0/1 row in cursor as selected by prim_key if cur_account%notfound then o_result := -3; -- Account not found! elsif cur_operator%notfound then o_result := -4; -- Operator has not enough money else update pay_account set balance = (balance + p_sum) where current of cur_account; update pay_operator set total = (total - p_sum) where current of cur_operator; insert into pay_transaction ( id, account_id, operator_id, money, datetime ) values ( pay_transaction_seq.nextval, p_account_id, p_operator_id, p_sum, sysdate ); commit ; o_result := 1; -- transaction successfully finished! end if ; close cur_account; close cur_operator; end ; * This source code was highlighted with Source Code Highlighter .



  50. procedure PROCESS_TRANS(p_account_id in number, p_operator_id in number, p_sum in number, o_result out number) is l_cnt number; cursor cur_account is select id from pay_account where id = p_account_id for update of balance; cursor cur_operator is select id from pay_operator where id = p_operator_id and total >= p_sum for update of total; begin o_result := -1; -- tansaction begins select count (1) -- if such operator exist? into l_cnt from pay_operator opr where opr.id = p_operator_id; if (l_cnt != 1) then o_result := -2; -- Operator not found! return ; end if ; open cur_account; open cur_operator; fetch cur_account into l_cnt; -- need to fetch to update rows later fetch cur_operator into l_cnt; -- 0/1 row in cursor as selected by prim_key if cur_account%notfound then o_result := -3; -- Account not found! elsif cur_operator%notfound then o_result := -4; -- Operator has not enough money else update pay_account set balance = (balance + p_sum) where current of cur_account; update pay_operator set total = (total - p_sum) where current of cur_operator; insert into pay_transaction ( id, account_id, operator_id, money, datetime ) values ( pay_transaction_seq.nextval, p_account_id, p_operator_id, p_sum, sysdate ); commit ; o_result := 1; -- transaction successfully finished! end if ; close cur_account; close cur_operator; end ; * This source code was highlighted with Source Code Highlighter .



  51. procedure PROCESS_TRANS(p_account_id in number, p_operator_id in number, p_sum in number, o_result out number) is l_cnt number; cursor cur_account is select id from pay_account where id = p_account_id for update of balance; cursor cur_operator is select id from pay_operator where id = p_operator_id and total >= p_sum for update of total; begin o_result := -1; -- tansaction begins select count (1) -- if such operator exist? into l_cnt from pay_operator opr where opr.id = p_operator_id; if (l_cnt != 1) then o_result := -2; -- Operator not found! return ; end if ; open cur_account; open cur_operator; fetch cur_account into l_cnt; -- need to fetch to update rows later fetch cur_operator into l_cnt; -- 0/1 row in cursor as selected by prim_key if cur_account%notfound then o_result := -3; -- Account not found! elsif cur_operator%notfound then o_result := -4; -- Operator has not enough money else update pay_account set balance = (balance + p_sum) where current of cur_account; update pay_operator set total = (total - p_sum) where current of cur_operator; insert into pay_transaction ( id, account_id, operator_id, money, datetime ) values ( pay_transaction_seq.nextval, p_account_id, p_operator_id, p_sum, sysdate ); commit ; o_result := 1; -- transaction successfully finished! end if ; close cur_account; close cur_operator; end ; * This source code was highlighted with Source Code Highlighter .



  52. procedure PROCESS_TRANS(p_account_id in number, p_operator_id in number, p_sum in number, o_result out number) is l_cnt number; cursor cur_account is select id from pay_account where id = p_account_id for update of balance; cursor cur_operator is select id from pay_operator where id = p_operator_id and total >= p_sum for update of total; begin o_result := -1; -- tansaction begins select count (1) -- if such operator exist? into l_cnt from pay_operator opr where opr.id = p_operator_id; if (l_cnt != 1) then o_result := -2; -- Operator not found! return ; end if ; open cur_account; open cur_operator; fetch cur_account into l_cnt; -- need to fetch to update rows later fetch cur_operator into l_cnt; -- 0/1 row in cursor as selected by prim_key if cur_account%notfound then o_result := -3; -- Account not found! elsif cur_operator%notfound then o_result := -4; -- Operator has not enough money else update pay_account set balance = (balance + p_sum) where current of cur_account; update pay_operator set total = (total - p_sum) where current of cur_operator; insert into pay_transaction ( id, account_id, operator_id, money, datetime ) values ( pay_transaction_seq.nextval, p_account_id, p_operator_id, p_sum, sysdate ); commit ; o_result := 1; -- transaction successfully finished! end if ; close cur_account; close cur_operator; end ; * This source code was highlighted with Source Code Highlighter .



  53. procedure PROCESS_TRANS(p_account_id in number, p_operator_id in number, p_sum in number, o_result out number) is l_cnt number; cursor cur_account is select id from pay_account where id = p_account_id for update of balance; cursor cur_operator is select id from pay_operator where id = p_operator_id and total >= p_sum for update of total; begin o_result := -1; -- tansaction begins select count (1) -- if such operator exist? into l_cnt from pay_operator opr where opr.id = p_operator_id; if (l_cnt != 1) then o_result := -2; -- Operator not found! return ; end if ; open cur_account; open cur_operator; fetch cur_account into l_cnt; -- need to fetch to update rows later fetch cur_operator into l_cnt; -- 0/1 row in cursor as selected by prim_key if cur_account%notfound then o_result := -3; -- Account not found! elsif cur_operator%notfound then o_result := -4; -- Operator has not enough money else update pay_account set balance = (balance + p_sum) where current of cur_account; update pay_operator set total = (total - p_sum) where current of cur_operator; insert into pay_transaction ( id, account_id, operator_id, money, datetime ) values ( pay_transaction_seq.nextval, p_account_id, p_operator_id, p_sum, sysdate ); commit ; o_result := 1; -- transaction successfully finished! end if ; close cur_account; close cur_operator; end ; * This source code was highlighted with Source Code Highlighter .



  54. procedure PROCESS_TRANS(p_account_id in number, p_operator_id in number, p_sum in number, o_result out number) is l_cnt number; cursor cur_account is select id from pay_account where id = p_account_id for update of balance; cursor cur_operator is select id from pay_operator where id = p_operator_id and total >= p_sum for update of total; begin o_result := -1; -- tansaction begins select count (1) -- if such operator exist? into l_cnt from pay_operator opr where opr.id = p_operator_id; if (l_cnt != 1) then o_result := -2; -- Operator not found! return ; end if ; open cur_account; open cur_operator; fetch cur_account into l_cnt; -- need to fetch to update rows later fetch cur_operator into l_cnt; -- 0/1 row in cursor as selected by prim_key if cur_account%notfound then o_result := -3; -- Account not found! elsif cur_operator%notfound then o_result := -4; -- Operator has not enough money else update pay_account set balance = (balance + p_sum) where current of cur_account; update pay_operator set total = (total - p_sum) where current of cur_operator; insert into pay_transaction ( id, account_id, operator_id, money, datetime ) values ( pay_transaction_seq.nextval, p_account_id, p_operator_id, p_sum, sysdate ); commit ; o_result := 1; -- transaction successfully finished! end if ; close cur_account; close cur_operator; end ; * This source code was highlighted with Source Code Highlighter .



  55. procedure PROCESS_TRANS(p_account_id in number, p_operator_id in number, p_sum in number, o_result out number) is l_cnt number; cursor cur_account is select id from pay_account where id = p_account_id for update of balance; cursor cur_operator is select id from pay_operator where id = p_operator_id and total >= p_sum for update of total; begin o_result := -1; -- tansaction begins select count (1) -- if such operator exist? into l_cnt from pay_operator opr where opr.id = p_operator_id; if (l_cnt != 1) then o_result := -2; -- Operator not found! return ; end if ; open cur_account; open cur_operator; fetch cur_account into l_cnt; -- need to fetch to update rows later fetch cur_operator into l_cnt; -- 0/1 row in cursor as selected by prim_key if cur_account%notfound then o_result := -3; -- Account not found! elsif cur_operator%notfound then o_result := -4; -- Operator has not enough money else update pay_account set balance = (balance + p_sum) where current of cur_account; update pay_operator set total = (total - p_sum) where current of cur_operator; insert into pay_transaction ( id, account_id, operator_id, money, datetime ) values ( pay_transaction_seq.nextval, p_account_id, p_operator_id, p_sum, sysdate ); commit ; o_result := 1; -- transaction successfully finished! end if ; close cur_account; close cur_operator; end ; * This source code was highlighted with Source Code Highlighter .



  56. procedure PROCESS_TRANS(p_account_id in number, p_operator_id in number, p_sum in number, o_result out number) is l_cnt number; cursor cur_account is select id from pay_account where id = p_account_id for update of balance; cursor cur_operator is select id from pay_operator where id = p_operator_id and total >= p_sum for update of total; begin o_result := -1; -- tansaction begins select count (1) -- if such operator exist? into l_cnt from pay_operator opr where opr.id = p_operator_id; if (l_cnt != 1) then o_result := -2; -- Operator not found! return ; end if ; open cur_account; open cur_operator; fetch cur_account into l_cnt; -- need to fetch to update rows later fetch cur_operator into l_cnt; -- 0/1 row in cursor as selected by prim_key if cur_account%notfound then o_result := -3; -- Account not found! elsif cur_operator%notfound then o_result := -4; -- Operator has not enough money else update pay_account set balance = (balance + p_sum) where current of cur_account; update pay_operator set total = (total - p_sum) where current of cur_operator; insert into pay_transaction ( id, account_id, operator_id, money, datetime ) values ( pay_transaction_seq.nextval, p_account_id, p_operator_id, p_sum, sysdate ); commit ; o_result := 1; -- transaction successfully finished! end if ; close cur_account; close cur_operator; end ; * This source code was highlighted with Source Code Highlighter .



  57. procedure PROCESS_TRANS(p_account_id in number, p_operator_id in number, p_sum in number, o_result out number) is l_cnt number; cursor cur_account is select id from pay_account where id = p_account_id for update of balance; cursor cur_operator is select id from pay_operator where id = p_operator_id and total >= p_sum for update of total; begin o_result := -1; -- tansaction begins select count (1) -- if such operator exist? into l_cnt from pay_operator opr where opr.id = p_operator_id; if (l_cnt != 1) then o_result := -2; -- Operator not found! return ; end if ; open cur_account; open cur_operator; fetch cur_account into l_cnt; -- need to fetch to update rows later fetch cur_operator into l_cnt; -- 0/1 row in cursor as selected by prim_key if cur_account%notfound then o_result := -3; -- Account not found! elsif cur_operator%notfound then o_result := -4; -- Operator has not enough money else update pay_account set balance = (balance + p_sum) where current of cur_account; update pay_operator set total = (total - p_sum) where current of cur_operator; insert into pay_transaction ( id, account_id, operator_id, money, datetime ) values ( pay_transaction_seq.nextval, p_account_id, p_operator_id, p_sum, sysdate ); commit ; o_result := 1; -- transaction successfully finished! end if ; close cur_account; close cur_operator; end ; * This source code was highlighted with Source Code Highlighter .



  58. procedure PROCESS_TRANS(p_account_id in number, p_operator_id in number, p_sum in number, o_result out number) is l_cnt number; cursor cur_account is select id from pay_account where id = p_account_id for update of balance; cursor cur_operator is select id from pay_operator where id = p_operator_id and total >= p_sum for update of total; begin o_result := -1; -- tansaction begins select count (1) -- if such operator exist? into l_cnt from pay_operator opr where opr.id = p_operator_id; if (l_cnt != 1) then o_result := -2; -- Operator not found! return ; end if ; open cur_account; open cur_operator; fetch cur_account into l_cnt; -- need to fetch to update rows later fetch cur_operator into l_cnt; -- 0/1 row in cursor as selected by prim_key if cur_account%notfound then o_result := -3; -- Account not found! elsif cur_operator%notfound then o_result := -4; -- Operator has not enough money else update pay_account set balance = (balance + p_sum) where current of cur_account; update pay_operator set total = (total - p_sum) where current of cur_operator; insert into pay_transaction ( id, account_id, operator_id, money, datetime ) values ( pay_transaction_seq.nextval, p_account_id, p_operator_id, p_sum, sysdate ); commit ; o_result := 1; -- transaction successfully finished! end if ; close cur_account; close cur_operator; end ; * This source code was highlighted with Source Code Highlighter .



  59. procedure PROCESS_TRANS(p_account_id in number, p_operator_id in number, p_sum in number, o_result out number) is l_cnt number; cursor cur_account is select id from pay_account where id = p_account_id for update of balance; cursor cur_operator is select id from pay_operator where id = p_operator_id and total >= p_sum for update of total; begin o_result := -1; -- tansaction begins select count (1) -- if such operator exist? into l_cnt from pay_operator opr where opr.id = p_operator_id; if (l_cnt != 1) then o_result := -2; -- Operator not found! return ; end if ; open cur_account; open cur_operator; fetch cur_account into l_cnt; -- need to fetch to update rows later fetch cur_operator into l_cnt; -- 0/1 row in cursor as selected by prim_key if cur_account%notfound then o_result := -3; -- Account not found! elsif cur_operator%notfound then o_result := -4; -- Operator has not enough money else update pay_account set balance = (balance + p_sum) where current of cur_account; update pay_operator set total = (total - p_sum) where current of cur_operator; insert into pay_transaction ( id, account_id, operator_id, money, datetime ) values ( pay_transaction_seq.nextval, p_account_id, p_operator_id, p_sum, sysdate ); commit ; o_result := 1; -- transaction successfully finished! end if ; close cur_account; close cur_operator; end ; * This source code was highlighted with Source Code Highlighter .



  60. procedure PROCESS_TRANS(p_account_id in number, p_operator_id in number, p_sum in number, o_result out number) is l_cnt number; cursor cur_account is select id from pay_account where id = p_account_id for update of balance; cursor cur_operator is select id from pay_operator where id = p_operator_id and total >= p_sum for update of total; begin o_result := -1; -- tansaction begins select count (1) -- if such operator exist? into l_cnt from pay_operator opr where opr.id = p_operator_id; if (l_cnt != 1) then o_result := -2; -- Operator not found! return ; end if ; open cur_account; open cur_operator; fetch cur_account into l_cnt; -- need to fetch to update rows later fetch cur_operator into l_cnt; -- 0/1 row in cursor as selected by prim_key if cur_account%notfound then o_result := -3; -- Account not found! elsif cur_operator%notfound then o_result := -4; -- Operator has not enough money else update pay_account set balance = (balance + p_sum) where current of cur_account; update pay_operator set total = (total - p_sum) where current of cur_operator; insert into pay_transaction ( id, account_id, operator_id, money, datetime ) values ( pay_transaction_seq.nextval, p_account_id, p_operator_id, p_sum, sysdate ); commit ; o_result := 1; -- transaction successfully finished! end if ; close cur_account; close cur_operator; end ; * This source code was highlighted with Source Code Highlighter .



  61. procedure PROCESS_TRANS(p_account_id in number, p_operator_id in number, p_sum in number, o_result out number) is l_cnt number; cursor cur_account is select id from pay_account where id = p_account_id for update of balance; cursor cur_operator is select id from pay_operator where id = p_operator_id and total >= p_sum for update of total; begin o_result := -1; -- tansaction begins select count (1) -- if such operator exist? into l_cnt from pay_operator opr where opr.id = p_operator_id; if (l_cnt != 1) then o_result := -2; -- Operator not found! return ; end if ; open cur_account; open cur_operator; fetch cur_account into l_cnt; -- need to fetch to update rows later fetch cur_operator into l_cnt; -- 0/1 row in cursor as selected by prim_key if cur_account%notfound then o_result := -3; -- Account not found! elsif cur_operator%notfound then o_result := -4; -- Operator has not enough money else update pay_account set balance = (balance + p_sum) where current of cur_account; update pay_operator set total = (total - p_sum) where current of cur_operator; insert into pay_transaction ( id, account_id, operator_id, money, datetime ) values ( pay_transaction_seq.nextval, p_account_id, p_operator_id, p_sum, sysdate ); commit ; o_result := 1; -- transaction successfully finished! end if ; close cur_account; close cur_operator; end ; * This source code was highlighted with Source Code Highlighter .



  62. procedure PROCESS_TRANS(p_account_id in number, p_operator_id in number, p_sum in number, o_result out number) is l_cnt number; cursor cur_account is select id from pay_account where id = p_account_id for update of balance; cursor cur_operator is select id from pay_operator where id = p_operator_id and total >= p_sum for update of total; begin o_result := -1; -- tansaction begins select count (1) -- if such operator exist? into l_cnt from pay_operator opr where opr.id = p_operator_id; if (l_cnt != 1) then o_result := -2; -- Operator not found! return ; end if ; open cur_account; open cur_operator; fetch cur_account into l_cnt; -- need to fetch to update rows later fetch cur_operator into l_cnt; -- 0/1 row in cursor as selected by prim_key if cur_account%notfound then o_result := -3; -- Account not found! elsif cur_operator%notfound then o_result := -4; -- Operator has not enough money else update pay_account set balance = (balance + p_sum) where current of cur_account; update pay_operator set total = (total - p_sum) where current of cur_operator; insert into pay_transaction ( id, account_id, operator_id, money, datetime ) values ( pay_transaction_seq.nextval, p_account_id, p_operator_id, p_sum, sysdate ); commit ; o_result := 1; -- transaction successfully finished! end if ; close cur_account; close cur_operator; end ; * This source code was highlighted with Source Code Highlighter .



  63. procedure PROCESS_TRANS(p_account_id in number, p_operator_id in number, p_sum in number, o_result out number) is l_cnt number; cursor cur_account is select id from pay_account where id = p_account_id for update of balance; cursor cur_operator is select id from pay_operator where id = p_operator_id and total >= p_sum for update of total; begin o_result := -1; -- tansaction begins select count (1) -- if such operator exist? into l_cnt from pay_operator opr where opr.id = p_operator_id; if (l_cnt != 1) then o_result := -2; -- Operator not found! return ; end if ; open cur_account; open cur_operator; fetch cur_account into l_cnt; -- need to fetch to update rows later fetch cur_operator into l_cnt; -- 0/1 row in cursor as selected by prim_key if cur_account%notfound then o_result := -3; -- Account not found! elsif cur_operator%notfound then o_result := -4; -- Operator has not enough money else update pay_account set balance = (balance + p_sum) where current of cur_account; update pay_operator set total = (total - p_sum) where current of cur_operator; insert into pay_transaction ( id, account_id, operator_id, money, datetime ) values ( pay_transaction_seq.nextval, p_account_id, p_operator_id, p_sum, sysdate ); commit ; o_result := 1; -- transaction successfully finished! end if ; close cur_account; close cur_operator; end ; * This source code was highlighted with Source Code Highlighter .



  64. procedure PROCESS_TRANS(p_account_id in number, p_operator_id in number, p_sum in number, o_result out number) is l_cnt number; cursor cur_account is select id from pay_account where id = p_account_id for update of balance; cursor cur_operator is select id from pay_operator where id = p_operator_id and total >= p_sum for update of total; begin o_result := -1; -- tansaction begins select count (1) -- if such operator exist? into l_cnt from pay_operator opr where opr.id = p_operator_id; if (l_cnt != 1) then o_result := -2; -- Operator not found! return ; end if ; open cur_account; open cur_operator; fetch cur_account into l_cnt; -- need to fetch to update rows later fetch cur_operator into l_cnt; -- 0/1 row in cursor as selected by prim_key if cur_account%notfound then o_result := -3; -- Account not found! elsif cur_operator%notfound then o_result := -4; -- Operator has not enough money else update pay_account set balance = (balance + p_sum) where current of cur_account; update pay_operator set total = (total - p_sum) where current of cur_operator; insert into pay_transaction ( id, account_id, operator_id, money, datetime ) values ( pay_transaction_seq.nextval, p_account_id, p_operator_id, p_sum, sysdate ); commit ; o_result := 1; -- transaction successfully finished! end if ; close cur_account; close cur_operator; end ; * This source code was highlighted with Source Code Highlighter .



  65. procedure PROCESS_TRANS(p_account_id in number, p_operator_id in number, p_sum in number, o_result out number) is l_cnt number; cursor cur_account is select id from pay_account where id = p_account_id for update of balance; cursor cur_operator is select id from pay_operator where id = p_operator_id and total >= p_sum for update of total; begin o_result := -1; -- tansaction begins select count (1) -- if such operator exist? into l_cnt from pay_operator opr where opr.id = p_operator_id; if (l_cnt != 1) then o_result := -2; -- Operator not found! return ; end if ; open cur_account; open cur_operator; fetch cur_account into l_cnt; -- need to fetch to update rows later fetch cur_operator into l_cnt; -- 0/1 row in cursor as selected by prim_key if cur_account%notfound then o_result := -3; -- Account not found! elsif cur_operator%notfound then o_result := -4; -- Operator has not enough money else update pay_account set balance = (balance + p_sum) where current of cur_account; update pay_operator set total = (total - p_sum) where current of cur_operator; insert into pay_transaction ( id, account_id, operator_id, money, datetime ) values ( pay_transaction_seq.nextval, p_account_id, p_operator_id, p_sum, sysdate ); commit ; o_result := 1; -- transaction successfully finished! end if ; close cur_account; close cur_operator; end ; * This source code was highlighted with Source Code Highlighter .



procedure PROCESS_TRANS(p_account_id in number, p_operator_id in number, p_sum in number, o_result out number) is l_cnt number; cursor cur_account is select id from pay_account where id = p_account_id for update of balance; cursor cur_operator is select id from pay_operator where id = p_operator_id and total >= p_sum for update of total; begin o_result := -1; -- tansaction begins select count (1) -- if such operator exist? into l_cnt from pay_operator opr where opr.id = p_operator_id; if (l_cnt != 1) then o_result := -2; -- Operator not found! return ; end if ; open cur_account; open cur_operator; fetch cur_account into l_cnt; -- need to fetch to update rows later fetch cur_operator into l_cnt; -- 0/1 row in cursor as selected by prim_key if cur_account%notfound then o_result := -3; -- Account not found! elsif cur_operator%notfound then o_result := -4; -- Operator has not enough money else update pay_account set balance = (balance + p_sum) where current of cur_account; update pay_operator set total = (total - p_sum) where current of cur_operator; insert into pay_transaction ( id, account_id, operator_id, money, datetime ) values ( pay_transaction_seq.nextval, p_account_id, p_operator_id, p_sum, sysdate ); commit ; o_result := 1; -- transaction successfully finished! end if ; close cur_account; close cur_operator; end ; * This source code was highlighted with Source Code Highlighter .







多数の同時接続を備えた高負荷のサーバーアプリケーションを構築するための最もイデオロギー的かつ実際的に正しいアプローチは、マルチプレクサの実装です( C10Kの問題 )。

彼らは、「非伝統的な」 Oracle 10.2 Express Editionをデータベースとして採用することにしました。 約2ミリ秒で実行したデータベース内のトランザクション(更新)。 Oracleがデータをディスクにフラッシュしたとき(明らかにdbwrが変更されたデータブロックをバッファキャッシュから書き込んでいたとき)、トランザクションは20ミリ秒まで遅延しました。



データベースに接続するために、メーカーのライブラリを使用することにしました。 これらのうち、タスクのフレームワークでは、2つのジョークが蓄積されました。 OCIの最高の伝統であるOCCIは、はるかに視覚的で使いやすいです。 ただし、その低レベルの対応には否定できない利点があります。OCIを使用すると、1つのクライアントの処理の一部として複数のデータベースクエリを持つ多重化サーバーを実装するために必要な非ブロッキング(非同期)データベースクエリを実行できます。 多くの人は、ノンブロッキングコールの可能性のために、かなり面倒なコードを記述し、OCCIソースを開くようにOracleに要求する必要があることを不満に思っていますが、私が知る限り、役に立ちません。 パフォーマンスの面では、2人の兄弟は非常にわずかに異なります。



成分

他のハードウェアがないため、 Acer 5920Gラップトップ上のVMWareの下でUbuntu 9.04に住んでいました。 すべてのテストが同じ環境で実行されたため、リソースの不足(両方の意味で)が比較テストの結果の客観性に影響を与えないことを願っています。



Oracleのセットアップでは、Tom Kiteから遠く離れているため、データベースとOSはチューニングにあまり煩わされていませんでした。 フルサーバーに移行するときは忙しくなります。



実験の純度を高めるため、各プレートに〜100kエントリが追加されました。



体験



そのようなシステムを構築する方法は? FastCGIプロトコルに基づく最も簡単なソリューションを考えたのは私たちが最初でした。 FastCGIがその祖先CGIと比較して好意的に比較される方法をもう一度説明する価値はないと思います。 高負荷のアプリケーションでは、この違いが基本です。 別のニュアンスについて詳しく説明したいと思いますが、すぐにはわかりませんでした。



FastCGI仕様は、複数の要求の多重化処理を同時に実装できるように、ユーザー接続の保存を規定しています。 簡単に言えば、リクエストハンドラーで非同期操作を呼び出して、他のクライアントに静かにプロセッサー時間を与え、ポーリングサイクルの次の反復で、呼び出された操作の結果を取得し、クライアントに応答を渡して、接続を閉じます。 残念ながら、nginxとlighttpd(およびlibfcgiとfastcgippライブラリ)はまだこれをサポートしていないため、次のクライアントを処理する前に接続を閉じる必要があります。



ただし、この例では、パフォーマンスの大幅な低下を心配せずに、データベースに対して1つの短いクエリのみを同期的に実行できます。



Nginxとlighttpdを使用すると、2つの方法でFastCGIとやり取りできます。TCPチャネルとUnixドメインソケットを使用する方法です。 最初のアプローチの利点はFastCGIサーバーのクラスタリングの可能性であり、欠点はデータ転送の比較的高いオーバーヘッドです(それにもかかわらずTCPスタック)。 ただし、UDSはローカルでのみ動作するため、パフォーマンスが向上します。



2番目の方法について、多くの「暖かい」言葉を述べたいと思います。 最初のテスト後、リクエストの10分の1がFastCGIアプリケーションに到達し、200以上のクライアント(ハードウェア上)からの同時リクエストが届きました。 キャッチはカーネル変数net.unux.max_dgram_qlenにありました。これは、ソケットへの書き込み時の要求キューのサイズを制限します。 デフォルトでは、このオプションは10で、リクエストの損失を説明していました。 値を10000に設定すると、すべてが正常に戻るはずです。 しかし、そこにありました。 ほぼ10分の1のリクエストが確実に落ち、nginxはロジックに「connect()to socket failed(11:Resource temporary unavailable)」という恐ろしい言葉を書きました。 ロシア語では、多数の同時リクエストがあるため、ソケットは「窒息」していました。 この問題はまだ解決できていません。 生産性は向上しましたが、トランザクションの約10%がコード「502」で完了したときに、誰がそれを必要としますか





FastCGIサーバー:







  1. const char * bind_address = ":9000" ;
  2. const char * db_user_name = "orauser" ;
  3. const char * db_password = "pass" ;
  4. const char * db_conn_str = "comp:1521 / xe" ;
  5. int main( int argc、 char * const argv [])
  6. {
  7. oracle:occi 名前空間 を使用し ます
  8. int listenQueueBacklog = 4000;
  9. FCGX_Requestリクエスト;
  10. if (FCGX_Init())
  11. exit(1);
  12. int listen_socket = FCGX_OpenSocket(bind_address、listenQueueBacklog);
  13. if (listen_socket <0)
  14. exit(1);
  15. if (fchmod(listen_socket、S_IROTH | S_IWOTH))
  16. exit(1);
  17. if (FCGX_InitRequest(&request、listen_socket、0))exit(1);
  18. 環境* env = Environment :: createEnvironment(Environment :: DEFAULT);
  19. 接続* conn = env-> createConnection(db_user_name、db_password、db_conn_str);
  20. ステートメント* stmt = conn-> createStatement(
  21. 「BEGIN PAY_SYS.PROCESS_TRANS(:v1 ,: v2 ,: v3 ,: v4); END;」 );
  22. while (FCGX_Accept_r(&request)== 0)
  23. {
  24. bool noException = false 、succesful = false ;
  25. ロングスタート= GetTickCount();
  26. char * params = FCGX_GetParam( "QUERY_STRING" 、request.envp);
  27. int operatorID、accountID、moneySum、result = -1;
  28. operatorID = GetIntParam( params"operator =" );
  29. accountID = GetIntParam( params"account =" );
  30. moneySum = GetIntParam( params"money =" );
  31. if (operatorID <= 0 || accountID <= 0 || moneySum <= 0)
  32. {
  33. FCGX_FPrintF(リクエスト。出力、 「HTTP / 1.0 503 Params Error \ n」 );
  34. FCGX_FPrintF(リクエスト。出力、 「コンテンツタイプ:text / html \ r \ n \ r \ n」 );
  35. FCGX_FPrintF(request。Out、 "wrong params <br> \ n" );
  36. FCGX_Finish_r(&リクエスト);
  37. 続ける ;
  38. }
  39. 試してみる
  40. {
  41. stmt-> setInt(1、accountID);
  42. stmt-> setInt(2、operatorID);
  43. stmt-> setInt(3、moneySum);
  44. stmt-> registerOutParam(4、OCCIINT、 sizeof (結果));
  45. stmt-> execute();
  46. 結果= stmt-> getInt(4);
  47. if (結果== 1)
  48. succesful = true ;
  49. }
  50. catch (SQLExceptionおよびsqlExcp)
  51. {
  52. error_log(sqlExcp.getMessage()。c_str());
  53. }
  54. if (成功)
  55. {
  56. FCGX_FPrintF(リクエスト。出力、 「HTTP / 1.0 200 OK \ n」 );
  57. FCGX_FPrintF(リクエスト。出力、 「コンテンツタイプ:text / html \ r \ n \ r \ n」 );
  58. FCGX_FPrintF(request。Out、 「SQL result =%d」 、result);
  59. }
  60. 他に
  61. {
  62. FCGX_FPrintF(リクエスト。Out、 "HTTP / 1.0 503 DatabaseError \ n" );
  63. FCGX_FPrintF(リクエスト。出力、 「コンテンツタイプ:text / html \ r \ n \ r \ n」 );
  64. FCGX_FPrintF(リクエスト。出力、 「データベースエラーが発生しました」 );
  65. error_log( "db error" );
  66. }
  67. FCGX_Finish_r(&リクエスト);
  68. }
  69. conn-> terminateStatement(stmt);
  70. env-> terminateConnection(conn);
  71. 環境:: terminateEnvironment(env);
  72. 0を返します。
  73. }
*このソースコードは、 ソースコードハイライターで強調表示されました。




合計



使用された包囲とab。 メモリの問題により、Siegeは1秒あたり380を超えるリクエストをきっぱりと拒否し、1000のリクエストに「絞り込んだ」が、過剰な数のオープンソケットに言及した。



結果の信頼性のために、テストは100、200、300、400の同時10,000クエリのスキームに従って実行されました。 デフォルトのカーネル設定を使用したこのマシン上のFastCGIの場合、負荷は、失われた要求の10%のクリティカルしきい値を克服するのに十分でした。 lighttpd + fastcgiの束は200件のリクエストで「つまずき」始めましたが、nginxの束は最大300の同時接続を維持しました。 400を超える同時接続の負荷では、両方のFastCGIバリアントが「apr_poll:指定されたタイムアウトが期限切れ(70007)」というメッセージで落ちましたが、nginxモジュールはabを介した1000の同時接続で悲鳴を上げることなく分解されました。 テストは再びハードウェアで実行されました。 明確にするために、測定結果をグラフ形式で表示することにしました。



そのため、グラフの署名に応じて、横軸-同時要求数、縦軸-になります。





(図2.最長のリクエスト、秒)





(図3.平均リクエスト処理時間、秒)





(図4. 1秒間に処理されるリクエストの数)





(図5. 10,000リクエストの処理にかかった時間、秒)



おわりに



限られたリソースでは素晴らしい結果を得ることができませんでしたが、比較テストは非常に成功したと信じています。 テスト結果は完全であると主張していませんが、一般的に、私たちの意見では、期待を確認します。 国内のアスリートは、最小限の追加装備で自信を持ってリードしています。 彼と彼のコーチは大きな敬意を払っています! FastCGIと連動して、彼は再び小さな外国の敵をバイパスします。



私たちの実験では、非同期データベース呼び出しのメカニズムはまだ使用されていません。 クライアントの処理をデータベースへの複数の呼び出しに複雑にし、完全なマルチプレクサを実装すると、テスト結果がどのように変化するか興味があります。 FastCGIでは、これは機能しませんが、nginxモジュールで実行できます。実験を完全にするために、poco、asio、pionなどのライブラリに基づいて独自のHTTPデーモンを呼び出して、「実験的」なもののランクに入れます...



一般的に、 継続するには...



UPD

Nginxモジュールは、静的にコンパイルされるサーバー拡張機能です。 SSLやFastCGIなどの組み込み機能もモジュールとして実装されます。 プラス-速度、マイナス-実行中のマシンでの更新の複雑さ。 すばらしいマニュアルがここにあります

簡単な例を以下に示します。 変更については、OCI Cライブラリを使用してORACLEを操作してください。





  1. // nginx.confおよびエラー処理による設定のサポートなしのオプション
  2. #include <ngx_config.h>
  3. #include <ngx_core.h>
  4. #include <ngx_http.h>
  5. #include < string .h>
  6. #include <oci.h>
  7. const text * db_user_name =( const text *) "orauser" ;
  8. const text * db_password =( const text *) "pass" ;
  9. const text * db_conn_str =( const text *) "comp:1521 / xe" ;
  10. const text * command =( const text *)
  11. 「BEGIN PAY_SYS.PROCESS_TRANS(:v1 ,: v2 ,: v3 ,: v4); END;」 ;
  12. OCIEnv * env;
  13. OCISvcCtx *コンテキスト。
  14. OCISession *セッション。
  15. OCIServer *サーバー。
  16. OCIError *エラー。
  17. OCIStmt *ステートメント。
  18. OCIBind * bnd1、* bnd2、* bnd3、* bnd4;
  19. int operatorID、accountID、sum、result;
  20. static char * ngx_http_payment_init(ngx_conf_t * cf、
  21. ngx_command_t * cmd、 void * conf);
  22. // nginx.confの可能なモジュールオプションの配列
  23. static ngx_command_t ngx_http_payment_commands [] =
  24. { //指定された場所のモジュールを含むメインオプションを1つだけ設定する
  25. {ngx_string( "payment_enabled" )、
  26. NGX_HTTP_LOC_CONF | NGX_CONF_NOARGS、
  27. ngx_http_payment_init、
  28. NGX_HTTP_LOC_CONF_OFFSET、
  29. 0
  30. NULL}、
  31. ngx_null_command //配列を終了します
  32. };
  33. //コールバック、使用しない
  34. static ngx_http_module_t ngx_http_payment_module_ctx =
  35. {
  36. NULL、 / *事前設定* /
  37. NULL、 / *構成後* /
  38. NULL、 / *メイン構成の作成* /
  39. NULL、 / *メイン構成の初期化* /
  40. NULL、 / *サーバー構成の作成* /
  41. NULL、 / *サーバー構成のマージ* /
  42. NULL、 / *ロケーション構成の作成* /
  43. NULL / *ロケーション構成のマージ* /
  44. };
  45. //すべてのパラメーターを含むモジュール記述子
  46. ngx_module_t ngx_http_payment_module =
  47. {
  48. NGX_MODULE_V1、
  49. &ngx_http_payment_module_ctx、 / *モジュールコンテキスト* /
  50. ngx_http_payment_commands、 / *モジュールディレクティブ* /
  51. NGX_HTTP_MODULE、 / *モジュールタイプ* /
  52. NULL、 / * init master * /
  53. NULL、 / *初期化モジュール* /
  54. NULL、 / *初期化プロセス* /
  55. NULL、 / *初期化スレッド* /
  56. NULL、 / *終了スレッド* /
  57. NULL、 / *プロセスを終了* /
  58. NULL、 / *終了マスター* /
  59. NGX_MODULE_V1_PADDING
  60. };
  61. void SetCallParams( int oper、 int account、 int money)
  62. {
  63. if (bnd1!= 0)OCIHandleFree((dvoid *)bnd1、OCI_HTYPE_BIND);
  64. if (bnd2!= 0)OCIHandleFree((dvoid *)bnd2、OCI_HTYPE_BIND);
  65. if (bnd3!= 0)OCIHandleFree((dvoid *)bnd3、OCI_HTYPE_BIND);
  66. if (bnd4!= 0)OCIHandleFree((dvoid *)bnd4、OCI_HTYPE_BIND);
  67. //スタックからコピーして、有効なポインターを渡すことができるようにします
  68. 結果= 0;
  69. operatorID = oper;
  70. accountID =アカウント。
  71. 合計=お金;
  72. //パラメータをSQL呼び出しにバインドします
  73. OCIBindByPos(ステートメント、&bnd1、エラー、1、およびaccountID、
  74. sizeof (accountID)、SQLT_INT、(dvoid *)0、
  75. (ub2 *)0、(ub2 *)0、(ub4)0、(ub4 *)0、OCI_DEFAULT);
  76. OCIBindByPos(ステートメント、&bnd2、エラー、2、&operatorID、
  77. sizeof (operatorID)、SQLT_INT、(dvoid *)0、
  78. (ub2 *)0、(ub2 *)0、(ub4)0、(ub4 *)0、OCI_DEFAULT);
  79. OCIBindByPos(ステートメント、&bnd3、エラー、3、&合計、 sizeof (合計)、SQLT_INT、
  80. (dvoid *)0、(ub2 *)0、(ub2 *)0、(ub4)0、
  81. (ub4 *)0、OCI_DEFAULT);
  82. OCIBindByPos(ステートメント、&bnd4、エラー、4、&結果、 sizeof (結果)、SQLT_INT、
  83. (dvoid *)0、(ub2 *)0、(ub2 *)0、(ub4)0、(ub4 *)0、OCI_DEFAULT);
  84. }
  85. //メインハンドラ、すべての作業はここで行われます
  86. 静的 ngx_int_t ngx_http_payment_handler(ngx_http_request_t * r)
  87. {
  88. //本体セクションをクリアします
  89. ngx_int_t rc = ngx_http_discard_request_body(r);
  90. if (rc!= NGX_OK && rc!= NGX_AGAIN)
  91. {
  92. ngx_log_error(NGX_LOG_ERR、r-> connection-> log、0、
  93. 「ngx_http_discard_request_body()に失敗しました」 );
  94. return rc;
  95. }
  96. // nginxの行は、長さデータのペアとして保存されます。
  97. //従来のCスタイルのゼロエンドとしてではありません
  98. //パーサーが正しく動作するようにコピーします
  99. const int buflen = 100;
  100. char buf [buflen + 1];
  101. int len =(r-> args.len <buflen)? r-> args.len:buflen;
  102. buf [len] = '\ 0' ;
  103. ngx_memcpy(buf、r-> args.data、r-> args.len);
  104. int成功= 0;
  105. int 演算子 、abonent、money、result = -1;
  106. //最も単純なパーサーを呼び出します
  107. operator = GetIntParam(buf、 "operator =" );
  108. abonent = GetIntParam(buf、 "abonent =" );
  109. money = GetIntParam(buf、 "money =" );
  110. if演算子 > 0 && abonent> 0 && money> 0)
  111. {
  112. SetCallParams( operator 、abonent、money);
  113. int retCode = OCIStmtExecute(
  114. コンテキスト、ステートメント、エラー、(ub4)1、(ub4)0、
  115. (OCISnapshot *)NULL、(OCISnapshot *)NULL、
  116. (ub4)OCI_COMMIT_ON_SUCCESS);
  117. if (retCode == OCI_SUCCESS)
  118. 成功= 1;
  119. }
  120. r-> headers_out.content_type.len = sizeof"text / html" )-1;
  121. r-> headers_out.content_type.data =(u_char *) "text / html" ;
  122. r-> headers_out.content_length_n = 0;
  123. if (成功== 1)
  124. r-> headers_out.status = NGX_HTTP_OK;
  125. 他に
  126. r-> headers_out.status = NGX_HTTP_INTERNAL_SERVER_ERROR;
  127. // ...応答の本文を形成し、nginxに渡します.. emillerの例を参照してください
  128. }
  129. static char * ngx_http_payment_init(ngx_conf_t * cf、
  130. ngx_command_t * cmd、
  131. void * our_conf)
  132. {
  133. // nginxハンドラーを設定します
  134. ngx_http_core_loc_conf_t * core_conf =
  135. ngx_http_conf_get_module_loc_conf(cf、ngx_http_core_module);
  136. core_conf-> handler = ngx_http_payment_handler;
  137. //オラクル
  138. bnd1 =(OCIBind *)0;
  139. bnd2 =(OCIBind *)0;
  140. bnd3 =(OCIBind *)0;
  141. bnd4 =(OCIBind *)0;
  142. OCIEnvCreate((OCIEnv **)&env、(ub4)OCI_DEFAULT、
  143. (dvoid *)0、(dvoid *(*)(dvoid *、size_t))0、
  144. (dvoid *(*)(dvoid *、dvoid *、size_t))0、
  145. void (*)(dvoid *、dvoid *))0、(size_t)0、(dvoid **)0);
  146. / *サーバーハンドルを割り当てます* /
  147. OCIHandleAlloc((dvoid *)env、(dvoid **)&server、
  148. OCI_HTYPE_SERVER、0、(dvoid **)0);
  149. / *エラーハンドルを割り当てます* /
  150. OCIHandleAlloc((dvoid *)env、(dvoid **)&エラー、
  151. OCI_HTYPE_ERROR、0、(dvoid **)0);
  152. / *サーバーコンテキストを作成* /
  153. int retCode = OCIServerAttach(サーバー、エラー、db_conn_str、
  154. strlen(( const char *)db_conn_str)、OCI_DEFAULT);
  155. / *サービスハンドルを割り当てます* /
  156. retCode = OCIHandleAlloc((dvoid *)env、(dvoid **)&context、
  157. OCI_HTYPE_SVCCTX、0、(dvoid **)0);
  158. / *サービスコンテキストハンドルのサーバー属性を設定* /
  159. retCode = OCIAttrSet((dvoid *)コンテキスト、OCI_HTYPE_SVCCTX、
  160. (dvoid *)サーバー、(ub4)0、OCI_ATTR_SERVER、エラー);
  161. / *ユーザーセッションハンドルを割り当てます* /
  162. retCode = OCIHandleAlloc((dvoid *)env、(dvoid **)&session、
  163. OCI_HTYPE_SESSION、0、(dvoid **)0);
  164. //セッションのユーザーとパスワードを設定します
  165. retCode = OCIAttrSet((dvoid *)セッション、OCI_HTYPE_SESSION、
  166. void *)db_user_name、(ub4)strlen(( const char *)db_user_name)、
  167. OCI_ATTR_USERNAME、エラー);
  168. retCode = OCIAttrSet((dvoid *)セッション、OCI_HTYPE_SESSION、
  169. void *)db_password、(ub4)strlen(( const char *)db_password)、
  170. OCI_ATTR_PASSWORD、エラー);
  171. //セッションを開始
  172. retCode = OCISessionBegin(コンテキスト、エラー、セッション、
  173. OCI_CRED_RDBMS、OCI_DEFAULT);
  174. / *サービスコンテキストハンドルでユーザーセッション属性を設定* /
  175. retCode = OCIAttrSet((dvoid *)コンテキスト、OCI_HTYPE_SVCCTX、
  176. (dvoid *)セッション、(ub4)0、
  177. OCI_ATTR_SESSION、エラー);
  178. OCIHandleAlloc((dvoid *)env、(dvoid **)&ステートメント、
  179. OCI_HTYPE_STMT、(size_t)0、(dvoid **)0);
  180. OCIStmtPrepare(ステートメント、エラー、コマンド、(ub4)strlen(( char *)コマンド)、
  181. (ub4)OCI_NTV_SYNTAX、(ub4)OCI_DEFAULT);
  182. return NGX_CONF_OK;
  183. }
*このソースコードは、 ソースコードハイライターで強調表示されました。







All Articles