Express中创建触发器

Express中创建触发器

本文介绍了在Oracle Express中创建触发器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图在Oracle 11g Express和SQL Developer中执行自动递增之类的操作.我对Oracle知之甚少,而且对触发器也很陌生.

I was trying to do something like auto-increment in Oracle 11g Express and SQL Developer.I know very little about Oracle and I am also new to triggers.

我尝试运行此程序,但我不知道如何正确执行.

I tried running this, but I don't know how to do it properly.

CREATE TABLE theschema.thetable
(id NUMBER PRIMARY KEY,
name VARCHAR2(30));

CREATE SEQUENCE theschema.test1_sequence
START WITH 1
INCREMENT BY 1;

create or replace trigger insert_nums
before insert on theschema.thetable
for each row
begin
select test1_sequence.nextval into :new.id from dual;
end;
/

当我尝试创建触发器时,会出现一个屏幕,询问我一些绑定".该对话框只有一个复选框"null".这是什么意思,我该怎么做一个正常工作的脚本?

When I try to create the trigger, I get a screen which asks me for some "binds".The dialog box has only one check box "null". What does this mean and how do I makea script that works properly?

在进行这种自动增量"时要采取任何预防措施吗?

Any precautions to take while doing this kind of "auto-increment" ?

推荐答案

SQL Developer似乎认为您正在运行纯DML(数据操作)脚本,而不是DDL(数据定义)脚本.它还认为:new.id是可绑定变量.

It seems that SQL Developer thinks that you are running a plain DML (data manipulation) script, not a DDL (data definition). It also thinks that :new.id is a bindable variable.

为什么会这样,我不知道;为什么?我无法在Oracle SQL Developer 2.1中复制它.

Why this happens, I don't know; I can't reproduce it in Oracle SQL Developer 2.1.

尝试在theschema模式中打开一个新的SQL工作表窗口,并按(不是)执行整个"脚本(不是语句)

Try to open a new SQL worksheet window in the theschema schema and execute a "whole" script (not a statement) by pressing (not ).

这篇关于在Oracle Express中创建触发器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-18 20:37