{"id":3141,"date":"2019-07-31T17:16:03","date_gmt":"2019-07-31T15:16:03","guid":{"rendered":"http:\/\/van-maanen.com\/?p=3141"},"modified":"2019-07-31T17:16:03","modified_gmt":"2019-07-31T15:16:03","slug":"generate-code-in-oracle","status":"publish","type":"post","link":"http:\/\/archief.van-maanen.com\/?p=3141","title":{"rendered":"Generate code in Oracle"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">The idea is as follows. We want to create a simple function that calculates a code from a string. This code is the total ASCII value of the characters in a string. I used this code to act as a foreign key to which other tables may refer to.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">I use an Oracle function that is written as:<\/p>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\"><p>create or replace <br>     function sumascii (str in varchar2) return number is<br>     x number := 0;<br> begin<br>     for i in 1..length (str)<br>     loop<br>         x := x + i*ascii (substr (str, i, 1)) ;<br>     end loop;<br>     return x;<br> end;<br> \/<\/p><\/blockquote>\n\n\n\n<p class=\"wp-block-paragraph\">This function can be used in a SQL statement. For example, one may insert the codes as:  update mappings set sleutel =  sumascii(mapping); <\/p>\n","protected":false},"excerpt":{"rendered":"<p>The idea is as follows. We want to create a simple function that calculates a code from a string. This code is the total ASCII value of the characters in a string. I used this code to act as a foreign key to which other tables may refer to. I use an Oracle function that [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3],"tags":[],"class_list":["post-3141","post","type-post","status-publish","format-standard","hentry","category-allgemein"],"_links":{"self":[{"href":"http:\/\/archief.van-maanen.com\/index.php?rest_route=\/wp\/v2\/posts\/3141","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/archief.van-maanen.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/archief.van-maanen.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/archief.van-maanen.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/archief.van-maanen.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=3141"}],"version-history":[{"count":0,"href":"http:\/\/archief.van-maanen.com\/index.php?rest_route=\/wp\/v2\/posts\/3141\/revisions"}],"wp:attachment":[{"href":"http:\/\/archief.van-maanen.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=3141"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/archief.van-maanen.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=3141"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/archief.van-maanen.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=3141"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}