SQL ステートメントで %TYPE 属性を使用して値をキャストしたいと考えています。%TYPE 属性を使用すると、型名をハードコーディングするのではなく、独自の宣言でフィールド、レコード、ネストされたテーブル、データベース列、または変数のデータ型を使用できます。
これは機能します:
insert into t1 select cast(v as varchar2(1)) from t2;
しかし、私はしたいです
insert into t1 select cast(v as t1.v%TYPE) from t2;
Error starting at line 16 in command:
insert into t1 select cast(v as t1.v%TYPE) from t2
Error at Command Line:16 Column:37
Error report:
SQL Error: ORA-00911: Ongeldig teken.
00911. 00000 - "invalid character"
*Cause: identifiers may not start with any ASCII character other than
letters and numbers. $#_ are also allowed after the first
character. Identifiers enclosed by doublequotes may contain
any character other than a doublequote. Alternative quotes
(q'#...#') cannot use spaces, tabs, or carriage returns as
delimiters. For all other contexts, consult the SQL Language
Reference Manual.
*Action:
これ(または同様のこと)を行うことはできますか?
編集: 私が達成しようとしているのは: t2.v が大きすぎる場合は切り捨てたいです。ハードコードされたフィールド長で substr を使用しないようにしています。したがって、substr(v,1,1) の代わりにキャスト(v as t1.v%TYPE)