在Oracle中,您如何从表中读取Count(*)
变量?
在Microsoft SQL Server中,您可以这样做
select @variable = count(*) from Table where x=1;
我在Oracle中尝试过类似的尝试无效:
SELECT v_count_of_rows_bad := Count(*) FROM SCHEMANAME.TABLENAME WHERE ...;
答案 0 :(得分:2)
您使用SELECT INTO
SELECT COUNT(*)
INTO v_count_of_rows_bad
FROM schemaname.tablename
WHERE ...
答案 1 :(得分:1)
Easy Peasie:
DECLARE
v_count_of_rows_bad NUMBER;
BEGIN
SELECT COUNT(*) INTO v_count_of_rows_bad FROM SCHEMANAME.TABLENAME WHERE ...;
END