avaloq cost rule: commstex swx buy sell prozent menge betrag
| Cost Rules: | ||||||||||||
| RuleNr | Cost_type | Matching Criteria : | Order | Amount from | Amount to | Factor | Minimum | Maximum | Graduated | |||
| Stock Exchange | Type | |||||||||||
| 1 | commstex | SWX | Buy | 0 | 50’000 | 0.006 | 60 | yes | ||||
| 2 | commstex | SWX | Buy | 50’000 | 100’000 | 0.0055 | yes | |||||
| 3 | commstex | SWX | Buy | 100’000 | 150’000 | 0.005 | yes | |||||
| 4 | commstex | SWX | Buy | 150’000 | 0.0045 | yes | ||||||
| 5 | commstex | SWX | Sell | 0 | 50’000 | 0.006 | 60 | no | ||||
| 6 | commstex | SWX | Sell | 50’000 | 100’000 | 0.0055 | no | |||||
| 7 | commstex | SWX | Sell | 100’000 | 150’000 | 0.005 | no | |||||
| 8 | commstex | SWX | Sell | 150’000 | 0.0045 | no | ||||||
| Trade 1 | from | to | Prozent | Menge | Betrag | |||||||
| EVENT: | Order: | Buy | 0 | 50000 | 0.006 | 50000 | 300 | |||||
| Exchange: | SWX | 50000 | 100000 | 0.0055 | 50000 | 275 | graduated | |||||
| Title: | UBSN | Gross | 100000 | 150000 | 0.005 | 50000 | 250 | |||||
| Pieces: | 3’000 | 156000 | 150000 | up | 0.0045 | 6000 | 27 | |||||
| Price: | 52 | Cost = | 852 | |||||||||
| Trade 2 | from | to | Prozent | Menge | Betrag | |||||||
| EVENT: | Order: | Sell | ||||||||||
| Exchange: | SWX | 50000 | 100000 | 0.0055 | 76500 | 420.75 | not graduated! | |||||
| Title: | UBSN | Gross | ||||||||||
| Pieces: | 1’500 | 76500 | ||||||||||
| Price: | 51 | Cost = | 420.75 | |||||||||
| Trade 3 | ||||||||||||
| EVENT: | Order: | Sell | Cost = | Error | ||||||||
| Exchange: | VIRT-X | NO VIRT-X | ||||||||||
| Title: | UBSN | |||||||||||
| Pieces: | 900 | |||||||||||
| Price: | 51 | |||||||||||
PL/SQL: Merge Statement – Merge into a single table (no Join to insert or update) – like mySQL upsert
On Oracle, you can write simple insert/update statements with PL/SQL. Also using some if-then-else cases you can decide wether to insert or to update data.
The much more elegant way to insert or update data with pl/sql is to use Oracle's MERGE Command (like upsert in mySQL).
Usually within the Merge command, you can join two tables together to check the data. Just search the web - you'll find many examples with MERGE and JOINS.
But what when you'd only like to MERGE into a single table?
After some tries, I found a solution using the DUAL table.
Just see my MERGE PL/SQL sample. It's absolutelly easy to understand:
merge into position_table t
using dual
on (t.pos_id = p_pos_id)
when matched then
update
set anzahl = p_anzahl
, gueltig_ab = p_gueltig_ab
, doc_id = p_doc_id
, bemerkung = p_bemerkung
when not matched then
insert
(pos_id
,anzahl
,gueltig_ab
,doc_id
,bemerkung
)
values
(p_pos_id
,p_anzahl
,p_gueltig_ab
,p_doc_id
,p_bemerkung
)
; -- ende merge















