Posts

Showing posts with the label Oracle Develop

ORACLE Develop Rule

Rule: 1. Try to use one SQL script to accomplish the task. 2. If one SQL script can't solve the problem, try to use PL/SQL script. 3. If PL/SQL script can't solve the problem, try to use JAVA script. 4. If JAVA script can't solve the problem, try to use C script. 5. If C script can't solve the problem, try to think whether the problem need to be solved.

Weekly Report Generation

Base on daily records to generate monthly report: select  trunc(price_date, 'day' )+ 1  Price_date,                       avg (price) price    from  dm_data_1   group   by  trunc(price_date, 'day' )

Monthly Report Generation

Base on daily records to generate monthly report:   Example: select  to_char(price_date,'yyyy-mm') Price_date,                       avg (price) price    from  dm_data_1   group   by  to_char(price_date,'yyyy-mm')

ORACLE DYNAMIC SQL Script

Attention: 1. the dynamic sql script do not need ';' 2. the ' in the script should be write as '' 3. there should be space in the script   ONE RECORD v_script:= 'SELECT to_char(min(PRICE_DATE),''yyyy/mm/dd'') from ' ||v_table_name_1|| '' ; DBMS_OUTPUT.PUT_LINE(v_script);       EXECUTE   IMMEDIATE  v_script7  into  v_table1_start;   v_script:='select description from dm_convert where result='''||v_t_result_1_tmp||''''; dbms_output.put_line(v_script); EXECUTE IMMEDIATE v_script into v_t_result_1;   MORE THAN ONE record v_script:= 'SELECT price from ' ||v_table_name_1|| ' where price_date between to_date(''' ||v_table1_start|| ''',''yyyy/mm/dd'') and to_date(''' ||v_table1_end|| ''',''yyyy/mm/dd'') order by ' ||v_table_name_1|| '.price_date' ; v_t1_id:= 1 ; DBMS_...

ORACLE Develop Example 1

Image
Description: Time series analysis   Requirement: below is the sturcture of the tables   Table ABI_DATA Name Type Nullable Default ID INTEGER No N/A PRICE_DATE DATE Yes N/A PRICE NUMBER Yes N/A Table ABI_MT Name Type Nullable Default ID INTEGER Yes N/A MT NUMBER Yes N/A Table ABI_QTET Name Type Nullable Default ID INTEGER Yes N/A QTET NUMBER Yes N/A Table ABI_QT Name Type Nullable Default ID INTEGER Yes N/A QT NUMBER Yes N/A Table ABI_MTET Name Type Nullable Default ID INTEGER Yes N/A MTET NUMBER Yes N/A Table ABI_RESULT Name Type Nullable Default ID INTEGER Yes N/A PRICE NUMBER Yes N/A Oracle Procedure Use PL/SQL Developer tool and command to trigger the oracle procedure ABI_DATA_PROCESS. The oracle procedure will clear the pervious data and information which ...