If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > DB2 > Stupid question

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 12-09-04, 05:24
nelapsi nelapsi is offline
Registered User
 
Join Date: Dec 2004
Posts: 43
Stupid questions

Sorry for stupid question and for my poor english, but how i can to find a sin(5) ?
In postgres i just type 'select sin(5)', but in DB2 it doesnt work :-((

Last edited by nelapsi; 12-09-04 at 05:42.
Reply With Quote
  #2 (permalink)  
Old 12-09-04, 05:30
okman okman is offline
Registered User
 
Join Date: Oct 2004
Posts: 4
Try

Code:
select sin(5) from sysibm.sysdummy1
Reply With Quote
  #3 (permalink)  
Old 12-09-04, 05:39
nelapsi nelapsi is offline
Registered User
 
Join Date: Dec 2004
Posts: 43
Quote:
Originally Posted by okman
Try

Code:
select sin(5) from sysibm.sysdummy1
thanks
can you say, how i can select nextval from sequence:?
Reply With Quote
  #4 (permalink)  
Old 12-09-04, 09:34
urquel urquel is offline
Registered User
 
Join Date: Aug 2004
Posts: 330
Be aware that the DB2 sine function is the sine of an angle expressed in RADIANS.
Reply With Quote
  #5 (permalink)  
Old 12-09-04, 10:49
bmujeeb bmujeeb is offline
Registered User
 
Join Date: Mar 2004
Posts: 448
db2 "values nextval for <sequence_name>"

You can also use

db2 "select nextval for test_seq from sysibm.sysdummy1"

regards

Mujeeb
Reply With Quote
  #6 (permalink)  
Old 12-10-04, 07:51
nelapsi nelapsi is offline
Registered User
 
Join Date: Dec 2004
Posts: 43
Quote:
Originally Posted by okman
Try

Code:
select sin(5) from sysibm.sysdummy1
i've found more simple method :
values(sin(5))
$)
Reply With Quote
  #7 (permalink)  
Old 12-10-04, 09:23
urquel urquel is offline
Registered User
 
Join Date: Aug 2004
Posts: 330
Or even more simply -0.95892427466313846889315440615599 and bypass the DBMS altogether.
Reply With Quote
  #8 (permalink)  
Old 12-10-04, 10:03
nelapsi nelapsi is offline
Registered User
 
Join Date: Dec 2004
Posts: 43
Another stupid question :)

How can I get in seconds time elapsed since 1970 year?
Reply With Quote
  #9 (permalink)  
Old 12-10-04, 10:16
n_i n_i is offline
:-)
 
Join Date: Jun 2003
Location: Toronto, Canada
Posts: 4,449
We've had this discussion before:
http://www.dbforums.com/t1004639.html
Reply With Quote
  #10 (permalink)  
Old 12-17-04, 13:44
nelapsi nelapsi is offline
Registered User
 
Join Date: Dec 2004
Posts: 43
another stupid question

please someone give an example of function (in sql) with "select into" statement....
I newbie in DB2 and I try this
Code:
create function tf() returns integer
language sql
not deterministic
no external action
begin atomic
    declare iii integer default 7;
    select id into iii from tt;
    return iii;
end@
Code:
but I have error :SQL0104N  An unexpected token "iii" was found following ";     select id
into".  Expected tokens may include:  "<space>".  LINE NUMBER=7.
SQLSTATE=42601
Reply With Quote
  #11 (permalink)  
Old 12-17-04, 14:08
ARWinner ARWinner is offline
Registered User
 
Join Date: Jan 2003
Posts: 3,575
Try:

create function tf() returns integer
language sql
not deterministic
no external action
begin atomic
declare iii integer default 7;
set (iii) = (select id from tt);
return iii;
end@

Andy
Reply With Quote
  #12 (permalink)  
Old 12-18-04, 05:32
nelapsi nelapsi is offline
Registered User
 
Join Date: Dec 2004
Posts: 43
Help!

please, smb, give an example of procedure (in sql) with out parameter and with calling of another stored procedures
I've tried this
Code:
CREATE PROCEDURE tp(ss varchar(100), out ret integer)
language sql
begin
    set (ret) = (select id from tt);
    insert into tt1 values(12, ss);
end@
and take an error...
and another question.
can I use an user defined type in pocedures?
Reply With Quote
  #13 (permalink)  
Old 12-18-04, 07:55
nelapsi nelapsi is offline
Registered User
 
Join Date: Dec 2004
Posts: 43
call procedure from procedure

Why this procedure
Code:
CREATE PROCEDURE UTIL.CREATE_USER (u_login varchar(100), pass varchar(100), u_email varchar(100), comm varchar(100), person integer, uuser integer)
LANGUAGE SQL
begin atomic
    declare ret integer;
    select max(id) + 1 into ret from UTIL.Users;
    insert into UTIL.Users values (ret, u_login, pass, u_email, comm, nullif(person,0), 0);
    call util.set_user_right ('UTIL', 'Users', ret, uuser, 31);

end@
generates an error:
Code:
SQL0104N  An unexpected token "''UTIL'', ''Users''" was found following
"til.set_user_right (".  Expected tokens may include:  "<psm_var_list_input>".
LINE NUMBER=9.  SQLSTATE=42601
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On