| select sysdate from dual [message #125114] |
Thu, 23 June 2005 06:37  |
sneha_84
Messages: 21 Registered: May 2005
|
Junior Member |
|
|
Friends,
I gave a query
select sysdate from dual;
It returns two dates into screen.
My problem is
In one PLSQL code
when I use
select last_day(x_date) into dVar from dual;
is telling.
Oracle error selected rows are more than requested rows.
Can you friends suggest the reason is.
|
|
|
|
|
|
| Re: select sysdate from dual [message #125132 is a reply to message #125128] |
Thu, 23 June 2005 07:30   |
girish.rohini
Messages: 744 Registered: April 2005 Location: Delhi (India)
|
Senior Member |
|
|
HI Art
I too was thinking on same line that there someone has played with dual table...
& then for testing I started playing with my sys.dual table.
then before trying to rebuild dual table, i dropped it in my sys schema. Now I am struck in recreating it...
I recreated using my "create table statement..." but then all statements like "select sysdate from dual" etc are not working. I am getting "no rows selected" there.
I again dropped the table dual and the ran catalog.sql.
After this when i am trying to "desc dual" i am getting the error
"SP2-0749: Cannot resolve circular path of synonym "dual"".
Now can u advise how to resolve this issue.
Regds
Girish
|
|
|
|
| Re: select sysdate from dual [message #125134 is a reply to message #125132] |
Thu, 23 June 2005 07:53   |
girish.rohini
Messages: 744 Registered: April 2005 Location: Delhi (India)
|
Senior Member |
|
|
Got the table back.
[EDIT]: I dropped the public synonym dual.
I had to re-run sql.bsq script. from location @oracle_home/rdbms/admin.
Anyone... can pls suggest what can be the after-effects of running sql.bsq script again.
All suggesstions will be highly appreciated.
Regds
Girish
[Updated on: Thu, 23 June 2005 08:05] Report message to a moderator
|
|
|
|
|
|
| Re: select sysdate from dual [message #125188 is a reply to message #125114] |
Thu, 23 June 2005 13:50   |
Bill B
Messages: 1971 Registered: December 2004
|
Senior Member |
|
|
Do not EVER play with the dual table again. If you do, you can and will cause your database and applications to blow up!!!!! . To fix it (if it is dropped),
create table sys.dual ( DUMMY VARCHAR2(1));
insert into sys.dual values('X');
commit;
SQL> select count(*) from sys.dual;
COUNT(*)
----------
1
SQL> select * from sys.dual;
D
-
X
SQL>
If you get ANYTHING else, then your DUAL table is corrupted.
|
|
|
|
| Re: select sysdate from dual [message #125250 is a reply to message #125188] |
Fri, 24 June 2005 01:02   |
girish.rohini
Messages: 744 Registered: April 2005 Location: Delhi (India)
|
Senior Member |
|
|
Thnx Bill/Maaher for ur replies & providing me a way to resolve this issue.
Now, as i mentioned earlier, that I did got the table back by running sql.bsq script, my query regarding re-running this script on a already created live data base (for testing purpose)still persists. Of course... I wont be playing around with sys tables in my production database.
Whats the effect of running this script again on a database. Is it going to hamper / change something in my database.
Regds
Girish
[Updated on: Fri, 24 June 2005 01:02] Report message to a moderator
|
|
|
|
| Re: select sysdate from dual [message #125260 is a reply to message #125188] |
Fri, 24 June 2005 02:08   |
sneha_84
Messages: 21 Registered: May 2005
|
Junior Member |
|
|
One friend has said
SQL> select count(*) from sys.dual; must return 1. But I am getting 2. but select * from sys.dual is correct as he specified I am getting.
Is my sys.dual is correpted.
Expecting comments from group.
COUNT(*)
----------
1
SQL> select * from sys.dual;
D
-
X
SQL>
|
|
|
|
| Re: select sysdate from dual [message #125264 is a reply to message #125260] |
Fri, 24 June 2005 02:26   |
sneha_84
Messages: 21 Registered: May 2005
|
Junior Member |
|
|
Yes what our friend has said is correct.
My sy.dual was corrupted.
I truncate sys.dual
Then insert the data 'X'
Then when I test it is working OK.
Thanks for the Great Comment.
With regards
Sneha
/*
One friend has said
SQL> select count(*) from sys.dual; must return 1. But I am getting 2. but select * from sys.dual is correct as he specified I am getting.
Is my sys.dual is correpted.
Expecting comments from group.
COUNT(*)
----------
1
SQL> select * from sys.dual;
D
-
X
SQL>
*/
|
|
|
|
| Re: select sysdate from dual [message #125265 is a reply to message #125260] |
Fri, 24 June 2005 02:28   |
girish.rohini
Messages: 744 Registered: April 2005 Location: Delhi (India)
|
Senior Member |
|
|
Bill said:
| Quote: | Do not EVER play with the dual table again. If you do, you can and will cause your database and applications to blow up!!!!! . To fix it (if it is dropped),
create table sys.dual ( DUMMY VARCHAR2(1));
insert into sys.dual values('X');
commit;
SQL> select count(*) from sys.dual;
COUNT(*)
----------
1
SQL> select * from sys.dual;
D
-
X
SQL>
If you get ANYTHING else, then your DUAL table is corrupted.
|
Now comparing ur results with this shows that ur dual table is definitely corrupted.
Now one way to resolve this is:
truncate the table dual.
then insert value 'X' in sys.dual.
Then check for the result of both queries:
select * from dual;
&
select count(*) from dual;
Regds
Girish
|
|
|
|
| Re: select sysdate from dual [message #125377 is a reply to message #125114] |
Fri, 24 June 2005 15:26   |
Frank
Messages: 7901 Registered: March 2000
|
Senior Member |
|
|
@sneha_84
Since there should be only 1 row in dual, sql*plus is optimized for it. It just knows there is no need to fetch more than one row in case you issue a 'select * from dual'.
This is the reason a 'select * from dual' seems to return only one row, whereas a 'select count(*) from dual' returns the actual number of rows contained in dual. This is why Bill suggested to use both methods to test for the validity of your dual table.
hth
|
|
|
|
|
|
|
|
| Re: select sysdate from dual [message #125447 is a reply to message #125429] |
Sat, 25 June 2005 12:37  |
girish.rohini
Messages: 744 Registered: April 2005 Location: Delhi (India)
|
Senior Member |
|
|
Hi Maaher
Yes, I do agree & will never-ever play around with dictionary tables (unless otherwise advised by Support to do so).
Yes, it was really funny (actually it made me bang my head...) The only solace was I learnt it the easy way. The DB I played around with is the one installed on my desktop, which I can always reinstall.... But learnt something really important...
Thnx once again.
Regds
Girish
|
|
|
|