YN Wiki

website·Indexed 29 days ago

https://yn-wiki.com

A collection of personal learning notes and technical troubleshooting guides covering a wide range of technologies, including Web frontend and backend, Vue, React, JavaScript, HTTP, Oracle, MySQL, Layui, npm, and MyBatis-Plus-Join.

Tokens
6.1K
Snippets
34
Records
36
Agent score
48%

What's inside YN Wiki

  1. Perform a full refresh of an Oracle Materialized View

    To attempt a recovery from ORA-12034 or to synchronize a materialized view, you can perform a full refresh using the dbms_mview.refresh procedure. Use the 'C' parameter for a complete refresh.
    -- Identify the materialized view name
    SELECT mview_name, last_refresh_date, fullrefreshtim, increfreshtim
    FROM dba_mview_analysis;
    
    SELECT * FROM user_objects WHERE object_type='MATERIALIZED VIEW';
    
    -- Perform a full refresh (Replace 'MV_NAME' with your actual view name)
    EXEC dbms_mview.refresh('MV_NAME', 'C');
    EXEC dbms_mview.refresh('MV_NAME');
  2. Perform date arithmetic using the INTERVAL function in Oracle

    Use the INTERVAL keyword to add or subtract specific time durations (days, years, etc.) from a date. This is useful for querying ranges relative to a parameter or the current system date (SYSDATE).
    -- Query records between a parameter date and 2 days in the future
    WHERE table.date_column BETWEEN to_date(#{datetime}, 'YYYY-MM-DD HH24:MI:SS')
    AND (to_date(#{datetime}, 'YYYY-MM-DD HH24:MI:SS') + INTERVAL '2' DAY)
    
    -- Query records from the last 5 years relative to current system date
    SELECT * FROM oe.orders 
    WHERE order_date < (SYSDATE - INTERVAL '5' YEAR)
  3. Drop and recreate an Oracle Materialized View

    If a full refresh does not permanently resolve ORA-12034, drop the materialized view and recreate it. When recreating, ensure you include the rowid if using REFRESH FAST ON COMMIT to maintain performance and synchronization.
    -- Drop the existing materialized view
    DROP MATERIALIZED VIEW MV_FORCE_READ_CONTENT;
    
    -- Recreate the materialized view
    CREATE MATERIALIZED VIEW MV_CMS_FORCE_READ_CONTENT
    REFRESH FAST ON COMMIT
    AS
    SELECT rowid as rid, VALID_DATE, CONTENT_ID 
    FROM dd.user_table 
    WHERE VALIDITY = 'VALID';
  4. Refresh an Oracle Materialized View

    To resolve synchronization issues or update data in a materialized view, you can perform a full refresh using the DBMS_MVIEW.REFRESH procedure. First, identify the materialized view name using dba_mview_analysis or user_objects.
    -- Find the materialized view name
    SELECT mview_name, last_refresh_date, fullrefreshtim, increfreshtim
    FROM dba_mview_analysis;
    
    SELECT * FROM user_objects WHERE object_type='MATERIALIZED VIEW';
    
    -- Perform a full refresh ('C' stands for Complete refresh)
    EXEC dbms_mview.refresh('MV_FORCE_READ_CONTENT', 'C');
    -- Or a standard refresh
    EXEC dbms_mview.refresh('MV_FORCE_READ_CONTENT');
  5. Perform date arithmetic using the INTERVAL function in Oracle

    The INTERVAL function allows you to add or subtract specific time durations (days, years, etc.) from a date. This is useful for querying records within a specific range relative to a parameter or the current system date (SYSDATE). Note that the numeric value in the interval string typically supports up to two digits.
    -- Query records between a parameter date and 2 days in the future
    WHERE table.column BETWEEN to_date(#{datetime}, 'YYYY-MM-DD HH24:MI:SS')
    AND (to_date(#{datetime}, 'YYYY-MM-DD HH24:MI:SS') + INTERVAL '2' DAY)
    
    -- Query records from the previous X days
    -- Use INTERVAL '-X' DAY
    
    -- Query orders from the last 5 years using SYSDATE
    SELECT * FROM oe.orders 
    WHERE order_date < (SYSDATE - INTERVAL '5' YEAR)
  6. Retrieve values from Layui form fields

    Form field values can be retrieved using standard DOM methods or jQuery if available in the project.
    // Method 1: Direct DOM access
    var validEndDateInput = document.getElementById('validEndDate');
    var endDateValue = validEndDateInput.value;
    
    // Method 2: Using jQuery
    var endDateValue = $('#validEndDate').val();
  7. Format date fields for Layui Table via Java backend

    Alternatively, you can handle date formatting on the backend before sending the data to the frontend. In Java, use the @JsonFormat annotation from the Jackson library on the Date field to specify the desired pattern.
    import com.fasterxml.jackson.annotation.JsonFormat;
    
    @JsonFormat(pattern = "yyyy-MM-dd")
    private Date cDate;
  8. Define custom validation rules for Layui forms

    Custom validation rules are defined using form.verify(). Assign the rule name to the lay-verify attribute of the input element.
    <input type="text" name="schoolName" class="layui-input" lay-verify="rule2">
    form.verify({
        rule1 : function(value){
            if (value.length > 250) {
                return '最多输入250字'; // Max 250 characters
            }
        },
        rule2 : function(value){
            if(value.length < 1){
                return '不能为空,请选择'; // Cannot be empty
            }
        }
    });
  9. Fix 'npm ERR! could not determine executable to run' error

    If you encounter the error 'npm ERR! could not determine executable to run' within a project, you can resolve it by removing the Git hooks and reinstalling the project dependencies.
    # Remove all files in the .git/hooks directory
    rm -rf .git/hooks
    
    # Reinstall dependencies
    npm install
  10. Manage permissions for creating Materialized Views

    If you encounter error ORA-01031 (insufficient privileges) while creating a materialized view, you must grant the CREATE MATERIALIZED VIEW privilege to the user.
    -- Check who has the privilege
    SELECT * FROM DBA_SYS_PRIVS WHERE PRIVILEGE = 'CREATE MATERIALIZED VIEW';
    
    -- Grant the privilege to a specific user
    GRANT CREATE MATERIALIZED VIEW TO username;
  11. Fix 'npm ERR! could not determine executable to run' error

    If you encounter the error npm ERR! could not determine executable to run within a project, you can resolve it by removing the Git hooks and reinstalling the project dependencies.
    # 1. Remove all files in the .git/hooks directory
    rm -rf .git/hooks
    
    # 2. Reinstall dependencies
    npm install
  12. Manage permissions for creating Materialized Views

    If you encounter ORA-01031: insufficient privileges while creating a materialized view, you must grant the CREATE MATERIALIZED VIEW privilege to the user.
    -- Check which users have the privilege
    SELECT * FROM DBA_SYS_PRIVS WHERE PRIVILEGE = 'CREATE MATERIALIZED VIEW';
    
    -- Grant the privilege to a specific user
    GRANT CREATE MATERIALIZED VIEW TO username;