Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Why my bind variables I have defined don't print result in SQL*Plus ?

Quanwen ZhaoApr 28 2018 — edited May 11 2018

Hello, experts

I write a SQL for query MAX(sample_time) and MIN(sample_time) in the v$active_session_history.

But why bind variables I have defined don't print result ? The following is my operation steps,

set linesize 200 pagesize 200

set verify off

col min(sample_time) for a30

col max(sample_time) for a30

col oldest_sample for a30

col latest_sample for a30

variable oldest_sample   varchar2(30);

variable latest_sample   varchar2(30);

select min(sample_time), max(sample_time)

into   :oldest_sample, :latest_sample

from v$active_session_history;

print :oldest_sample;

print :latest_sample;

/

SQL> set linesize 200 pagesize 200

SQL> set verify off

SQL>

SQL> col min(sample_time) for a30

SQL> col max(sample_time) for a30

SQL>

SQL> col oldest_sample for a30

SQL> col latest_sample for a30

SQL>

SQL> variable oldest_sample   varchar2(30);

SQL> variable latest_sample   varchar2(30);

SQL>

SQL> select min(sample_time), max(sample_time)

  2  into   :oldest_sample, :latest_sample

  3  from v$active_session_history;

print :oldest_sample;

print :latest_sample;

MIN(SAMPLE_TIME)               MAX(SAMPLE_TIME)

------------------------------ ------------------------------

23-APR-18 04.22.28.784 PM      28-APR-18 12.03.33.343 PM

SQL>

OLDEST_SAMPLE

------------------------------

SQL>

LATEST_SAMPLE

------------------------------

Please give me some advice, thanks a lot.

Best Regards

Quanwen Zhao

This post has been answered by Cookiemonster76 on May 2 2018
Jump to Answer
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jun 6 2018
Added on Apr 28 2018
17 comments
4,160 views