質問

Here's a simple proc which defines 2 numeric fields, 1 as a Number, the other as Decimal, yet when I pass both to another procedures the decimal field is rounded to 0 dp, ie

IAMOUNT ends up with 9875.4321 but IUNITS ends up with 123

CREATE OR REPLACE PROCEDURE apex_public_user.badbdcall2
AS
  iamount NUMBER(15, 7);
  iunits  DECIMAL(15, 7);
  BEGIN
    iamount := 9875.4321;
    iunits := 123.567;

    BEGIN
      BADBDCALL2CALLME(
         IAMOUNT => iamount,
         IUNITS => iunits
      );
    END;
  END;

The receiving SQL:

CREATE OR REPLACE PROCEDURE badbdcall2callme(iamount IN OUT DECIMAL,
                                             iunits  IN OUT DECIMAL)
AS
  in_ds1 bde1000ds%ROWTYPE;
  BEGIN
    in_ds1.iamount := iamount;
    in_ds1.iunits := iunits;
  END;

If I debug the code, I can see that IUNITS becomes 38,0 which is the default for a decimal and IAMOUNT becomes a NUMBER (with out the 15,7), but I thought that parameters inherited the size of the field passed to it.

役に立ちましたか?

解決

Procedure and function parameters with one of the simple data types (VARCHAR2, NUMBER, etc) don't have a size or precision and always take the maximum size/precision of the underlying data type (VARCHAR2 or NUMBER).

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top