记录不显示结果
Records not showing results
CREATE TABLE manager (
mgrid INT PRIMARY KEY,
fname VARCHAR2(50),
city VARCHAR2(50)
);
以上为经理table.
&下面是我写的获取记录的代码
DECLARE
TYPE mgr_info IS RECORD (
mgrid manager.mgrid%TYPE,
fname manager.fname%TYPE,
city manager.city%TYPE
);
mgr mgr_info;
id manager.mgrid%TYPE;
name manager.fname%TYPE;
mcity manager.city%TYPE;
BEGIN
SELECT
mgrid,
fname,
city
INTO mgr
FROM
manager
WHERE
city = 'Mumbai';
id := mgr.mgrid;
name := mgr.fname;
mcity := mgr.city;
dbms_output.put_line('Manager ID = '
|| id
|| ' || Manager Name = '
|| name
|| ' || City = '
|| mcity);
EXCEPTION
WHEN no_data_found THEN
dbms_output.put_line('No Matching Record Found');
WHEN too_many_rows THEN
dbms_output.put_line('More than one matching Record Found');
END;
/
问题是我无法获得正确的输入,即使我有一行是住在孟买市的经理。
我没有做什么,我无法获得正确的输出。
以下是 table 的输入:
insert into manager values(101,'mohan','jaipur');
insert into manager values(102,'sohan','surat');
insert into manager values(103,'rohan', 'delhi');
insert into manager values(104,'jagmohan','mumbai');
table有Mumbai
,select有mumbai
。情况不同。 @Littlefoot 要求 INSERT
声明是正确的,没有它们我们无法提供帮助。
如果您希望 SELECT
起作用,您需要将 table 和查询折叠到相同的大小写:
WHERE lower(city) = lower('Mumbai')
CREATE TABLE manager (
mgrid INT PRIMARY KEY,
fname VARCHAR2(50),
city VARCHAR2(50)
);
以上为经理table.
&下面是我写的获取记录的代码
DECLARE
TYPE mgr_info IS RECORD (
mgrid manager.mgrid%TYPE,
fname manager.fname%TYPE,
city manager.city%TYPE
);
mgr mgr_info;
id manager.mgrid%TYPE;
name manager.fname%TYPE;
mcity manager.city%TYPE;
BEGIN
SELECT
mgrid,
fname,
city
INTO mgr
FROM
manager
WHERE
city = 'Mumbai';
id := mgr.mgrid;
name := mgr.fname;
mcity := mgr.city;
dbms_output.put_line('Manager ID = '
|| id
|| ' || Manager Name = '
|| name
|| ' || City = '
|| mcity);
EXCEPTION
WHEN no_data_found THEN
dbms_output.put_line('No Matching Record Found');
WHEN too_many_rows THEN
dbms_output.put_line('More than one matching Record Found');
END;
/
问题是我无法获得正确的输入,即使我有一行是住在孟买市的经理。
我没有做什么,我无法获得正确的输出。
以下是 table 的输入:
insert into manager values(101,'mohan','jaipur');
insert into manager values(102,'sohan','surat');
insert into manager values(103,'rohan', 'delhi');
insert into manager values(104,'jagmohan','mumbai');
table有Mumbai
,select有mumbai
。情况不同。 @Littlefoot 要求 INSERT
声明是正确的,没有它们我们无法提供帮助。
如果您希望 SELECT
起作用,您需要将 table 和查询折叠到相同的大小写:
WHERE lower(city) = lower('Mumbai')