473,379 Members | 1,520 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,379 software developers and data experts.

PL/SQL Function

3
PL/SQL Function
--------------------------------------------------------------------------------

I have to populate a time table with 2 years say 2000 to 2001 dates with the following requirements

Table Time
(TIME_ID: NUMBER(6) NOT NULL
DT: DATE NOT NULL
DAY_OF_WK: NUMBER(1) NULL
DAY_NUM_MO: NUMBER(2) NULL
DAY_NUM_YR: NUMBER(3) NULL
MO_NM: VARCHAR2(10) NULL
QTR_NUM: NUMBER(1) NULL
YR: NUMBER(4) NULL)

DT is Date
DAY_OF_WEEK: This column gives us the numerical representation of the day of the week (Sunday = 1, Monday = 2, etc). Like isWeekday, you will want to make adjustments if your DATEFIRST setting does NOT consider Sunday to be the first day of the week.
DAY_NUM_MO:This column gives us the numerical representation of the month (January = 1, February = 2, etc). We can use this, for example, when we're looking for a cross-section of all events that have happened in March, regardless of year.
MO_NM: Name of the Month Jan,Feb,Mar,etc
QTR_NUM: every 3 months is a quarter.
YR: either its 2000 or 2001 year.

Any Suggestions how to go abt this? in PL/SQL function or a procedure to insert data. I know there is a way to do in SQL server but I need it for Oracle.

--------------------------------------------------------------------------------
Jul 25 '07 #1
1 3535
nutmeg
3
There are direct functions available for each of these in oracle, jus use the table
Format Mask Description

SCC or CC The century. If the SCC format is used BC dates are prefaced with a negative sign.
SYYYY or YYYY The four-digit year. If the SYYYY format is used BC dates are prefaced with a negative sign.
IYYY The four-digit ISO standard year.
YYY or YY or Y The last three, two, or one digits of the year.
IYY or IY or I The last three, two, or one digits of the ISO year.
Y.YYY The four-digit year with a comma.
YEAR or SYEAR
Year or SYear The year spelled out in uppercase or title case. The S prefix places a negative sign in front
of B.C. dates. The language is always English.
BC or AD The BC or AD indicator, without periods.
B.C. or A.D. The BC or AD indicator, with periods.
Q The quarter of the year from 1 through 4.
MM The number of the month in the year, from 01 through 12.
RM The Roman numeral representation of the month number.
MONTH or Month The name of the month in uppercase or title case in the language set by NLS_LANGUAGE
MON or Mon The abbreviated name of the month in uppercase or title case in the language set by NLS_LANGUAGE
WW The week in the year, from 1 through 53.
IW The ISO week in the year, from 1 through 52 or 53.
W The week in the month, from 1 through 5.
DDD The day in the year, from 1 through 366.
DD The day in the month, from 1 through 31.
D The day in the week, from 1 through 7. The starting day is determined by NLS_TERRITORY.
DAY or Day The name of the day in uppercase or title case format.
DY The 3 character abbreviated name of the day in the language set by NLS_LANGUAGE.
J The Julian day of the date; i.e., the number of days since 1 January 4712 BC
AM or PM The meridian indicator without periods.
A.M. or P.M. The meridian indicator with periods.
HH or HH12 The hour in the day, from 1 through 12.
HH24 The hour in the day, from 0 through 23.
MI The minutes component of the date/time, from 0 through 59.
SS The seconds component of the date/time, from 0 through 59.
sssss The number of seconds since midnight of the time component.
TH Suffix that converts a number to its ordinal format. The language is always English.
SP Suffix that converts a number to its spelled format. The language is always English.
SPTH Suffix that converts a number to its spelled and ordinal format. The language is always English.
Other text Any text in quotes will be reproduced in the formatted output of the conversion.
Date Format Models
Jul 26 '07 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: domeceo | last post by:
can anyone tell me why I cannot pass values in a setTimeout function whenever I use this function it says "menu is undefined" after th alert. function imgOff(menu, num) { if (document.images) {...
5
by: phil_gg04 | last post by:
Dear Javascript Experts, Opera seems to have different ideas about the visibility of Javascript functions than other browsers. For example, if I have this code: if (1==2) { function...
2
by: laredotornado | last post by:
Hello, I am looking for a cross-browser way (Firefox 1+, IE 5.5+) to have my Javascript function execute from the BODY's "onload" method, but if there is already an onload method defined, I would...
2
by: sushil | last post by:
+1 #include<stdio.h> +2 #include <stdlib.h> +3 typedef struct +4 { +5 unsigned int PID; +6 unsigned int CID; +7 } T_ID; +8 +9 typedef unsigned int (*T_HANDLER)(void); +10
8
by: Olov Johansson | last post by:
I just found out that JavaScript 1.5 (I tested this with Firefox 1.0.7 and Konqueror 3.5) has support not only for standard function definitions, function expressions (lambdas) and Function...
3
by: Beta What | last post by:
Hello, I have a question about casting a function pointer. Say I want to make a generic module (say some ADT implementation) that requires a function pointer from the 'actual/other modules'...
2
by: f rom | last post by:
----- Forwarded Message ---- From: Josiah Carlson <jcarlson@uci.edu> To: f rom <etaoinbe@yahoo.com>; wxpython-users@lists.wxwidgets.org Sent: Monday, December 4, 2006 10:03:28 PM Subject: Re: ...
28
by: Larax | last post by:
Best explanation of my question will be an example, look below at this simple function: function SetEventHandler(element) { // some operations on element element.onclick = function(event) {
4
by: alex | last post by:
I am so confused with these three concept,who can explained it?thanks so much? e.g. var f= new Function("x", "y", "return x * y"); function f(x,y){ return x*y } var f=function(x,y){
7
by: VK | last post by:
I was getting this effect N times but each time I was in rush to just make it work, and later I coudn't recall anymore what was the original state I was working around. This time I nailed the...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.