К основному контенту

Сообщения

Сообщения за ноябрь, 2012

Problems with Oracle SYS_CONTEXT function

Hey there,   Today I've solved an interesting bug in the existent database procedures. Actually, it's not the bug right now, but it definitely will after a couple of years.   We have an ASP.NET web site which works with the Oracle based database. There're no any entity model (it's old system with just a support for now) and all the queries are native SQL or calling SQL procedures from the database itself. Database generates new "unique" oid for every newly created entity with well-known procedure like this: CREATE OR REPLACE FUNCTION new_uuid RETURN VARCHAR2 AS   l_seed        BINARY_INTEGER;   l_random_num  NUMBER(5);   l_date        VARCHAR2(25);   l_random      VARCHAR2(4);   l_ip_address  VARCHAR2(12); BEGIN   l_seed       := TO_NUMBER(TO_CHAR(SYSDATE,'YYYYDDMMSS')); DBMS_RANDOM.initialize (val => l_seed);   l_random_num := TRUNC(DBMS_RANDOM.value(low => 1, high => 65535)); DBMS_RANDOM.terminate;   l_date       := conversion_api.to_hex(