What does “%Type” mean in Oracle sql?

前端 未结 3 861
有刺的猬
有刺的猬 2021-01-30 13:22

I\'m getting my first experience with Oracle and TOAD (I know SSMS). I came across this \"%Type\" next to an input parameter in an update procedure and I have no idea what it is

3条回答
  •  星月不相逢
    2021-01-30 13:59

    some example

    set serveroutput on
    DECLARE
      var1  table_a.id%TYPE;
      var2  table_a.value%TYPE;
      var3_row table_a%ROWTYPE;
    BEGIN
      SELECT id,value
        INTO var1, var2
        FROM table_a
      WHERE id= 8 AND ROWNUM<=1; 
    
      SELECT id+100,value INTO var3_row from table_A where rownum=1;
    
      INSERT INTO table_a VALUES var3_row;
    
      dbms_output.put_line('this is a test');
      dbms_output.put_line(var1);
      dbms_output.put_line(var2);
      NULL;  -- do something useful here
    EXCEPTION
      WHEN NO_DATA_FOUND THEN
        NULL;  -- do something appropriate here
      WHEN TOO_MANY_ROWS THEN
        NULL;  -- do something appropriate here
    END;
    /
    

提交回复
热议问题