Smart questions
Smart answers
Smart people
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Member Login




Remember Me
Forgot Password?
Join Us!

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips now!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

Join Tek-Tips
*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Donate Today!

Do you enjoy these
technical forums?
Donate Today! Click Here

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.
Jobs from Indeed

Link To This Forum!

Partner Button
Add Stickiness To Your Site By Linking To This Professionally Managed Technical Forum.
Just copy and paste the
code below into your site.

skydive (Programmer)
19 Jun 01 5:08
Hi All,

I am trying to write a database creation script and on one table I need to assign a default date to a column of data type "DATETIME YEAR TO MINUTE". I wish to assign the current date.
Any help would be great!

Blue Skies
Skydive.
olded (Programmer)
19 Jun 01 11:15
Skydive:

I don't know how your 'creation script' populates the tables, but use the current keyword.  The stored procedure below illustrates the concept.

An as we use to say in the airborne: Keep your feet and knees together!

Ed
Schaefer

-- This function returns a datetime year to minute
CREATE PROCEDURE ret_dt()
   RETURNING DATETIME YEAR TO MINUTE;
DEFINE dt_ret DATETIME YEAR TO MINUTE;

create temp table b (
   dts datetime year to minute
   ) with no log;

insert into b values (CURRENT);
select dts into dt_ret from b;

drop table b;

RETURN dt_ret;
END PROCEDURE;
skydive (Programmer)
19 Jun 01 11:37
Hi Ed,

Thanks for the reply,
I'll explain futher what I am trying to do:
I have a SQL script which creates the database and tables (I'm importing data afterwards using the MS-DTC from another DBMS)
Below you'll find the troublesome table, I have made the problem line in RED

create table report_result_head (
 report_result_id serial(10001) not null,
 report_name      varchar(50),
 served_flag      char(1)  default "n"
 check (served_flag is null or ( served_flag in ("y","n"))),

 create_date datetime year to minute default CURRENT,

 primary key (report_result_id)
 constraint pk_report_result_h
);

Thanks & Blue One's
Colin
olded (Programmer)
20 Jun 01 11:41
I believe you're going to have to write a trigger to make this happen.  I haven't written a trigger in several years, so I'd have to pull out the manual.

It you read the thread HELP WITH TRIGGERS right after this thread, it should give you some idea how to proceed.

regards,

Ed
skydive (Programmer)
20 Jun 01 11:56
Hi Ed,
Yeah I think you may be right, I wanted to stay away from using a trigger if possible but I can't see any other way of doing it.

Thanks Ed for your help.

Regards
Colin

olded (Programmer)
21 Jun 01 11:45
Colin:

Looks like I didn't help you all that much, but you're welcome.

Thanks,

Ed
Rosti (Programmer)
26 Jun 01 9:59
You need to use a TODAY function.
Use it on place of CURRENT function.

Rosti  
GRP (MIS)
16 Aug 01 1:12
Dear Friend,

Specify the exact date time qualifier at your default current. Replace the redlines with the following:

                                               
create_date datetime year to minute default current year to
minute,                                                  

Try this out.

G.R.P.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close