最近、高性能アプリケーションの実装のテーマが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 .
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 .
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 .
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 .
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 .
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 .
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 .
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 .
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 .
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 .
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 .
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 .
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 .
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 .
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 .
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 .
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 .
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 .
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 .
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 .
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 .
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 .
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 .
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 .
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 .
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 .
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 .
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 .
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 .
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 .
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 .
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 .
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 .
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つのジョークが蓄積されました。
- Oracle Call Interface©
- Oracle C ++ Call Interface(C ++)
OCIの最高の伝統であるOCCIは、はるかに視覚的で使いやすいです。 ただし、その低レベルの対応には否定できない利点があります。OCIを使用すると、1つのクライアントの処理の一部として複数のデータベースクエリを持つ多重化サーバーを実装するために必要な非ブロッキング(非同期)データベースクエリを実行できます。 多くの人は、ノンブロッキングコールの可能性のために、かなり面倒なコードを記述し、OCCIソースを開くようにOracleに要求する必要があることを不満に思っていますが、私が知る限り、役に立ちません。 パフォーマンスの面では、2人の兄弟は非常にわずかに異なります。
成分
- Oracle XE 10.2
- Nginx 0.7.62
- Lighttpd 1.4.23
他のハードウェアがないため、
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サーバー:
- const char * bind_address = ":9000" ;
- const char * db_user_name = "orauser" ;
- const char * db_password = "pass" ;
- const char * db_conn_str = "comp:1521 / xe" ;
- int main( int argc、 char * const argv [])
- {
- oracle:occi 名前空間 を使用し ます 。
- int listenQueueBacklog = 4000;
- FCGX_Requestリクエスト;
- if (FCGX_Init())
- exit(1);
- int listen_socket = FCGX_OpenSocket(bind_address、listenQueueBacklog);
- if (listen_socket <0)
- exit(1);
- if (fchmod(listen_socket、S_IROTH | S_IWOTH))
- exit(1);
- if (FCGX_InitRequest(&request、listen_socket、0))exit(1);
- 環境* env = Environment :: createEnvironment(Environment :: DEFAULT);
- 接続* conn = env-> createConnection(db_user_name、db_password、db_conn_str);
- ステートメント* stmt = conn-> createStatement(
- 「BEGIN PAY_SYS.PROCESS_TRANS(:v1 ,: v2 ,: v3 ,: v4); END;」 );
- while (FCGX_Accept_r(&request)== 0)
- {
- bool noException = false 、succesful = false ;
- ロングスタート= GetTickCount();
- char * params = FCGX_GetParam( "QUERY_STRING" 、request.envp);
- int operatorID、accountID、moneySum、result = -1;
- operatorID = GetIntParam( params 、 "operator =" );
- accountID = GetIntParam( params 、 "account =" );
- moneySum = GetIntParam( params 、 "money =" );
- if (operatorID <= 0 || accountID <= 0 || moneySum <= 0)
- {
- FCGX_FPrintF(リクエスト。出力、 「HTTP / 1.0 503 Params Error \ n」 );
- FCGX_FPrintF(リクエスト。出力、 「コンテンツタイプ:text / html \ r \ n \ r \ n」 );
- FCGX_FPrintF(request。Out、 "wrong params <br> \ n" );
- FCGX_Finish_r(&リクエスト);
- 続ける ;
- }
- 試してみる
- {
- stmt-> setInt(1、accountID);
- stmt-> setInt(2、operatorID);
- stmt-> setInt(3、moneySum);
- stmt-> registerOutParam(4、OCCIINT、 sizeof (結果));
- stmt-> execute();
- 結果= stmt-> getInt(4);
- if (結果== 1)
- succesful = true ;
- }
- catch (SQLExceptionおよびsqlExcp)
- {
- error_log(sqlExcp.getMessage()。c_str());
- }
- if (成功)
- {
- FCGX_FPrintF(リクエスト。出力、 「HTTP / 1.0 200 OK \ n」 );
- FCGX_FPrintF(リクエスト。出力、 「コンテンツタイプ:text / html \ r \ n \ r \ n」 );
- FCGX_FPrintF(request。Out、 「SQL result =%d」 、result);
- }
- 他に
- {
- FCGX_FPrintF(リクエスト。Out、 "HTTP / 1.0 503 DatabaseError \ n" );
- FCGX_FPrintF(リクエスト。出力、 「コンテンツタイプ:text / html \ r \ n \ r \ n」 );
- FCGX_FPrintF(リクエスト。出力、 「データベースエラーが発生しました」 );
- error_log( "db error" );
- }
- FCGX_Finish_r(&リクエスト);
- }
- conn-> terminateStatement(stmt);
- env-> terminateConnection(conn);
- 環境:: terminateEnvironment(env);
- 0を返します。
- }
*このソースコードは、 ソースコードハイライターで強調表示されました。
合計
使用された包囲と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デーモンを呼び出して、「実験的」なもののランクに入れます...
一般的に、
継続するには...UPDNginxモジュールは、静的にコンパイルされるサーバー拡張機能です。 SSLやFastCGIなどの組み込み機能もモジュールとして実装されます。 プラス-速度、マイナス-実行中のマシンでの更新の複雑さ。 すばらしいマニュアルが
ここにあります 。
簡単な例を以下に示します。 変更については、OCI Cライブラリを使用してORACLEを操作してください。
- // nginx.confおよびエラー処理による設定のサポートなしのオプション
- #include <ngx_config.h>
- #include <ngx_core.h>
- #include <ngx_http.h>
- #include < string .h>
- #include <oci.h>
- const text * db_user_name =( const text *) "orauser" ;
- const text * db_password =( const text *) "pass" ;
- const text * db_conn_str =( const text *) "comp:1521 / xe" ;
- const text * command =( const text *)
- 「BEGIN PAY_SYS.PROCESS_TRANS(:v1 ,: v2 ,: v3 ,: v4); END;」 ;
- OCIEnv * env;
- OCISvcCtx *コンテキスト。
- OCISession *セッション。
- OCIServer *サーバー。
- OCIError *エラー。
- OCIStmt *ステートメント。
- OCIBind * bnd1、* bnd2、* bnd3、* bnd4;
- int operatorID、accountID、sum、result;
- static char * ngx_http_payment_init(ngx_conf_t * cf、
- ngx_command_t * cmd、 void * conf);
- // nginx.confの可能なモジュールオプションの配列
- static ngx_command_t ngx_http_payment_commands [] =
- { //指定された場所のモジュールを含むメインオプションを1つだけ設定する
- {ngx_string( "payment_enabled" )、
- NGX_HTTP_LOC_CONF | NGX_CONF_NOARGS、
- ngx_http_payment_init、
- NGX_HTTP_LOC_CONF_OFFSET、
- 0
- NULL}、
- ngx_null_command //配列を終了します
- };
- //コールバック、使用しない
- static ngx_http_module_t ngx_http_payment_module_ctx =
- {
- NULL、 / *事前設定* /
- NULL、 / *構成後* /
- NULL、 / *メイン構成の作成* /
- NULL、 / *メイン構成の初期化* /
- NULL、 / *サーバー構成の作成* /
- NULL、 / *サーバー構成のマージ* /
- NULL、 / *ロケーション構成の作成* /
- NULL / *ロケーション構成のマージ* /
- };
- //すべてのパラメーターを含むモジュール記述子
- ngx_module_t ngx_http_payment_module =
- {
- NGX_MODULE_V1、
- &ngx_http_payment_module_ctx、 / *モジュールコンテキスト* /
- ngx_http_payment_commands、 / *モジュールディレクティブ* /
- NGX_HTTP_MODULE、 / *モジュールタイプ* /
- NULL、 / * init master * /
- NULL、 / *初期化モジュール* /
- NULL、 / *初期化プロセス* /
- NULL、 / *初期化スレッド* /
- NULL、 / *終了スレッド* /
- NULL、 / *プロセスを終了* /
- NULL、 / *終了マスター* /
- NGX_MODULE_V1_PADDING
- };
- void SetCallParams( int oper、 int account、 int money)
- {
- if (bnd1!= 0)OCIHandleFree((dvoid *)bnd1、OCI_HTYPE_BIND);
- if (bnd2!= 0)OCIHandleFree((dvoid *)bnd2、OCI_HTYPE_BIND);
- if (bnd3!= 0)OCIHandleFree((dvoid *)bnd3、OCI_HTYPE_BIND);
- if (bnd4!= 0)OCIHandleFree((dvoid *)bnd4、OCI_HTYPE_BIND);
- //スタックからコピーして、有効なポインターを渡すことができるようにします
- 結果= 0;
- operatorID = oper;
- accountID =アカウント。
- 合計=お金;
- //パラメータをSQL呼び出しにバインドします
- OCIBindByPos(ステートメント、&bnd1、エラー、1、およびaccountID、
- sizeof (accountID)、SQLT_INT、(dvoid *)0、
- (ub2 *)0、(ub2 *)0、(ub4)0、(ub4 *)0、OCI_DEFAULT);
- OCIBindByPos(ステートメント、&bnd2、エラー、2、&operatorID、
- sizeof (operatorID)、SQLT_INT、(dvoid *)0、
- (ub2 *)0、(ub2 *)0、(ub4)0、(ub4 *)0、OCI_DEFAULT);
- OCIBindByPos(ステートメント、&bnd3、エラー、3、&合計、 sizeof (合計)、SQLT_INT、
- (dvoid *)0、(ub2 *)0、(ub2 *)0、(ub4)0、
- (ub4 *)0、OCI_DEFAULT);
- OCIBindByPos(ステートメント、&bnd4、エラー、4、&結果、 sizeof (結果)、SQLT_INT、
- (dvoid *)0、(ub2 *)0、(ub2 *)0、(ub4)0、(ub4 *)0、OCI_DEFAULT);
- }
- //メインハンドラ、すべての作業はここで行われます
- 静的 ngx_int_t ngx_http_payment_handler(ngx_http_request_t * r)
- {
- //本体セクションをクリアします
- ngx_int_t rc = ngx_http_discard_request_body(r);
- if (rc!= NGX_OK && rc!= NGX_AGAIN)
- {
- ngx_log_error(NGX_LOG_ERR、r-> connection-> log、0、
- 「ngx_http_discard_request_body()に失敗しました」 );
- return rc;
- }
- // nginxの行は、長さデータのペアとして保存されます。
- //従来のCスタイルのゼロエンドとしてではありません
- //パーサーが正しく動作するようにコピーします
- const int buflen = 100;
- char buf [buflen + 1];
- int len =(r-> args.len <buflen)? r-> args.len:buflen;
- buf [len] = '\ 0' ;
- ngx_memcpy(buf、r-> args.data、r-> args.len);
- int成功= 0;
- int 演算子 、abonent、money、result = -1;
- //最も単純なパーサーを呼び出します
- operator = GetIntParam(buf、 "operator =" );
- abonent = GetIntParam(buf、 "abonent =" );
- money = GetIntParam(buf、 "money =" );
- if ( 演算子 > 0 && abonent> 0 && money> 0)
- {
- SetCallParams( operator 、abonent、money);
- int retCode = OCIStmtExecute(
- コンテキスト、ステートメント、エラー、(ub4)1、(ub4)0、
- (OCISnapshot *)NULL、(OCISnapshot *)NULL、
- (ub4)OCI_COMMIT_ON_SUCCESS);
- if (retCode == OCI_SUCCESS)
- 成功= 1;
- }
- r-> headers_out.content_type.len = sizeof ( "text / html" )-1;
- r-> headers_out.content_type.data =(u_char *) "text / html" ;
- r-> headers_out.content_length_n = 0;
- if (成功== 1)
- r-> headers_out.status = NGX_HTTP_OK;
- 他に
- r-> headers_out.status = NGX_HTTP_INTERNAL_SERVER_ERROR;
- // ...応答の本文を形成し、nginxに渡します.. emillerの例を参照してください
- }
- static char * ngx_http_payment_init(ngx_conf_t * cf、
- ngx_command_t * cmd、
- void * our_conf)
- {
- // nginxハンドラーを設定します
- ngx_http_core_loc_conf_t * core_conf =
- ngx_http_conf_get_module_loc_conf(cf、ngx_http_core_module);
- core_conf-> handler = ngx_http_payment_handler;
- //オラクル
- bnd1 =(OCIBind *)0;
- bnd2 =(OCIBind *)0;
- bnd3 =(OCIBind *)0;
- bnd4 =(OCIBind *)0;
- OCIEnvCreate((OCIEnv **)&env、(ub4)OCI_DEFAULT、
- (dvoid *)0、(dvoid *(*)(dvoid *、size_t))0、
- (dvoid *(*)(dvoid *、dvoid *、size_t))0、
- ( void (*)(dvoid *、dvoid *))0、(size_t)0、(dvoid **)0);
- / *サーバーハンドルを割り当てます* /
- OCIHandleAlloc((dvoid *)env、(dvoid **)&server、
- OCI_HTYPE_SERVER、0、(dvoid **)0);
- / *エラーハンドルを割り当てます* /
- OCIHandleAlloc((dvoid *)env、(dvoid **)&エラー、
- OCI_HTYPE_ERROR、0、(dvoid **)0);
- / *サーバーコンテキストを作成* /
- int retCode = OCIServerAttach(サーバー、エラー、db_conn_str、
- strlen(( const char *)db_conn_str)、OCI_DEFAULT);
- / *サービスハンドルを割り当てます* /
- retCode = OCIHandleAlloc((dvoid *)env、(dvoid **)&context、
- OCI_HTYPE_SVCCTX、0、(dvoid **)0);
- / *サービスコンテキストハンドルのサーバー属性を設定* /
- retCode = OCIAttrSet((dvoid *)コンテキスト、OCI_HTYPE_SVCCTX、
- (dvoid *)サーバー、(ub4)0、OCI_ATTR_SERVER、エラー);
- / *ユーザーセッションハンドルを割り当てます* /
- retCode = OCIHandleAlloc((dvoid *)env、(dvoid **)&session、
- OCI_HTYPE_SESSION、0、(dvoid **)0);
- //セッションのユーザーとパスワードを設定します
- retCode = OCIAttrSet((dvoid *)セッション、OCI_HTYPE_SESSION、
- ( void *)db_user_name、(ub4)strlen(( const char *)db_user_name)、
- OCI_ATTR_USERNAME、エラー);
- retCode = OCIAttrSet((dvoid *)セッション、OCI_HTYPE_SESSION、
- ( void *)db_password、(ub4)strlen(( const char *)db_password)、
- OCI_ATTR_PASSWORD、エラー);
- //セッションを開始
- retCode = OCISessionBegin(コンテキスト、エラー、セッション、
- OCI_CRED_RDBMS、OCI_DEFAULT);
- / *サービスコンテキストハンドルでユーザーセッション属性を設定* /
- retCode = OCIAttrSet((dvoid *)コンテキスト、OCI_HTYPE_SVCCTX、
- (dvoid *)セッション、(ub4)0、
- OCI_ATTR_SESSION、エラー);
- OCIHandleAlloc((dvoid *)env、(dvoid **)&ステートメント、
- OCI_HTYPE_STMT、(size_t)0、(dvoid **)0);
- OCIStmtPrepare(ステートメント、エラー、コマンド、(ub4)strlen(( char *)コマンド)、
- (ub4)OCI_NTV_SYNTAX、(ub4)OCI_DEFAULT);
- return NGX_CONF_OK;
- }
*このソースコードは、 ソースコードハイライターで強調表示されました。