DECLARE @count INT
SELECT @count = COUNT(*) FROM tests
SELECT @count AS totalCounts,* FROM tests这个是sqlserver语法。在oracle中,怎么写?
SELECT @count = COUNT(*) FROM tests
SELECT @count AS totalCounts,* FROM tests这个是sqlserver语法。在oracle中,怎么写?
解决方案 »
- 什么是OS备份?
- oracle 10g创建数据库提示‘ORA-01092: ORACLE 实例终止。强制断开连接’是怎么回事?
- 这个错误看了很久也不知道怎么解决,请帮帮忙啊??
- 我一个程序应为半分钟要读写一次数据库,看了下在Oracle中的连接数为5个,是不是有点大?
- 关于如何将select出来的数据插入到另外一张表的问题!
- 求助:PL/SQL中对项目数据库的导入/导出问题
- 如何知道“昨天”(关于DATE)
- 如何让一个job在每个星期第一天的凌晨1点自动执行
- trigger:每次update table1,table2字段值自增1,不运行?
- SQL小问题
- user_tables的问题,表删除后,user_tables还存在该表
- 求实现这样一个功能——简历(之二):
DECLARE @count INT
SELECT @count = COUNT(*) FROM tests
SELECT @count AS totalCounts,* FROM tests
*/
declare
cnt int := 0;
begin
select count(1) into cnt from tests;
select cnt as totalcounts,字段列表(请一一写出来 ORACLE不支持单表使用字段+*的用法) from tests;
end;
在行 1 上开始执行命令时出错:
declare
cnt int := 0;
begin
select count(*) into cnt from users;
select cnt as totalcounts,USERID,
USERNAME,
USERSEX,
USERAGE,
USERPASSWORD,
USERCREATETIME,
USERTYPEID from users;
end;
错误报告:
ORA-06550: 第 5 行, 第 3 列:
PLS-00428: 在此 SELECT 语句中缺少 INTO 子句
06550. 00000 - "line %s, column %s:\n%s"
*Cause: Usually a PL/SQL compilation error.
*Action:
比如说改成:
create table t_test as
select cnt as totalcounts,USERID,
USERNAME,
USERSEX,
USERAGE,
USERPASSWORD,
USERCREATETIME,
USERTYPEID from users;
SQLServer 执行SELECT @count AS totalCounts,* FROM tests直接就返回结果集Oracle必须声明一个动态游标返回结果集
declare
cnt number(20,0) := 0;
cur sys_refcursor;
begin
select count(*) into cnt from users;
open cur for
select cnt as totalcounts,USERID,
USERNAME,
USERSEX,
USERAGE,
USERPASSWORD,
USERCREATETIME,
USERTYPEID from users;
end;