我需要编写一个触发器,防止在星期五下午5点到星期一上午9点之间插入.
我是否正在走下正轨,以为我需要从sysdate中提取日期/时间并按照这样的方式做一些事情
if
extract (day from sysdate) =>5
AND extract (hour from sysdate) =>17
AND extract (day from sysdate) =< 1
AND extract (hour from sysdate) =<9
THEN
...
Run Code Online (Sandbox Code Playgroud)
如果这是可怕的走错了,请告诉我.
我觉得令人沮丧的是,我对"指定星期几之间"的搜索结果毫无结果,也许有人可以建议更好的搜索方法?
我正在尝试在APEX中运行以下PLSQL脚本:
DECLARE
total NUMBER;
BEGIN
SELECT COUNT(*)
INTO total
FROM one_table;
FOR i IN 0:100 --This is line 8
LOOP
INSERT INTO other_table(id, column_a) SELECT id + i * total, column_a FROM one_table;
END LOOP;
COMMIT;
END;
Run Code Online (Sandbox Code Playgroud)
我收到这个错误:
ORA-06550: line 8, column 15: PLS-00103: Encountered the symbol "" when expecting one of the following: * & - + / at mod remainder rem .. <an exponent (**)> || multiset The symbol ".." was substituted for "" to continue.'
Run Code Online (Sandbox Code Playgroud) 我有一个plsql过程来删除子表和父表中的记录.
找到儿童记录时我想提出异常.
我怎样才能做到这一点?
CREATE OR REPLACE PROCEDURE myproc(
p_id number,
p_id2 number,
p_par3 number)
AS
BEGIN
DELETE FROM child_table
WHERE id1 = p_id and par=p_par3;
DELETE FROM parent_table
WHERE no = p_id2;
COMMIT;
EXCEPTION
WHEN OTHERS
THEN
--raise
END myproc;
/
Run Code Online (Sandbox Code Playgroud) 我创建了一个触发器,以便在更新位置时插入employeeID.在某些情况下,有许多员工连接到一个职位,因此触发器无法插入所有员工(仅1个).我需要所有的员工ID
可以帮我这个代码吗?
问候
create or replace trigger postn_updt
after update on postn
for each row
declare
cursor m is
select u.login
from user u,
party_per s
where u.row_id=s.person_id
and s.party_id=:new.row_id;
rownum varchar2(10);
begin
if updating ('postn_type_cd') then
open mult;
fetch mult into rownum;
insert into test123
(employee_number,type,request_date,remarks)
values
(( rownum,
'Updated',sysdate,''
);
close m;
end if;
end;
Run Code Online (Sandbox Code Playgroud) 我在Oracle中有一个查询(部分)看起来像这样:
where Doc3.clinicalDate >= ml.convert_date_to_id(:DateBegin)
and Doc3.clinicalDate < ml.convert_date_to_id(:DateEnd)
Run Code Online (Sandbox Code Playgroud)
当我将此查询放在SSRS中并设置报表和数据集参数时,它可以正常工作.但是,如果我将其粘贴到Oracle SQL Developer中,它会弹出一个窗口,要求我"输入绑定".当我输入"date'2011-06-01'"时,我收到错误"ORA-01858:找到一个非数字字符,其中数字是预期的".如何以实际可以理解的格式将日期传递给它?谢谢.
我需要在游标中插入大约300000行的一些插入,然而这运行得很慢,有关如何让它运行得更快的任何想法?我可以通过批量提交加快速度吗?所以例如我会在第1000行之后执行提交
DECLARE
CURSOR test_cursor IS
SELECT a from database.mytable
BEGIN
FOR curRow IN test_cursor LOOP
insert into tableb (testval)
values ('something');
commit;
END LOOP;
END;
Run Code Online (Sandbox Code Playgroud) 当我只有一个状态代码作为参数时,这可以工作.
当我在parm_list中有多个state_code时,如何让代码工作?
要求:
(1)我不想在光标定义中硬编码状态代码
(2)我确实想在where子句中允许多个州代码
例如:我想为parm_list =('NY','NJ','NC')运行此代码.我在将parm_list中的单引号与'where state_code in'查询中的单引号进行协调时遇到了困难.
set serveroutput on;
DECLARE
parm_list varchar2(40);
cursor get_state_codes(in_state_codes varchar2)
is
select state_name, state_code from states
where state_code in (in_state_codes);
BEGIN
parm_list := 'NY';
for get_record in get_state_codes(parm_list) loop
dbms_output.put_line(get_record.state_name || get_record.state_code);
end loop;
END;
Run Code Online (Sandbox Code Playgroud) 在Oracle中,我有一个包含列(X)的表,它可以包含这样的字符串:
97M
481
101X
88
21E
等
我想只选择那些x> 90的整数值的行.在这个例子中,我希望得到包含值97M,101X和481的行.我该怎么做?
我有一个select语句,需要在我的pl/sql中选择几十列到自定义变量中.如下所示:
select col1,
col2,
....
col30
into var1,
...
var30
from table
where ....
Run Code Online (Sandbox Code Playgroud)
在执行SP时遇到错误:
ORA-06502:PL/SQL:数字或值错误:字符串缓冲区太小
错误信息仅指出select语句的第一行号.即使我可以弄清楚我定义的变量太小而无法容纳列,但仍然难以精确定位错误定义的变量.这不是我调试此sp的有效方法.
有什么好主意,请告诉我.
我想执行一个触发器,应该应用于除一个用户之外的所有用户.
我怎么写这个?
请提供一个简单的代码示例?