CREATE FUNCTION PackContent
(
@region int, 
@action int, 
@object int, 
@mode int 
)
RETURNS int
AS 
BEGIN
DECLARE @content int
SET @region = @region * 0x01000000
SET @action = @action * 0x00010000
SET @object = @object * 0x00000100
SET @mode = @mode * 0x00000001
SET @content = @region | @action | @object | @mode
RETURN @content
END

解决方案 »

  1.   


    CREATE FUNCTION PackContent
    (
    region number,  
    action number,  
    object number,  
    mode number 
    )
    return number
    AS  
    content number;
    BEGIN
    region := region * 0x01000000;
    action := action * 0x00010000;
    object := object * 0x00000100;
    mode := mode * 0x00000001;
    content := region|action |object | mode;--这个是进行位与运算吗?
    RETURN content;
    END;
     
      

  2.   

    oracle 进行位运算 能用"|"么?不行吧!
      

  3.   

    那在ORACLE中进行位运算是那个符号啊?
      

  4.   

    没有吧,好像只有这个函数 BITAND(nExpression1, nExpression2)。
      

  5.   

    CREATE FUNCTION PackContent
    (
    region in number,  
    action in number,  
    object in number,  
    mode in number  
    )
    RETURN is number result number(10);BEGIN
        result := (region * 0x01000000) | (action * 0x00010000) | (object * 0x00000100) |(mode * 0x00000001);
    RETURN result;
    END;没去查 | 这个用什么代替,只是替你改了一下语法。注意几点就是:
    1.开头的create 定义传入参数要用 in ,返回参数定义也不一样;
    2.所有的语句结尾必须加分号;
    3.赋值用 :=,判断采用 = ;
    4.不支持对传入参数进行赋值,也就是说不能修改传入参数,要改就得另外给个变量;
    5.唯一省略的一点就是可以直接用 result 去替代你的返回变量。
    6.变量不用加@符号,因此变量定义最好有个命名规则,否则容易与字段名等混淆。
      

  6.   

    SET @region = @region * 0x01000000
    SET @action = @action * 0x00010000
    SET @object = @object * 0x00000100
    SET @mode = @mode * 0x00000001
    --这些是转换为16进行吗?
      

  7.   

    CREATE OR REPLACE FUNCTION PackContent
    (
      in_region IN NUMBER,
      in_action IN NUMBER,
      in_OBJECT IN NUMBER,
      in_MODE   IN NUMBER
    ) RETURN NUMBER AS
      content    NUMBER;
      in_region1 NUMBER;
      in_action1 NUMBER;
      in_OBJECT1 NUMBER;
      in_MODE1   NUMBER;
    BEGIN
      in_region1 := in_region * 64; -- 0x01000000;
      in_action1 := in_action * 16; -- 0x00010000;
      in_OBJECT1 := in_OBJECT * 4; -- 0x00000100;
      in_MODE1   := in_MODE * 1; --0x00000001;
      content    := in_region1 + in_action1 -
                                  BITAND(in_region1,
                                         in_action1);
    content:= content+in_OBJECT1 -bitand(content,in_object1);
    content:= content+in_OBJECT1 -bitand(content,in_MODE1);
      RETURN content;
    END;