今天,我在数据库课上的大学讲师带来了PSP.
我已经使用了LAMP堆栈并进入开源,所以我对Oracle有偏见.但我知道,Oracle数据库在工业中使用,因此学习如何使用它是很好的.
但是,当我们覆盖PL/SQL Server页面(输出HTML并可以通过Web浏览器访问的Oracle数据库中的存储过程)时,我感到很沮丧.我的偏见是否会影响太多,与使用PHP和动态SQL查询相比,使用它有什么好处?PSP在使用Oracle的Web应用程序中有多受欢迎?
我想让一个没有经理的员工在我的桌子上展示,但当我知道这样的员工存在于数据库中时,所有我得到的都是"没有找到数据".
这是我的代码:
ACCEPT p_1 PROMPT 'Please Enter Employee ID:'
declare
v_eid employee.employee_id%TYPE := &p_1;
v_count NUMBER;
v_name employee.employee_name%TYPE;
v_sal employee.salary%type;
v_mname employee.employee_id%TYPE ;
v_dptname department.department_name%type;
v_avg employee.salary%type;
BEGIN
SELECT count(*)
INTO v_count
FROM employee
WHERE employee_id = v_eid;
IF v_count = 0 THEN
DBMS_OUTPUT.PUT_LINE(v_eid || ' is not in the table.');
ELSE
select e1.employee_name, e1.salary, department.department_name,
nvl(e2.employee_name, 0)
into v_name, v_sal, v_mname, v_dptname
from employee e1
inner join employee e2 on e1.manager_id = e2.employee_id
inner join department on e1.department_id = …Run Code Online (Sandbox Code Playgroud) 我正在尝试编写一个plsql查询,它允许我查询一组未存储在表中的已知值.假设这些已知值是以下字符串:
我想实现以下内容:
select * from [fill-in-the-blank] myvalues
where not myvalues in
(
select id from dbtable
)
..我试图确定哪些知识值不在数据库表中.
约束
有任何想法吗?
我有一个3"创建类型"语句的文件.我不明白为什么,当我运行脚本时,它只创建第一种类型.当我打开创建的类型时,我会在里面看到所有三个create语句.我在这里错过了什么?
码:
create type SplitPathTableType as table of varchar2(450);
create TYPE TSMNodesRecord AS OBJECT (
NodeID number(20),
IsDataNode number(1),
Path nvarchar2 (450),
ParentID number(20),
TimeStep number(20)
);
create type TSMNODESTABLE as table of TSMNODESRECORD;
Run Code Online (Sandbox Code Playgroud) 在以下sql语句中:
BEGIN
update table1 set col1 = 'Y';
commit;
update table2 set col2 = 'Y';
rollback;
end;
/
Run Code Online (Sandbox Code Playgroud)
它会回滚更新还是仅更新#2?
我希望有一个嵌套表来保存自定义对象,通过从多个游标逐个添加它们.但我不想在表格中有重复.我怎样才能做到这一点?
以下是我向表中添加元素的方法:
create type recipient as object (firstname varchar2, lastname varchar2, email varchar2);
declare type recipients_list is table of recipient;
rec recipients_list := recipients_list();
cursor admins is
select firstname, lastname, email
from users
where profile_id = 1;
cursor operators is
select firstname, lastname, email
from users
where operator = 1;
-- an user may be both admin and operator
....
for to_email in admins
loop
rec.extend;
rec(rec.last) := recipient(to_email.firstname, to_email.lastname, to_email.email);
end loop;
for to_email in operators
loop
rec.extend;
rec(rec.last) …Run Code Online (Sandbox Code Playgroud) 我有以下数据
1)MAXO_INSTR_INTERFACE
2)MAXIS_VENDOR_INTERFACE
3)MAXIMOS_EMPS_INTERFACE2
Run Code Online (Sandbox Code Playgroud)
我需要提取位于PL/SQL中两个下划线之间的String
INPUT EXPECTED OUTPUT
------------------------ ---------------
MAXO_INSTR_INTERFACE INSTR
MAXIS_VENDOR_INTERFACE VENDOR
MAXIMOS_EMPS_INTERFACE2 EMPS
Run Code Online (Sandbox Code Playgroud)
我尝试过子串函数,但我无法准确执行.
1:名称varchar2(30):='uu'|| '&(emp name)';
2:名称varchar2(30):='uu'|| '&emp name';
我不知道差异()是什么.
在第一种情况下,name = uu&(emo名称和
第二种情况,它促使用户输入值.
请任何机构解释我这背后的概念.
代码
SELECT some_identifier_id INTO a_someid_id FROM "SOME_IDENTIFIER" SOME_IDT
INNER JOIN "CASE" cse ON cse.customer_id = '1001'
INNER JOIN "MEASURE" m ON m.case_id = cse.case_id
WHERE SOME_IDT.some_identifier_type_code = '430101';
Run Code Online (Sandbox Code Playgroud)
给出"缺少关键字"错误.问题出在哪里?
说你有
select '9|2|6|7|5' as somedata from dual
Run Code Online (Sandbox Code Playgroud)
有没有办法,我可以做以下事情:
select
in_string_sort('|', a.somedata)
from
(select '9|2|6|7|5' as somedata from dual) a
Run Code Online (Sandbox Code Playgroud)
结果会是'2|5|6|7|9'什么?
我知道,我可以使用一个函数来实现它,但这是如此基本我想知道Oracle是否会为这类事情提供一些内置函数.
[编辑]忘记提及:这将在Oracle 10gR2中.