0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

[SQL][Oracle]備忘録 ファンクションの使用方法

Posted at

SQLファンクションの書き方

下記ファンクションのテンプレート

cnvt.sql  
--テンプレート
  CREATE OR REPLACE FUNCTION 任意の関数名(引数 varchar2)
  RETURN varchar2
  IS
     戻り値 varchar2(400);
  BEGIN
      SELECT
      
      INTO
        戻り値
   FROM
    変換テーブル名
   WHERE
  ;
   RETURN 戻り値;
   END;
   /
cnvt1.sql
  --使用例  
  CREATE OR REPLACE FUNCTION cnvt(test varchar2)
  RETURN varchar2
  IS
     ret_text varchar2(400);
  BEGIN
      SELECT
        col002
      INTO
        ret_text
   FROM
    変換テーブル名
   WHERE
       col001 = test
   RETURN ret_text;
   END;
   /
--説明
--関数cnvt 引数test
--引数のtestとcol001が同じ値の時、col002を戻り値として返す
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?