The meaning of% TYPE in the Oracle stored procedure

Transfer:

The meaning of %type in the oracle stored procedure

Copyright statement: This article is a blogger’s original article, which follows the CC 4.0 BY-SA copyright agreement. Please attach the original source link and this statement for reprinting.

Link to this article: https://blog.csdn.net/qq_31279347/article/details/83820838

Example:

CREATE OR REPLACE
procedure getDeptById
(
v_deptno in dept.deptno%type
)
is
v_dname dept.dname%type;
v_loc dept.loc%type;
begin
select dname,loc into v_dname,v_loc from dept where deptno = v_deptno;
dbms_output.put_line(v_dname||‘***‘||v_loc);
end;
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • li>

  • 9
  • 10
  • 11< /li>
  • 12

v_deptno is a defined variable, dept is a table in the database, there is a deptno field in the table, and then% type is the data type of deptno.
The popular understanding is to let the type of the variable v_deptno match the type of the table field in the database, so that you don’t have to worry about the problem of type mismatch.

There are two advantages of using %type:

  • You don’t need to know the number of columns and data types in the referenced database.
  • The number of columns and data types in the referenced database can be changed in real time.

2018-11-07 11:43:56 lizhi_ma Reading number 1361

Classification column: Database

2018-11-07 11:43:56 lizhi_ma Reading number 1361

Classification column: Database

Classification column: Database

< p>

Copyright notice: This article is the original article of the blogger, and it follows the CC 4.0 BY-SA copyright agreement. Please attach the original source for reprinting Link and this statement.

Link to this article: https://blog.csdn.net/qq_31279347/article/details/83820838

Link to this article: https://blog.csdn.net/qq_31279347/article/details/83820838

Example:

CREATE OR REPLACE
procedure getDeptById
(
v_deptno in dept.deptno%type
)
is
v_dname dept.dname%type;
v_loc dept.loc%type;
begin
select dname,loc into v_dname,v_loc from dept where deptno = v_deptno;
dbms_output.put_line(v_dname||‘***‘||v_loc);
end;
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • li>

  • 9
  • 10
  • 11< /li>
  • 12

v_deptno is a defined variable, dept is a table in the database, there is a deptno field in the table, and then% type is the data type of deptno.
The popular understanding is to let the type of the variable v_deptno match the type of the table field in the database, so that you don’t have to worry about the problem of type mismatch.

There are two advantages of using %type:

  • You don’t need to know the number of columns and data types in the referenced database.
  • The number of columns and data types in the referenced database can be changed in real time.

WordPress database error: [Table 'yf99682.wp_s6mz6tyggq_comments' doesn't exist]
SELECT SQL_CALC_FOUND_ROWS wp_s6mz6tyggq_comments.comment_ID FROM wp_s6mz6tyggq_comments WHERE ( comment_approved = '1' ) AND comment_post_ID = 264 ORDER BY wp_s6mz6tyggq_comments.comment_date_gmt ASC, wp_s6mz6tyggq_comments.comment_ID ASC

Leave a Comment

Your email address will not be published.