Vedswarup Rai wrote:
> hi
>
> Is there any table in Sybase SQL Server that works like the 'dual' table in
> Oracle?
> Like I used to do
> select sysdate from dual;
>
> Can I do a similar thing in sqbase?
Knowing nothing about how a "dual" table works (perhaps some more explanation
is in order?), it sounds like the Sybase equivalent is:
select getdate()
-bret
select getdate() works fine in the Database Painter. I need to do a similar
thing in the script.
I cannot do a
select getdate() into :my_date
in the script.
in Oracle, I would do
select sysdate into :my_date from dual
which would return me just one row with the system date.
I am now doing
select distinct getdate() into :my_date from sysobjects;
As sysobjects would have many rows, I would prefer something more
efficient. Without using DISTINCT
Rgds and Thnx
Ved
"Bret Halford" <br...@sybase.com> wrote in message
news:38C3D795...@sybase.com...
Yes, you can do something similar in Sybase.
As Bret mentioned, use the equivalent to 'sysdate' ('getdate()') and
drop the 'from' clause, e.g.:
select getdate()
I'm not sure about Russ's suggestion of using 'dummy' in place of 'dual'
... not questioning Russ's information ... I've just never used it so I
can't comment on it.
------------------
What I found in Oracle is that there is no such thing as 'select
@variable/function()/constants' *WITHOUT* a 'from' clause. In other
words they try to stick to the generic, base format of a 'select', e.g.:
select <select_list> from <table>
Since you may want to 'select' something that does not exist in a table
(e.g., sysdate), Oracle threw in a dummy table ('dual') which you can
use in the 'from' clause of your 'select' statement. (If I remember
correctly, I believe that 'dual' is an actual table with one row and one
column???)
With Sybase ... welllllll ... they just said "The heck with it, we ain't
gonna require no schtinkin' 'from' clause in a 'select' where the user
just wants to select/return a @variable or function()/constants!". In
other words, Sybase allows you to use a 'shorthand' version of the
'select' statement that does not require the 'from' clause.
Anyway, as Bret said, the Sybase equivalent to what you're trying to do
is:
select getdate()
Other exampls of Sybase 'shorthand' select's includes:
select suser_name()
select object_name(1)
select @@servername
select @@version
select @id (assuming you have a variable called '@id' defined)
select "look ma, no 'from' clause"
select 5
If Russ's suggestion works ('from dummy') ... and you prefer this method
... more power to ya, buddie! <g>
--
Mark Parsons
Pegasys Ltd
* As far as i remember from old days, dual in Oracle is used to "select"
constant values.
it is a virtual table for this purpose.because, i think you can not use
select statement without from clause in Oracle. it was a must. so there is
no such obligation in Sybase.feel free to select any constant without using
from clause like "select @myvalue" .
bye
Vedswarup Rai wrote in message ...
>hi
>
>Is there any table in Sybase SQL Server that works like the 'dual' table in
>Oracle?
>Like I used to do
>select sysdate from dual;
>
>Can I do a similar thing in sqbase?
>
>TIA
>Ved
>
>
>