我有两个表,当我进行插入时,我不想传输创建的数据,我想放入sysdate。我有下一个代码:
create or replace procedure procedure1 as
begin
INSERT INTO tlp
(given_name,
namel,
email, sysdate)
SELECT first_name,
namel,
mail
FROM glob
WHERE ( NOT EXISTS (SELECT email
FROM tlp
WHERE glob.mail = tlp.email )
AND glob.mail IS NOT NULL )
OR ( NOT EXISTS (SELECT namel
FROM tlp
WHERE glob.namel = tlp.namel )
--AND glob.mail IS NULL
);
end procedure1;
答案 0 :(得分:1)
create or replace procedure procedure1 as
begin
INSERT INTO tlp
(given_name,
namel,
email, sysdate)
SELECT first_name,
namel,
mail,
GETDATE() as sysdate
FROM glob
WHERE ( NOT EXISTS (SELECT email
FROM tlp
WHERE glob.mail = tlp.email )
AND glob.mail IS NOT NULL )
OR ( NOT EXISTS (SELECT namel
FROM tlp
WHERE glob.namel = tlp.namel )
--AND glob.mail IS NULL
);
end procedure1;
答案 1 :(得分:0)
在procedure
insert
tlp
中,为表4
提供的列数为columns
,而从表glob
中选择的3
为{ {1}}。
如果您想insert
sysdate
列表tlp
的一列,请提及
列名称并在sysdate
语句中添加select
。
假设tlp
的表结构是
tlp (
given_name,
namel,
email,
date_created --if clmn name is not "date_created", then change it in the proc.
)
现在试试这个;
create or replace procedure
procedure1 as
begin
INSERT INTO tlp (
given_name, namel,
email, date_created
)
SELECT
first_name, namel,
mail, sysdate --note sysdate is given in select query
FROM glob
WHERE (
NOT EXISTS (
SELECT email
FROM tlp
WHERE glob.mail = tlp.email
)
AND glob.mail IS NOT NULL
) OR (
NOT EXISTS (
SELECT namel
FROM tlp
WHERE glob.namel = tlp.namel
)
--AND glob.mail IS NULL
);
end procedure1;