具体是这样的:
已存在这个表:CREATE TABLE temp_table (
num_col NUMBER,
char_col VARCHAR2(60)
);
的情况下,执行如下代码:
REM AnonymousBlock.sql
REM Chapter 3, Oracle9i PL/SQL Programming by Scott Urman
REM This is an example of an anonymous block.DECLARE
/* Declare variables to be used in this block. */
v_Num1 NUMBER := 1;
v_Num2 NUMBER := 2;
v_String1 VARCHAR2(50) := 'Hello World!';
v_String2 VARCHAR2(50) :=
'-- This message brought to you by PL/SQL!';
v_OutputStr VARCHAR2(50);
BEGIN
/* First, insert two rows into temp_table, using the values
of the variables. */
INSERT INTO temp_table (num_col, char_col)
VALUES (v_Num1, v_String1);
INSERT INTO temp_table (num_col, char_col)
VALUES (v_Num2, v_String2);
/* Now query temp_table for the two rows we just inserted, and
output them to the screen using the DBMS_OUTPUT package. */
SELECT char_col
INTO v_OutputStr
FROM temp_table
WHERE num_col = v_Num1;
DBMS_OUTPUT.PUT_LINE(v_OutputStr);
SELECT char_col
INTO v_OutputStr
FROM temp_table
WHERE num_col = v_Num2;
DBMS_OUTPUT.PUT_LINE(v_OutputStr);
/* Rollback our changes */
ROLLBACK;
END;
本应该输出结果:
Hello World!
-- This message brought to you by PL/SQL!
但为什么没有这样的结果:书上的例子估计用的系统是oracle 9i版本的,难道我的oracle 8.1.7版就不行吗?请各位高手赐教:是什么原因?
已存在这个表:CREATE TABLE temp_table (
num_col NUMBER,
char_col VARCHAR2(60)
);
的情况下,执行如下代码:
REM AnonymousBlock.sql
REM Chapter 3, Oracle9i PL/SQL Programming by Scott Urman
REM This is an example of an anonymous block.DECLARE
/* Declare variables to be used in this block. */
v_Num1 NUMBER := 1;
v_Num2 NUMBER := 2;
v_String1 VARCHAR2(50) := 'Hello World!';
v_String2 VARCHAR2(50) :=
'-- This message brought to you by PL/SQL!';
v_OutputStr VARCHAR2(50);
BEGIN
/* First, insert two rows into temp_table, using the values
of the variables. */
INSERT INTO temp_table (num_col, char_col)
VALUES (v_Num1, v_String1);
INSERT INTO temp_table (num_col, char_col)
VALUES (v_Num2, v_String2);
/* Now query temp_table for the two rows we just inserted, and
output them to the screen using the DBMS_OUTPUT package. */
SELECT char_col
INTO v_OutputStr
FROM temp_table
WHERE num_col = v_Num1;
DBMS_OUTPUT.PUT_LINE(v_OutputStr);
SELECT char_col
INTO v_OutputStr
FROM temp_table
WHERE num_col = v_Num2;
DBMS_OUTPUT.PUT_LINE(v_OutputStr);
/* Rollback our changes */
ROLLBACK;
END;
本应该输出结果:
Hello World!
-- This message brought to you by PL/SQL!
但为什么没有这样的结果:书上的例子估计用的系统是oracle 9i版本的,难道我的oracle 8.1.7版就不行吗?请各位高手赐教:是什么原因?
解决方案 »
- 这个sql语句咋写?
- oracle动态游标问题
- 请教一个sql语句或存储过程的写法
- 关于两个数据库之间通过database link来访问的问题
- 只有一个表空间的数据文件,怎么恢复啊?
- 请教一个超级简单的SQL输出结果
- 在触发器中用select查询数据,如果没查到会报“ora-01403:未找到数据”的错误,应该如何解决?
- 谁有EXPERT ONE-ON-ONE ORACLE的英文电子版?
- 安装oracle9的时候出现问题
- 关于一个oracle应用比较个性的架构
- unix下面有类似odbc的东西可以操作多种数据库吗
- 关于 ORA-03113: end-of-file on communication channel 的问题,在线等待!!!!!
sql>set serveroutput on
show serveroutput;
可查看