Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/oracle/10.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Sql 在oracle中创建特定的值序列_Sql_Oracle_Oracle Apex_Sequence - Fatal编程技术网

Sql 在oracle中创建特定的值序列

Sql 在oracle中创建特定的值序列,sql,oracle,oracle-apex,sequence,Sql,Oracle,Oracle Apex,Sequence,我需要创建一个具有特定值的oracle序列 FOUR0001,FOUR0002,FOUR0003 增量必须按顺序进行。首先创建一个简单的序列 create sequence my_seq ; --start with 1 increment by 1 在使用序列存储数据的应用程序代码/表中,使用如下内容 INSERT INTO yourtab (col1) VALUES( 'FOUR'||lpad(my_seq.nextval,4,'0')); 首先创建一个简单的序列 create seq

我需要创建一个具有特定值的oracle序列

FOUR0001,FOUR0002,FOUR0003


增量必须按顺序进行。

首先创建一个简单的序列

create sequence my_seq ; --start with 1 increment by 1 
在使用序列存储数据的应用程序代码/表中,使用如下内容

INSERT INTO yourtab (col1) VALUES( 'FOUR'||lpad(my_seq.nextval,4,'0'));

首先创建一个简单的序列

create sequence my_seq ; --start with 1 increment by 1 
在使用序列存储数据的应用程序代码/表中,使用如下内容

INSERT INTO yourtab (col1) VALUES( 'FOUR'||lpad(my_seq.nextval,4,'0'));

您可以创建一个序列:

create sequence SEQ_NAME ...;
然后创建一个触发器,自动为字段提供数据:

CREATE OR REPLACE TRIGGER INS_TABLENAME
  before insert on TABLENAME
  for each row

BEGIN

  if :new.FIELD_NAME is null then
    :new.FIELD_NAME := 'FOUR'||lpad(SEQ_NAME.nextval,4,'0');
  end if;

END;

您可以创建一个序列:

create sequence SEQ_NAME ...;
然后创建一个触发器,自动为字段提供数据:

CREATE OR REPLACE TRIGGER INS_TABLENAME
  before insert on TABLENAME
  for each row

BEGIN

  if :new.FIELD_NAME is null then
    :new.FIELD_NAME := 'FOUR'||lpad(SEQ_NAME.nextval,4,'0');
  end if;

END;

我创建了一个从210开始的序列(因为我已经有209条记录),然后创建了下面的触发器

CREATE OR REPLACE trigger BIU_FRS  
  before insert or update on FOURNISSEUR             
  for each row 
begin  
  if :NEW.FRS_NUM is null then
    select ('FOUR'||lpad(four_seq.nextval,4,'0')) into :NEW.FRS_NUM from dual;
  end if;
  if inserting then
        :new.created    := localtimestamp;
        :new.created_by := nvl(wwv_flow.g_user,user);
    end if;
    :new.updated    := localtimestamp;
    :new.updated_by := nvl(wwv_flow.g_user,user);
end;

谢谢你@Kaushik Nayak和@Diego Souza

我已经创建了一个以210开头的序列(因为我已经有209条记录),然后创建了下面的触发器

CREATE OR REPLACE trigger BIU_FRS  
  before insert or update on FOURNISSEUR             
  for each row 
begin  
  if :NEW.FRS_NUM is null then
    select ('FOUR'||lpad(four_seq.nextval,4,'0')) into :NEW.FRS_NUM from dual;
  end if;
  if inserting then
        :new.created    := localtimestamp;
        :new.created_by := nvl(wwv_flow.g_user,user);
    end if;
    :new.updated    := localtimestamp;
    :new.updated_by := nvl(wwv_flow.g_user,user);
end;

谢谢@Kaushik-Nayak和@Diego-Souza创建一个普通序列,并在应用程序代码中添加带填充零的“四”?如何准确地添加它?创建序列“四”+=0209,增量为1 nocache-nocycle noorder/另请参见对类似问题的回答。创建一个普通序列,并在应用程序代码中添加带填充零的“四”?如何准确地添加它?创建序列“四”+=0209,增量为1 nocache nocycle noorder/另请参见对类似问题的回答。