如何查找表中长列的长度
我在名为 Files 的表中有一个名为 FileSize 的 LONG 列。
为了实现这一目标,我做了以下操作:
我编写了这个 PL/SQL 脚本来查找大小
declare
long_var LONG:=0;
begin
dbms_output.put_line(length(long_var));
execute immediate 'SELECT FILESIZE INTO long_var FROM FILES';
dbms_output.put_line(length(long_var));
end;
,但它抛出了一个错误:
ORA-00905: missing keyword
ORA-06512: at line 5
我正在执行以下操作,因为我在下面给出的链接上看到了以下内容: http://www.techonthenet.com/oracle/questions/long_length.php
有人可以建议我做错了什么,因为我无法识别我缺少的关键词,
谢谢。
I have a LONG column named FileSize in a table called Files.
To achieve the objective, I did the following :
I wrote this PL/SQL script to find the size
declare
long_var LONG:=0;
begin
dbms_output.put_line(length(long_var));
execute immediate 'SELECT FILESIZE INTO long_var FROM FILES';
dbms_output.put_line(length(long_var));
end;
But it throws an error :
ORA-00905: missing keyword
ORA-06512: at line 5
I was doing the following as I saw thw following on the link given below:
http://www.techonthenet.com/oracle/questions/long_length.php
Can some one suggest what I am doing wrong as I can not identify the key word I am missing
Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
在这种情况下,您不需要立即执行。
EXECUTE IMMEDIATE 从 PL/SQL 代码运行独立的 SQL 语句。它无法向您的代码返回任何内容。您使用的语句不是有效的 SQL,因此您会收到 ORA-00905。它是有效的 PL/SQL 代码,因此在删除 EXECUTE IMMEDIATE 后可以按您的预期工作。
编辑
您所关注问题的代码:要对多行执行此操作,您可以使用此代码
You don't need EXECUTE IMMEDIATE in this context.
EXECUTE IMMEDIATE runs a stand alone statement of SQL from your PL/SQL code. It can't return anything to your code. The statement you're using isn't valid SQL so you get the ORA-00905. It is valid PL/SQL code and so works as you'd expect once EXECUTE IMMEDIATE is removed.
Edit
Code for your follow on question: To do this with more than one row you can use this