Help with date format in Procedure...
Hi,
I am very new to orcale development.... as my requirement have asked me i have written a procedure
Procedure
create or replace
procedure MEXICO_NAFTA_CERTIFICATE_EXT (
f_org_id NUMBER,
f_customer_nbr_base NUMBER,
f_customer_nbr_sufx number,
f_year VARCHAR2)
is
output_file utl_file.file_type;
o_filename VARCHAR2(50):= 'MEXICO_NAFTA_CERTIFICATE_EXT.txt';
o_DataDir CONSTANT VARCHAR2 (30) := '/d014/oradata/temp';
v_CERTIFICATE_NBR fta.SAP_CERTIFICATES_EXTRACT_VIEW.CERTIFICATE_NBR%type;
v_PART171 fta.SAP_CERTIFICATES_EXTRACT_VIEW.PART171%type;
v_HTS_CDE fta.SAP_CERTIFICATES_EXTRACT_VIEW.HTS_CDE%type;
v_ORIGINATING_IND fta.SAP_CERTIFICATES_EXTRACT_VIEW.ORIGINATING_IND%type;
v_ISO_COUNTRY_CDE fta.SAP_CERTIFICATES_EXTRACT_VIEW.ISO_COUNTRY_CDE%type;
v_BASIS_CDE fta.SAP_CERTIFICATES_EXTRACT_VIEW.BASIS_CDE%type;
v_PRODUCER_CDE fta.SAP_CERTIFICATES_EXTRACT_VIEW.PRODUCER_CDE%type;
v_CERT_CDE fta.SAP_CERTIFICATES_EXTRACT_VIEW.CERT_CDE%type;
v_REGIONAL_VALUE_CONTENT_CDE fta.SAP_CERTIFICATES_EXTRACT_VIEW.REGIONAL_VALUE_CONTENT_CDE%type;
v_PART_NBR fta.SAP_CERTIFICATES_EXTRACT_VIEW.PART_NBR%type;
v_EFFECTIVE_DATE fta.SAP_CERTIFICATES_EXTRACT_VIEW.EFFECTIVE_DATE%type;
v_EFFECTIVE_FROM_DATE fta.SAP_CERTIFICATES_EXTRACT_VIEW.EFFECTIVE_FROM_DATE%type;
v_EFFECTIVE_TO_DATE fta.SAP_CERTIFICATES_EXTRACT_VIEW.EFFECTIVE_TO_DATE%type;
v_TRANSACTION_DATE fta.SAP_CERTIFICATES_EXTRACT_VIEW.TRANSACTION_DATE%type;
v_INACTIVE_IND fta.SAP_CERTIFICATES_EXTRACT_VIEW.INACTIVE_IND%type;
CURSOR Cert_ext IS select certificate_nbr,
part171,
inactive_ind,
hts_cde,
originating_ind,
iso_country_cde,
basis_cde,
producer_cde,
cert_cde,
regional_value_content_cde,
part_nbr,
to_char(effective_date, 'mm-dd-yy'),
to_char(effective_from_date, 'mm-dd-yy'),
to_char(effective_to_date, 'mm-dd-yy'),
to_char(transaction_date, 'mm-dd-yy')
from fta.SAP_CERTIFICATES_EXTRACT_VIEW
where org_id= f_org_id AND
customer_nbr_base= f_customer_nbr_base AND
customer_nbr_sufx = f_customer_nbr_sufx AND
to_char(effective_from_date,'yy')=f_year AND
to_char(effective_to_date, 'YY')=f_year;
begin
output_File := UTL_FILE.FOPEN (o_DataDir, o_FileName, 'w');
OPEN Cert_ext;
loop
fetch Cert_ext into v_CERTIFICATE_NBR ,
v_PART171 ,
v_INACTIVE_IND,
v_HTS_CDE ,
v_ORIGINATING_IND ,
v_ISO_COUNTRY_CDE ,
v_BASIS_CDE ,
v_PRODUCER_CDE ,
v_CERT_CDE ,
v_REGIONAL_VALUE_CONTENT_CDE ,
v_PART_NBR,
v_effective_date,
v_effective_from_date,
v_effective_to_date,
v_transaction_date ;
EXIT WHEN Cert_ext%NOTFOUND;
UTL_FILE.PUT_LINE (output_File, v_CERTIFICATE_NBR || ' '||
v_PART171 || ' '||
v_INACTIVE_IND || ' '||
v_HTS_CDE || ' '||
v_ORIGINATING_IND || ' '||
v_ISO_COUNTRY_CDE || ' '||
v_BASIS_CDE || ' '||
v_PRODUCER_CDE || ' '||
v_CERT_CDE || ' '||
v_REGIONAL_VALUE_CONTENT_CDE || ' '||
v_PART_NBR || ' '||
v_EFFECTIVE_DATE || ' '||
v_EFFECTIVE_FROM_DATE || ' '||
v_EFFECTIVE_TO_DATE || ' '||
v_TRANSACTION_DATE );
UTL_FILE.FCLOSE (output_File);
DBMS_OUTPUT.PUT_LINE ('Data Extracted');
end loop;
close Cert_ext;
END MEXICO_NAFTA_CERTIFICATE_EXT;
it got executed without errors...when i compile it with following values
declare
begin
MEXICO_NAFTA_CERTIFICATE_EXT('0048', '00254101', '11', '03');
end;
I get errors as
ERROR at line 4:
ORA-01843: not a valid month
ORA-06512: at "FTA_SOURCE.MEXICO_NAFTA_CERTIFICATE_EXT", line 56
ORA-06512: at line 3
i know where the error is its with f_year date type but i am not able to eleminate it... the value of f_year is give as '03' and has to be compared to dates and retrive the data.... Can any one say me how to slove this...
Thanks!!
As you have said Plan1
create or replace
procedure MEXICO_NAFTA_CERTIFICATE_EXT (
f_org_id NUMBER,
f_customer_nbr_base NUMBER,
f_customer_nbr_sufx number,
f_year VARCHAR2)
is
output_file utl_file.file_type;
o_filename VARCHAR2(50):= 'MEXICO_NAFTA_CERTIFICATE_EXT.txt';
o_DataDir CONSTANT VARCHAR2 (30) := '/d014/oradata/temp';
v_CERTIFICATE_NBR fta.SAP_CERTIFICATES_EXTRACT_VIEW.CERTIFICATE_NBR%type;
v_PART171 fta.SAP_CERTIFICATES_EXTRACT_VIEW.PART171%type;
v_HTS_CDE fta.SAP_CERTIFICATES_EXTRACT_VIEW.HTS_CDE%type;
v_ORIGINATING_IND fta.SAP_CERTIFICATES_EXTRACT_VIEW.ORIGINATING_IND%type;
v_ISO_COUNTRY_CDE fta.SAP_CERTIFICATES_EXTRACT_VIEW.ISO_COUNTRY_CDE%type;
v_BASIS_CDE fta.SAP_CERTIFICATES_EXTRACT_VIEW.BASIS_CDE%type;
v_PRODUCER_CDE fta.SAP_CERTIFICATES_EXTRACT_VIEW.PRODUCER_CDE%type;
v_CERT_CDE fta.SAP_CERTIFICATES_EXTRACT_VIEW.CERT_CDE%type;
v_REGIONAL_VALUE_CONTENT_CDE fta.SAP_CERTIFICATES_EXTRACT_VIEW.REGIONAL_VALUE_CONTENT_CDE%type;
v_PART_NBR fta.SAP_CERTIFICATES_EXTRACT_VIEW.PART_NBR%type;
v_EFFECTIVE_DATE fta.SAP_CERTIFICATES_EXTRACT_VIEW.EFFECTIVE_DATE%type;
v_EFFECTIVE_FROM_DATE fta.SAP_CERTIFICATES_EXTRACT_VIEW.EFFECTIVE_FROM_DATE%type;
v_EFFECTIVE_TO_DATE fta.SAP_CERTIFICATES_EXTRACT_VIEW.EFFECTIVE_TO_DATE%type;
v_TRANSACTION_DATE fta.SAP_CERTIFICATES_EXTRACT_VIEW.TRANSACTION_DATE%type;
v_INACTIVE_IND fta.SAP_CERTIFICATES_EXTRACT_VIEW.INACTIVE_IND%type;
CURSOR Cert_ext IS select certificate_nbr,
part171,
inactive_ind,
hts_cde,
originating_ind,
iso_country_cde,
basis_cde,
producer_cde,
cert_cde,
regional_value_content_cde,
part_nbr,
effective_date,
effective_from_date,
effective_to_date,
transaction_date
from fta.SAP_CERTIFICATES_EXTRACT_VIEW
where org_id= f_org_id AND
customer_nbr_base= f_customer_nbr_base AND
customer_nbr_sufx = f_customer_nbr_sufx AND
to_char(effective_from_date,'yy')=f_year AND
to_char(effective_to_date, 'YY')=f_year;
begin
output_File := UTL_FILE.FOPEN (o_DataDir, o_FileName, 'w');
OPEN Cert_ext;
loop
fetch Cert_ext into v_CERTIFICATE_NBR ,
v_PART171 ,
v_INACTIVE_IND,
v_HTS_CDE ,
v_ORIGINATING_IND ,
v_ISO_COUNTRY_CDE ,
v_BASIS_CDE ,
v_PRODUCER_CDE ,
v_CERT_CDE ,
v_REGIONAL_VALUE_CONTENT_CDE ,
v_PART_NBR,
v_effective_date,
v_effective_from_date,
v_effective_to_date,
v_transaction_date ;
EXIT WHEN Cert_ext%NOTFOUND;
UTL_FILE.PUT_LINE (output_File, v_CERTIFICATE_NBR || ' '||
v_PART171 || ' '||
v_INACTIVE_IND || ' '||
v_HTS_CDE || ' '||
v_ORIGINATING_IND || ' '||
v_ISO_COUNTRY_CDE || ' '||
v_BASIS_CDE || ' '||
v_PRODUCER_CDE || ' '||
v_CERT_CDE || ' '||
v_REGIONAL_VALUE_CONTENT_CDE || ' '||
v_PART_NBR || ' '||
to_char(v_EFFECTIVE_DATE, 'mm-dd-yy') || ' '||
to_char(v_EFFECTIVE_FROM_DATE, 'mm-dd-yy') || ' '||
to_char(v_EFFECTIVE_TO_DATE, 'mm-dd-yy') || ' '||
to_char(v_TRANSACTION_DATE, 'mm-dd-yy'));
UTL_FILE.FCLOSE (output_File);
DBMS_OUTPUT.PUT_LINE ('Data Extracted');
end loop;
close Cert_ext;
END MEXICO_NAFTA_CERTIFICATE_EXT;
1 declare
2 begin
3 MEXICO_NAFTA_CERTIFICATE_EXT('0048', '00254101', '11', '03');
4* end;
5 /
declare
ERROR at line 1:
ORA-29282: invalid file ID
ORA-06512: at "SYS.UTL_FILE", line 774
ORA-06512: at "FTA_SOURCE.MEXICO_NAFTA_CERTIFICATE_EXT", line 74
ORA-06512: at line 3
it dint work... i will surely try others and post you
Similar Messages
-
Help with date formatting.
Hi,
I have been asked to fix a problem with a report. I have found that the problem is the date format being passed to the stored procedure is not correct, The current format is like Mon April 04 2007. The correct format should be DD-MMM-YYYY which I take to be Mon Apr 04 2004. I am not sure if this is correct anyway, but after looking at the code and the api I have managed to create a date object and call toString on it, after setting a simple date format to dd MMM yyyy.
The problem is that the toString method returns Mon Apr 02 00:00:00 BST 20
07. Is anybody able to help me with this? Below is a little bit of the code:
public void renderDailyReport(ServletWriter out, HttpServletRequest request) throws Exception {
// reset counters
totalHits = 0;
maxHits = 0;
minHits = 0;
// get a GregorianCalendar object using the startDate and endDate Strings
SimpleDateFormat sdf = new SimpleDateFormat("dd MMMM yyyy", Locale.UK);
SimpleDateFormat procedureDateFormat = new SimpleDateFormat("dd MMM yyyy", Locale.UK);
GregorianCalendar dateCounter = new GregorianCalendar();
GregorianCalendar upperLimit = new GregorianCalendar();
sdf.setCalendar(Calendar.getInstance());
Date sd = sdf.parse(startDate);
Date ed = sdf.parse(endDate);
procStartDate = procedureDateFormat.parse(startDate);
procEndDate = procedureDateFormat.parse(endDate);The procStart and end dates are the bits that I added.
They are passed to the stored procedure calling .toString, they are date objects.
Appreciate any help.Do not use the toString() method of Date - it will always be the same format.
Use the format() method of SimpleDateFormat.
Date d = new Date();
SimpleDateFormat sdf = new SimpleDateFormat("'dd-MMM-yyyy"); // or something like this
String s = sdf.format(d);Message was edited by:
jbish -
Pls Help with date format picture ends ......error
Hi Everyone,
I am getting the following error when I run my crystal report.
Failed to retrieve data from the database.
Details: HY000:[DataDirect][ODBC Oracle driver][Oracle]ORA-01830: date format picture ends before converting entire input string
[Database Vendor Code: 1830]
I am using SQL Command for my report and in the command my date fields are of "Date" datatype.
I am using Crystal Reports XI R2,driver - CR Oracle ODBC Driver 5.1
Any help is greatly appreciated.
Thanks in advance
My SQL Command is as follows:
<
with MAXNEWSTAT as
(select
/--Added by HAN--/
HRHISTORY.COMPANY,
HRHISTORY.EMPLOYEE,
MAX(HRHISTORY.ACT_OBJ_ID) ACT_OBJ_ID
FROM
LAWSON.HRHISTORY
WHERE
HRHISTORY.FLD_NBR=20
and TO_DATE(HRHISTORY.DATE_STAMP)
>= TO_DATE((TO_CHAR((ADD_MONTHS(SYSDATE,-1)),'YYYY/MM')||'/01'),'YYYY/MM/DD')
AND TO_DATE(HRHISTORY.DATE_STAMP) <= (TO_DATE((TO_CHAR((ADD_MONTHS(SYSDATE,0)),'YYYY/MM')||'/01'),'YYYY/MM/DD'))-1
/--Added by HAN--/
GROUP BY COMPANY,
EMPLOYEE),
NEWSTAT AS
(SELECT
/--Added by HAN--/
HRHISTORY.COMPANY,
HRHISTORY.EMPLOYEE,
HRHISTORY.A_VALUE,
HRHISTORY.DATE_STAMP,
HRHISTORY.BEG_DATE,
HRHISTORY.ACT_OBJ_ID NS_OBJ_ID,
HRHISTORY.SEQ_NBR
FROM
LAWSON.HRHISTORY
INNER JOIN LAWSON.MAXNEWSTAT
ON
/--Added by HAN--/
HRHISTORY.COMPANY = MAXNEWSTAT.COMPANY
/--Added by KAM--/
AND HRHISTORY.EMPLOYEE = MAXNEWSTAT.EMPLOYEE
AND HRHISTORY.ACT_OBJ_ID = MAXNEWSTAT.ACT_OBJ_ID
WHERE
HRHISTORY.FLD_NBR=20
and TO_DATE(HRHISTORY.DATE_STAMP)
>= TO_DATE((TO_CHAR((ADD_MONTHS(SYSDATE,-1)),'YYYY/MM')||'/01'),'YYYY/MM/DD')
AND TO_DATE(HRHISTORY.DATE_STAMP) <= (TO_DATE((TO_CHAR((ADD_MONTHS(SYSDATE,0)),'YYYY/MM')||'/01'),'YYYY/MM/DD'))-1
PREVSTATID AS
(SELECT
/--Added by HAN--/
HRHISTORY.COMPANY,
HRHISTORY.EMPLOYEE,
MAX(HRHISTORY.ACT_OBJ_ID)OBJ_ID
FROM
LAWSON.HRHISTORY
INNER JOIN LAWSON.NEWSTAT
/--Added by HAN--/
ON HRHISTORY.COMPANY = NEWSTAT.COMPANY
AND HRHISTORY.EMPLOYEE = NEWSTAT.EMPLOYEE
WHERE
HRHISTORY.FLD_NBR=20
AND TO_DATE(HRHISTORY.BEG_DATE)
< to_date(NEWSTAT.BEG_DATE)
GROUP BY
/--Added by HAN--/
HRHISTORY.COMPANY,
HRHISTORY.EMPLOYEE
PREVSTAT AS
(SELECT
/--Added by HAN--/
HRHISTORY.COMPANY,
HRHISTORY.EMPLOYEE,
HRHISTORY.A_VALUE A_VALUE,
HRHISTORY.DATE_STAMP DATE_STAMP,
HRHISTORY.BEG_DATE BEG_DATE,
HRHISTORY.ACT_OBJ_ID OBJ_ID,
HRHISTORY.SEQ_NBR SEQ_NBR
FROM
LAWSON.HRHISTORY
INNER JOIN LAWSON.PREVSTATID
/--Added by HAN--/
ON HRHISTORY.COMPANY = PREVSTATID.COMPANY
AND HRHISTORY.EMPLOYEE = PREVSTATID.EMPLOYEE
WHERE
HRHISTORY.FLD_NBR=20 AND
HRHISTORY.ACT_OBJ_ID = PREVSTATID.OBJ_ID
MAXPERSACTHST AS
(SELECT
PERSACTHST.EMPLOYEE,
/--Added by KAM--/
PERSACTHST.COMPANY,
MAX(PERSACTHST.DATE_STAMP)DATE_STAMP
FROM
LAWSON.PERSACTHST
WHERE
(PERSACTHST.ACTION_CODE='LOASTATUS' OR PERSACTHST.ACTION_CODE='STATUS')
AND TO_DATE(PERSACTHST.DATE_STAMP)
>= TO_DATE((TO_CHAR((ADD_MONTHS(SYSDATE,-1)),'YYYY/MM')||'/01'),'YYYY/MM/DD')
AND TO_DATE(PERSACTHST.DATE_STAMP) <= (TO_DATE((TO_CHAR((ADD_MONTHS(SYSDATE,0)),'YYYY/MM')||'/01'),'YYYY/MM/DD'))-1
GROUP BY PERSACTHST.EMPLOYEE,
/--Added by KAM--/
PERSACTHST.COMPANY
CHANGELIST AS
(SELECT
PERSACTHST.EMPLOYEE,
/--Added by KAM--/
PERSACTHST.COMPANY,
PERSACTHST.ACTION_CODE,
PERSACTHST.REASON_01,
PERSACTHST.DATE_STAMP,
PERSACTHST.EFFECT_DATE,
PERSACTHST.REASON_02,
PREVSTAT.A_VALUE PS_A_VALUE,
PREVSTAT.DATE_STAMP PS_HR_DATE_STAMP,
PREVSTAT.BEG_DATE PS_HR_BEG_DATE,
PREVSTAT.OBJ_ID PS_HR_OBJ_ID,
PREVSTAT.SEQ_NBR PS_HR_SEQ_ID,
NEWSTAT.A_VALUE NS_A_VALUE,
NEWSTAT.DATE_STAMP NS_DATE_STAMP,
NEWSTAT.BEG_DATE NS_BEG_DATE,
NEWSTAT.NS_OBJ_ID,
NEWSTAT.SEQ_NBR NS_SEQ_NBR
FROM
LAWSON.PERSACTHST PERSACTHST
INNER JOIN LAWSON.PREVSTAT
ON PERSACTHST.EMPLOYEE=PREVSTAT.EMPLOYEE
/--Added by KAM--/
AND PERSACTHST.COMPANY = PREVSTAT.COMPANY
INNER JOIN LAWSON.NEWSTAT
ON PERSACTHST.EMPLOYEE = NEWSTAT.EMPLOYEE
/--Added by KAM--/
AND PERSACTHST.COMPANY = NEWSTAT.COMPANY
INNER JOIN LAWSON.MAXPERSACTHST
ON PERSACTHST.EMPLOYEE = MAXPERSACTHST.EMPLOYEE
/--Added by KAM--/
AND PERSACTHST.COMPANY = MAXPERSACTHST.COMPANY
WHERE
(PERSACTHST.ACTION_CODE='LOASTATUS' OR PERSACTHST.ACTION_CODE='STATUS')
AND NEWSTAT.A_VALUE <> PREVSTAT.A_VALUE
AND MAXPERSACTHST.DATE_STAMP = PERSACTHST.DATE_STAMP
PAEMPPOSENDDATE AS
(SELECT
PAEMPPOS.EMPLOYEE,
PAEMPPOS.COMPANY,
CASE
WHEN PAEMPPOS.END_DATE = TO_DATE('1700,01,01','YYYY,MM,DD')
THEN to_date(SYSDATE + 1,'YYYY,MM,DD')
ELSE PAEMPPOS.END_DATE
END END_DATE,
PAEMPPOS.EFFECT_DATE
FROM LAWSON.PAEMPPOS),
CURRFTE AS
(SELECT
PAEMPPOS.EMPLOYEE,
/--Added by KAM--/
PAEMPPOS.COMPANY,
PAEMPPOS.FTE CURR_FTE,
PAEMPPOS.EFFECT_DATE,
PAEMPPOSENDDATE.END_DATE
FROM
LAWSON.PAEMPPOS
INNER JOIN LAWSON.NEWSTAT
ON (PAEMPPOS.EMPLOYEE = NEWSTAT.EMPLOYEE)
/--Added by KAM--/
AND (PAEMPPOS.COMPANY = NEWSTAT.COMPANY)
INNER JOIN LAWSON.PAEMPPOSENDDATE
ON PAEMPPOS.EMPLOYEE = PAEMPPOSENDDATE.EMPLOYEE
/--Added by KAM--/
AND PAEMPPOS.COMPANY = PAEMPPOSENDDATE.COMPANY
AND PAEMPPOS.EFFECT_DATE=PAEMPPOSENDDATE.EFFECT_DATE
WHERE
(PAEMPPOSENDDATE.EFFECT_DATE <= NEWSTAT.BEG_DATE AND PAEMPPOSENDDATE.END_DATE >= NEWSTAT.BEG_DATE)
PREVFTE AS
(SELECT
PAEMPPOS.EMPLOYEE,
/--Added by KAM--/
PAEMPPOS.COMPANY,
PAEMPPOS.FTE PREV_FTE,
PAEMPPOSENDDATE.END_DATE
FROM
LAWSON.PAEMPPOS
INNER JOIN LAWSON.NEWSTAT
ON (PAEMPPOS.EMPLOYEE = NEWSTAT.EMPLOYEE)
/--Added by KAM--/
AND (PAEMPPOS.COMPANY = NEWSTAT.EMPLOYEE)
INNER JOIN LAWSON.PAEMPPOSENDDATE
ON (PAEMPPOS.EMPLOYEE = PAEMPPOSENDDATE.EMPLOYEE)
/--Added by KAM--/
AND (PAEMPPOS.COMPANY = PAEMPPOSENDDATE.COMPANY)
AND (PAEMPPOS.EFFECT_DATE = PAEMPPOSENDDATE.EFFECT_DATE)
WHERE
PAEMPPOS.EFFECT_DATE <= (NEWSTAT.BEG_DATE-1)AND PAEMPPOSENDDATE.END_DATE >= (NEWSTAT.BEG_DATE -1)
SELECT DISTINCT
EMPLOYEE.EMPLOYEE,
EMPLOYEE.DEPARTMENT,
EMPLOYEE.PROCESS_LEVEL,
EMPLOYEE.EMP_STATUS,
EMPLOYEE.FIRST_NAME,
EMPLOYEE.LAST_NAME,
EMPLOYEE.MIDDLE_INIT,
EMPLOYEE.POSITION,
PAPOSITION.DESCRIPTION,
CHANGELIST.PS_A_VALUE,
/--Added by KAM--/
CHANGELIST.COMPANY,
CHANGELIST.PS_HR_DATE_STAMP,
CHANGELIST.PS_HR_BEG_DATE,
CHANGELIST.PS_HR_OBJ_ID,
CHANGELIST.NS_A_VALUE,
CHANGELIST.NS_DATE_STAMP,
CHANGELIST.NS_OBJ_ID,
CHANGELIST.ACTION_CODE,
CHANGELIST.REASON_01,
CHANGELIST.REASON_02,
CHANGELIST.DATE_STAMP PERSACTSDATESTAMP,
CHANGELIST.EFFECT_DATE PERSACTEFFDATE,
DEPTCODE.R_NAME DEPTNAME,
PRSYSTEM.R_NAME PLNAME,
PREVFTE.PREV_FTE,
CURRFTE.CURR_FTE,
CHANGELIST.NS_BEG_DATE,
PGSELECT.GROUP_NAME,
PAEMPLOYEE.SENIOR_DATE
FROM
LAWSON.CHANGELIST
INNER JOIN LAWSON.EMPLOYEE
ON (EMPLOYEE.EMPLOYEE = CHANGELIST.EMPLOYEE)
/--Added by KAM--/
AND (EMPLOYEE.COMPANY = CHANGELIST.COMPANY)
INNER JOIN LAWSON.DEPTCODE
ON ((EMPLOYEE.COMPANY=DEPTCODE.COMPANY)
AND (EMPLOYEE.PROCESS_LEVEL=DEPTCODE.PROCESS_LEVEL)
AND (EMPLOYEE.DEPARTMENT=DEPTCODE.DEPARTMENT))
INNER JOIN LAWSON.PRSYSTEM
ON ((EMPLOYEE.COMPANY=PRSYSTEM.COMPANY)
AND(EMPLOYEE.PROCESS_LEVEL=PRSYSTEM.PROCESS_LEVEL))
LEFT OUTER JOIN LAWSON.PREVFTE
ON (CHANGELIST.EMPLOYEE=PREVFTE.EMPLOYEE)
/--Added by KAM--/
AND (CHANGELIST.COMPANY=PREVFTE.COMPANY)
LEFT OUTER JOIN LAWSON.CURRFTE
ON (CHANGELIST.EMPLOYEE=CURRFTE.EMPLOYEE)
/--Added by KAM--/
AND (CHANGELIST.COMPANY=CURRFTE.COMPANY)
INNER JOIN LAWSON.PGSELECT PGSELECT
ON ((EMPLOYEE.COMPANY=PGSELECT.COMPANY)
AND (EMPLOYEE.EMP_STATUS=PGSELECT.BEGIN_VALUE))
LEFT OUTER JOIN LAWSON.PAPOSITION
ON (EMPLOYEE.POSITION=PAPOSITION.POSITION)
AND (EMPLOYEE.COMPANY=PAPOSITION.COMPANY)
INNER JOIN LAWSON.PAEMPLOYEE
ON (CHANGELIST.EMPLOYEE=PAEMPLOYEE.EMPLOYEE)
/--Added by KAM--/
AND (CHANGELIST.COMPANY=PAEMPLOYEE.COMPANY)
WHERE
(PGSELECT.GROUP_NAME='G:ACTIVE' OR PGSELECT.GROUP_NAME='G:INACTIVE')
>Hi Arsh,
The error message you receive i.e.
ORA-01830: date format picture ends before converting entire input string
is an Oracle error.
The following document would be helpful:
ORA-01830: date format picture ends before converting entire input string
Cause: A valid date format picture included extra data. The first part of the format picture was converted into a valid date, but the remaining data was not required.
Action: Check the specifications for date format pictures and correct the statement.
Regards,
Alpana -
Need help with date format mask
Hi there, right now I'm trying to set a default date format mask constraint for one of the attributes for my table. I want to set the default mask constraint as MM/DD/YY but I don't know how to. it should be something like:
CREATE TABLE work (WorkDate DATE CHECK (WorkDate = 'MM/DD/YY'))
or something like that, but I don't think that's correct. Can anyone help me? Thanks in advance.What you want (and should have done) is to read the documentation, starting with the concepts:
http://download.oracle.com/docs/cd/B19306_01/server.102/b14220/datatype.htm#CNCPT413
http://www.oracle.com/pls/db102/search?remark=quick_search&word=date&tab_id=&format=ranked
A date is stored as, well, a date, format masks only come into play when you're selecting/retrieving a date or when you want to store a string as a date. Default date formats can be set through NLS_DATE_FORMAT at session and database level.
http://download.oracle.com/docs/cd/B19306_01/server.102/b14237/initparams122.htm#REFRN10119
Documentation homes (from which you can do a simple quick search):
http://www.oracle.com/pls/db102/homepage
http://www.oracle.com/pls/db112/homepage
Bottom line:
Trying to set a default date format mask on a date datatype column makes no sense... -
Hi
I am a complete oracle idiot.
I have created a table with 2 columns po_id,po_date. Yhe id data type is number,date type is date. To add values to the table i enter something like
"insert into purchase_orders(po_id,po_date) values(1,01/01/2004)"
It does not accept the date and will not add the record, i have also tried the date format 01-Jan-2004.
What is the proper way to add the date.
Thanks
GarryYou probably want to use an explicit to_date cast. That lets you specify the format of the date string, i.e.
INSERT INTO purchase_orders( po_id, po_date )
VALUES( 1, to_date( '01/01/2004', 'DD/MM/YYYY' );Justin
Distributed Database Consulting, Inc.
http://www.ddbcinc.com/askDDBC -
Hi, I have a record update form that shows Start date and End date in 2 separate fields like dd/mm/yyyy. When I edit the dates they do not get to the database correctly, all I get is 0000/00/00. I guess this is because the date format accepted by MySQL is yyyy/mm/dd.
I'm stuck because I don't know how to convert the dates back to MySQL format for updating.
This is the code that displays the start date:
//<input name="AG_fechai" type="text" class="CP_loginFormFields" value="<?php echo date('d/m/Y',strtotime($row_eventosUpdate_RS['AG_fechai'])); ?>" size="32" />
This is the code that displays the end date:
//<input name="AG_fechaf" type="text" class="CP_loginFormFields" value="<?php echo date('d/m/Y',strtotime($row_eventosUpdate_RS['AG_fechaf'])); ?>" size="32" />
This is my update query.(AG_fechai and AG_fechaf are the start and end date fields) which are not been updated. I appreciate your help. Thanks.
// $updateSQL = sprintf("UPDATE t_agenda SET AG_fechai=%s, AG_fechaf=%s, AG_precio=%s, AG_horario=%s, AG_titulo_esp=%s, AG_titulo_eng=%s, AG_titulo_ger=%s, AG_titulo_fra=%s WHERE id_AG=%s",
GetSQLValueString($_POST['AG_fechai'], "date",
GetSQLValueString($_POST['AG_fechaf'], "date",
GetSQLValueString($_POST['AG_precio'], "text",
GetSQLValueString($_POST['AG_horario'], "text",
GetSQLValueString($_POST['AG_titulo_esp'], "text",
GetSQLValueString($_POST['AG_titulo_eng'], "text",
GetSQLValueString($_POST['AG_titulo_ger'], "text",
GetSQLValueString($_POST['AG_titulo_fra'], "text",
GetSQLValueString($_POST['id_AG'], "int");
mysql_select_db($database_amat_connect, $amat_connect);
$Result1 = mysql_query($updateSQL, $amat_connect) or die(mysql_error());MySQL stores dates in one format only: the ISO recommended YYYY-MM-DD. You need to reorder the date parts to store the date correctly.
If your input date is in the following format: dd/mm/yyyy, you can convert it by creating a custom function like this:
function convertDate($val) {
$parts = explode('/', $val);
return "$parts[2]-$parts[1]-$parts[0]";
Pass both dates to this function:
GetSQLValueString(convertDate($_POST['AG_fechai']), "date",
GetSQLValueString(convertDate($_POST['AG_fechaf']), "date", -
Required help with date format
Hi All,
I am calling a webservice from plsql, for this I am using UTL_DBWS package. I want to insert the format of date as 'YYYY-MM-DD' only. I used to_char(sysdate, 'YYYY-MM-DD') , but it is throwing error. Please suggest any solution.
Thanks and Regards,
Mahesh
The error details are as follows
ORA-29532: Java call terminated by uncaught Java exception: javax.xml.rpc.soap.SOAPFaultException
Caught exception while handling request: invalid date: 25-NOV-08
ORA-06512: at "SYS.UTL_DBWS", line 403
ORA-06512: at "SYS.UTL_DBWS", line 400user6391695 wrote:
Hi All,
I am calling a webservice from plsql, for this I am using UTL_DBWS package. I want to insert the format of date as 'YYYY-MM-DD' only. I used to_char(sysdate, 'YYYY-MM-DD') , but it is throwing error. Please suggest any solution.What happens is...
You convert sysdate into a string of the format YYYY-MM-DD and then you are passing that to a parameter that is a DATE datatype. When you do this oracle has to implicitly conver the string to the DATE datatype. It does this based on the NLS settings of the session which, I would guess, are not of the format YYYY-MM-DD, so it can't understand the string you have passed and fails to convert it to a date.
Date formats are not something that is stored on the database (assuming you are correctly storing dates as DATE datatype). The format of dates is a display issue and something that should be handled by the user interface. The database stores data, just that, no display formats. ;) -
HELLO EVERYBODY
What is wrong with this sentence :
FECHA1 := TO_DATE(:P111_FECHA,'DD/MM/YYYY HH24:MI');
I want load into FECHA1 (DATE VAR) THE CONTENT OF :P111_FECHA (VARCHAR2 VAR)
THE CONTENT OF :P111_FECHA = '15/11/2006 15:23'
Thanks in advanced.
Regards everybodyNothing is obviously wrong. Are you getting an error? Are you absolutely certain that your bind variable is in the right format?
Justin -
Need help with data formating.
The following statment places extra spaces to the right of the month. I only want one space to the right of the month.
How do I do that
select to_char(to_date('08/07/2007','MM/DD/YYYY'),'MONTH DD, YYYY') || ' THRU ' || to_char(to_date('08/20/2007','MM/DD/YYYY'),'MONTH DD, YYYY') from
dual
What I get: AUGUST 07, 2007 THRU AUGUST 20, 2007
What I want: AUGUST 07, 2007 THRU AUGUST 20, 2007
HowardSQL> select
2 to_char(to_date('08/07/2007','MM/DD/YYYY'),'MONTH DD, YYYY') ||
3 ' THRU ' ||
4 to_char(to_date('08/20/2007','MM/DD/YYYY'),'MONTH DD, YYYY') dt
5 from dual
6 union all
7 select
8 to_char(to_date('08/07/2007','MM/DD/YYYY'),'fmMONTH DD, YYYY') ||
9 ' THRU ' ||
10 to_char(to_date('08/20/2007','MM/DD/YYYY'),'fmMONTH DD, YYYY') dt
11 from dual
12 /
DT
AUGUST 07, 2007 THRU AUGUST 20, 2007
AUGUST 7, 2007 THRU AUGUST 20, 2007Best regards
Maxim -
Hello,
i need some help with date formats. I am using JDeveloper 11g and am trying to write some SQL commands.
When i enter the following, everything is working correctly.
ResultSet query = st.executeQuery("select * from DB.TABLE where DATE > '01-01-2000'");
I need to make it work so that date can be used from a jtextarea.
String inputData =jTextArea1.getText();
ResultSet query = st.executeQuery("select * from DB.TABLE where DATE > " +inputData);
Query does not return anything.
Do i need to convert the value of inputData? What other problems could there be?
TY
Edited by: user10956166 on Apr 1, 2009 4:08 AMCorrect. Oracle will implicitly convert the date as shown below (see Predicate Information)
SQL > explain plan for select * from test where modified_date > '01/01/2008 12:00:00';
Explained.
SQL > select * from table(dbms_xplan.display);
PLAN_TABLE_OUTPUT
Plan hash value: 3461732445
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
| 0 | SELECT STATEMENT | | 677 | 105K| 6 (0)| 00:00:01 |
|* 1 | TABLE ACCESS FULL| TEST | 677 | 105K| 6 (0)| 00:00:01 |
Predicate Information (identified by operation id):
1 - filter("MODIFIED_DATE">TO_DATE(' 2008-01-01 12:00:00',
'syyyy-mm-dd hh24:mi:ss'))Don't forget to use parameterized queries (a.k.a. bind variables)!
HTH! -
Got one more problem Merilyn and Radhakrishnan...
Regarding the soln y provided me earler with the thread "Problem with date format"...
What is happening is....I am able to change the 2400 to 0000 but when it is changed from 2400 on jan 1st to 0000 the hour is changing but not the date....the date still remains as jan 1st instead of jan 2nd....
Eg: Jan 1st 2400 -- changed to -- jan1st 0000
instead of jan 2nd 0000
Could you please help me in this issue...
Thanks,
GKGK, try this...
decode(instr(packagename.functionname(param1 ,param2),'2400'), 0, to_date(to_char(to_date(rtrim(packagename.functionname(param1 ,param2),'(PT)'), 'Month dd, yyyy "at" hh24mi'),'mm/dd/yyyy hh24mi'),'mm/dd/yyyy hh24mi'),
to_date(to_char(to_date(rtrim(packagename.functionname(param1 ,param2),'(PT)'), 'Month dd, yyyy "at" "2400"')+1,'mm/dd/yyyy "0000"'),'mm/dd/yyyy "0000"'))-Marilyn -
Problem with date format dd/mm/yyyy. But I need to convert yyyy-mm-dd.
Dear friends,
I have the problem with date format. I receiving the date with the format dd/mm/yyyy. But I can upload to MySQL only in the format of yyyy-mm-dd.
how should I handle this situation, for this I've created these code lines.But I have some problem with these line. please help me to solve this problem.
String pattern = "yyyy-mm-dd";
SimpleDateFormat format = new SimpleDateFormat(pattern);
try {
Date date = format.parse("2006-02-12");
System.out.println(date);
} catch (ParseException e) {
e.printStackTrace();
System.out.println(format.format(new Date()));
this out put gives me Tue Apr 03 00:00:00 IST 2007
But I need the date format in yyyy-mm-dd.
regards,
maza
thanks in advance.Thanks Dear BalusC,
I tried with this,
rs.getString("DATA_SCAD1")// where the source from .xls files
String pattern = "yyyy-MM-dd";
SimpleDateFormat format = new SimpleDateFormat(pattern);
try {
Date date = format.parse("DATA_SCAD1");
System.out.println(date);
} catch (ParseException e) {
e.printStackTrace();
System.out.println(format.format(new Date()));
this out put gives me Tue Apr 03 00:00:00 IST 2007
But I want to display the date format in yyyy-mm-dd.
regards,
maza -
Hi All,
I m facing an issue with Date format in the prompt. I have used date presentation variables in my column formula as shown below:
FILTER("SKU Order Details"."Fulfilled Quantity" USING Time."Calendar Date" <= DATE '@{todate}{2900-01-01}')
The report returns data when I don't select any date range for start & end date prompts on the page. But when I select the start & end date values in the prompt, I m getting the following error:
Error Codes: OPR4ONWY:U9IM8TAC:OI2DL65P:OI2DL65P
State: HY000. Code: 10058. [NQODBC] [SQL_STATE: HY000] [nQSError: 10058] A general error has occurred. [nQSError: 46047] Datetime value 10/22/2009 12:00:00 AM from 10/22/2009 12:00:00 AM does not match the specified format. (HY000)
I included the following formulas for start & end date prompts:
Start Date prompt: case when 1=2 then License."Ips Creation Date" else cast ('1.1.1900' as date) end
End Date prompt: case when 1=2 then License."Ips Creation Date" else cast ('1.1.2900' as date) end
Can you please help me resolve the issue.
Thanks,
KartikHi Nico,
I tried putting the format that you mentioned, I m getting an error message.
My prompts have the following formula :
Start: case when 1=2 then License."Creation Date" else cast('1.1.1900' as DATE) end
End: case when 1=2 then Time."Calendar Date" else cast('1.1.2900' as DATE) end
My column formula has the following syntax:
FILTER("SKU Order Details"."Fulfilled Quantity" USING Time."Calendar Date" between DATE '@{start}{1900-01-01}' AND DATE '@{end}{2999-01-01}')
Error Message:
Error Codes: OPR4ONWY:U9IM8TAC:OI2DL65P:OI2DL65P
State: HY000. Code: 10058. [NQODBC] [SQL_STATE: HY000] [nQSError: 10058] A general error has occurred. [nQSError: 46047] Datetime value 11/17/2009 from 11/17/2009 does not match the specified format. (HY000)
Can you please let me know if something needs to be changed.
Thanks,
Kartik -
SQL Loader with date formatting
Hi,
I'm trying to get sql loader to insert a date into a column. After much browsing, reading trial and error I still get an array of errors.
I'm using oracle XE
my control file looks like this
LOAD DATA
INFILE 'posmeters/meters.csv'
INTO TABLE position_meters
FIELDS terminated by ","
ID CONSTANT '0',
POSITION_ID,
DATETIME DATE "DD/MM/YYYY HH24:MI:SS",
CASH_IN,
CASH_OUT,
NOTES_IN,
CHANGE_OUT,
WINNINGS,
VTP,
REFILL,
TOKEN_IN,
TOKEN_OUT,
ELEC_PAY,
ELEC_CREDIT,
REMOTE_PAY,
REMOTE_CREDIT,
INSERT_TS EXPRESSION "TO_CHAR(SYSDATE, 'DD/MM/YYYY HH24:MI:SS')",
FIFTY_PND,
TWENTY_PND,
TEN_PND,
FIVE_PND,
TWO_PND,
ONE_PND,
FIFTY_P,
TWENTY_P,
TEN_P,
FIVE_P
It is the DATETIME field which gives me grief. I have a test data file that looks like this
0,1010,29/09/2011 10:23:24,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24
and my table is defined as follows
ID NUMBER NOT NULL,
POSITION_ID NUMBER,
DATETIME TIMESTAMP(6) DEFAULT localTIMESTAMP NOT NULL,
CASH_IN NUMBER,
CASH_OUT NUMBER,
NOTES_IN NUMBER,
CHANGE_OUT NUMBER,
WINNINGS NUMBER,
VTP NUMBER,
REFILL NUMBER,
TOKEN_IN NUMBER DEFAULT (0) NOT NULL,
TOKEN_OUT NUMBER DEFAULT (0) NOT NULL,
ELEC_PAY NUMBER DEFAULT (0) NOT NULL,
ELEC_CREDIT NUMBER DEFAULT (0) NOT NULL,
REMOTE_PAY NUMBER DEFAULT (0) NOT NULL,
REMOTE_CREDIT NUMBER DEFAULT (0) NOT NULL,
INSERT_TS TIMESTAMP(6) DEFAULT (localtimestamp) NOT NULL,
FIFTY_PND NUMBER DEFAULT 0,
TWENTY_PND NUMBER DEFAULT 0,
TEN_PND NUMBER DEFAULT 0,
FIVE_PND NUMBER DEFAULT 0,
TWO_PND NUMBER DEFAULT 0,
ONE_PND NUMBER DEFAULT 0,
FIFTY_P NUMBER DEFAULT 0,
TWENTY_P NUMBER DEFAULT 0,
TEN_P NUMBER DEFAULT 0,
FIVE_P NUMBER DEFAULT 0
I have tried defining the control file with
DATETIME DATE "DD/MM/YYYY HH24:MI:SS",
DATETIME EXPRESSION "TO_DATE(:DATETIME, 'DD/MM/YYYY HH24:MI:SS')",
DATETIME EXPRESSION "TO_TIMESTAMP(:DATETIME, 'DD/MM/YYYY HH24:MI:SS')",
I get errors such as
Record 1: Rejected - Error on table "SITE_MAIN"."POSITION_METERS", column DATETIME.
ORA-01861: literal does not match format string
SQL*Loader-291: Invalid bind variable DATETIME in SQL string for column DATETIME.
any help would greatfully appreciated.It seems that the problem was caused by the constant at the beginning of the record and had nothing to do with date formats.
My control file now looks like this
LOAD DATA
INFILE 'posmeters/meters.csv'
APPEND INTO TABLE position_meters
FIELDS terminated by ","
POSITION_ID ,
DATETIME date "DD/MM/YYYY HH24:MI:SS",
CASH_IN ,
CASH_OUT ,
NOTES_IN ,
CHANGE_OUT ,
WINNINGS ,
VTP ,
REFILL ,
TOKEN_IN ,
TOKEN_OUT ,
ELEC_PAY ,
ELEC_CREDIT ,
REMOTE_PAY ,
REMOTE_CREDIT ,
INSERT_TS "TO_TIMESTAMP(SYSDATE, 'DD/MM/YYYY HH24:MI:SS')",
FIFTY_PND ,
TWENTY_PND ,
TEN_PND ,
FIVE_PND ,
TWO_PND ,
ONE_PND ,
FIFTY_P ,
TWENTY_P ,
TEN_P ,
FIVE_P
all is good :o) -
I am printing a calendar and certain events will be helds on certain dates.
One can edit the event if it has not passed the date. Events in the past can be viewed but not edited.
When I query the database the date must be formatted dd-MMM-yy
I am able to get today's date by doing this:
java.util.Date today = new java.util.Date();
String formatString = "dd-MMM-yy";
SimpleDateFormat sdf = new SimpleDateFormat(formatString);
String today_str = sdf.format(today);
My code for printing the calendar: I left out some of the table formatting in the JSP page.
GregorianCalendar d = new GregorianCalendar();
int today = d.get(Calendar.DAY_OF_MONTH);
int month = d.get(Calendar.MONTH);
d.set(Calendar.DAY_OF_MONTH,1);
int weekday = d.get(Calendar.DAY_OF_WEEK);
for(int i = Calendar.SUNDAY; i < weekday; i++)
out.print("<td> </td>");
do {
int day = d.get(Calendar.DAY_OF_MONTH);
out.print("<td>" + day + "</td>");
String formatString = "dd-MMM-yy";
SimpleDateFormat sdf = new SimpleDateFormat(formatString);
//if(event exists on this day
// Get results
// print link for viewing
// if (after today) print link for edit
if(weekday == Calendar.SATURDAY)
out.println("</tr><tr valign=top>");
d.add(Calendar.DAY_OF_MONTH,1);
weekday = d.get(Calendar.DAY_OF_WEEK);
} while(d.get(Calendar.MONTH) == month);
if(weekday != Calendar.SUNDAY)
System.out.println();
The part I need help on is this:
//if(event exists on this day
// Get results
// print link for viewing
// if (after today) print link for edit
I'm looping through each day of the month to print the days. I have the month, day, year as integers. How can I create a date object out of that and compare it to today's date to test if it's before or after today???
All the function in the Date class that I think would do this have been deprecated.Need Help with Dates
Here is some information about dates:
There are many edible palm fruits, and one of the most widespread and favored of these is the data (Phoenix dactylifera). Dates were cultivated in ancient land from Mesopotamia to prehistoric Egypt, possibly as early as 6000 B.C. Then--as now--dates were a staple for the natives of those dry regions. Much later, Arabs spread dates around northern Africa, and dates were introduced into California by the Spaniards in 1765, around Mission San Ignacio.
The date prefers dry, hot climates, because date fruits are injured at temperatures of 20 degrees F, and the damp climate of the California coast was not favorable for fruit production. In the mid-1800s, the date industry developed in California's hot interior valleys and in Arizona. Now the date industry in the United States is localized mostly in the Coachella Valley, where the sandy soils permit the plants to be deeply irrigated. Today the new varieties, mostly introduced in this century, produce about 40 million pounds of dates per annum, or over 60% of the dates consumed in this country. The rest are imported mainly from Persia. According to one survey, about one million people are engaged entirely in date palm cultivation worldwide.
Hope that helps.
Maybe you are looking for
-
I need to create a link on a page, while hiding it from the options
I am making a website for my work, which is a glass company. The options at the top to click on will be home, commercial, residential, and contact us. When you click on residential i would like to have links for windows, shower doors, ect. I want to
-
Genre options - any way to change?
Does anyone know if it is possible (if it isn't, I think this is a BIG flaw, if it is is, I've completely missed it) to change the options on an Ipod or in Itunes so that when I click on Genres (on my Ipod) and then on Soundtracks (hey, some people l
-
N80 - Rename gallery folder in menu, help please :...
Hello, by mistake i've changed the name of the gallery folder on the menu, and now when i try to change the name back to gallery, the option for changing the name isn't there!!!! I really don't understand what have happened... Can you help me? Thanks
-
Hi All, I am getting the below two errors, while ordering a Po assigned with WBS element in extended classic scenario. Profit Center DUMMY and Company Code xxxx must be consistent Profit on item 000 is missing or not allowed We used to get the first
-
How to install OEM 10g using an existing database on another host
Hi, I've created a 10g database (on host solaris_x86) which I like to use for the OEM 10G GC (on host linux_x86). If I install OEM using existing DB, then the installer expect the database is running locally. If I install OEM using new DB, then the i