SQL & PL/SQL :: Date Datatype Being Stored As DD:MM:YY HH:MI:SS?
Feb 21, 2012I have a table in my database with a column called theme_night_date that i want to store just a date and no time.
View 2 RepliesI have a table in my database with a column called theme_night_date that i want to store just a date and no time.
View 2 Repliesi am having one column name pdate with date datatype
i am updating here value like this
update table1 set pdate='15-10-2012' where id=1;
but showing error: not a valid month.
how to update this.
may I use ??
trunc(sysdate,'DD')
As it is not quite clear what it is about, I "created" a dummy title (which might be modified once we find out what the problem is).
I have a field " Tran_date " with datatype Date . It contains date as well as time . How can I get the time . I tried with it as below :
SELECT TO_CHAR(TRAN_DATE,'DD-MON-YYYY HH24:MI:SS') FROM ABC
WHERE COMP=1 AND
BRANCH=1 AND
LOC_CODE='12' AND
TRAN_DATE='12-JAN-2012' ;
VALUE IS COMING LIKE THIS :
12-JAN-2012 00:00:00
ALTHOUGH THERE IS TIME . Its not zero .
I have a table
CREATE TABLE TEST
(
X NUMBER(8),
SNUM NUMBER
)
SET DEFINE OFF;
Insert into TEST (X, SNUM) Values (20100409, 1);
Insert into TEST (X, SNUM) Values (20100317, 1);
[Code]...
For some reason, column x is a number data type, but the data is actually date.
My aim:
1. select the maximum of the dates stored in column x (in numeric data)..for a given snum.
2. check if it is within 3 days range and return 1 or 0
My program
CREATE OR REPLACE FUNCTION f_chk (in_num number)
RETURN NUMBER
IS
v_chk NUMBER;
v_max_dat number;
BEGIN
SELECT COUNT (*) INTO v_chk
[Code]....
I have following assumptions, correct me if I am wrong:
SELECT max(x) INTO v_max_dat FROM test WHERE snum = in_num;
1. The above will actually give me the maximum date for a given snum (correct result), since the data is stored in yyyymmdd format, it does actually picks up the maximum date (stored in number format) for a given snum ... or should i use to_date to convert it to date and declare v_max_dat as date ?
I have a date column, where the date values are not stored in a specific pattern. following are the sample value from the column.
8/10/10 12:00 AM
9/22/2010 1:00AM
01/01/2001
9/1/10 6:00 PM
9/22/2009 1:00AM
i want to convert this to a standard format, 'dd/mm'yyyy'.
I have need to know the best (least expensive) way to create a stored procedure that creates a new records in a table using a sequence and return the primary key (sequence value) for this inserted record:
CREATE TABLE TEST_A (SERIAL NUMBER PRIMARY KEY, NAME VARCHAR2(20));
CREATE SEQUENCE SEQ_TESTA_PK START WITH 1
NOCACHE
NOCYCLE;
CREATE OR REPLACE TRIGGER TRG_TESTA_PK
BEFORE INSERT ON TEST_A
[code]....
oracle stored procedure which sorts date, meaning the recent records needs to be shown first.
View 6 Replies View RelatedI would need to convert the column datatype from BLOB to CLOB. currently in the table, the BLOB column has the data. the requirement is to convert this column from BLOB to CLOB datatype.
How to convert from BLOB datatype to CLOB datatype ?
I have created a stored procedure that checks if a file exists and gets a date from the file if it exists. The date is then used as a paramter. See below:
CODEcreate or replace
PROCEDURE "P_Load_Stamp" AS
v_exists BOOLEAN;
v_length NUMBER;
v_blocksize NUMBER;
[code]...
The above codes works perfectly and I scheduled it using SQLPLUS as follows:
CODEvariable jobno number;
variable instno number;
begin
select instance_number into :instno from v$instance;
[code]...
My problem is that I need to pass the date from the above procedure as a parameter to another stored procedure. So I modified my code as follows (the parts in red):
CODEcreate or replace
PROCEDURE "P_Load_Stamp" (vCTIDATE OUT varchar2) AS
v_exists BOOLEAN;
v_length NUMBER;
[code]...
Now it doesn't strike me as a rights issue since I created it in the schem schema. What could I be doing wrong here?
Is there a seeded function by which I can check all the rows which stored dates in varchar column.
I have a table say test (test_data varchar2(100));
Now I will insert all types of records into the table varchar,number dates and then i will write q query to etch all those records only which has dates only
INSERT INTO test(1);
INSERT INTO test('ABC');
INSERT INTO test(SYSDATE);
INSERT INTO test(TO_CHAR(SYSDATE,'DD-MON-YYYY'));
INSERT INTO test(TO_CHAR(SYSDATE,'DD-MON-YYYY HH24:MI:SS'));
INSERT INTO test('15/01/2012');
...
commit;
I'm trying to work out how to take a table like this:
IDDate
12502-Feb-07
12516-Mar-07
12523-May-07
12524-May-07
12525-May-07
33302-Jan-09
33303-Jan-09
33304-Jan-09
33317-Mar-09
And display the data like this:
IDPeriodPeriod StartPeriod End
125102-Feb-0702-Feb-07
125216-Mar-0716-Mar-07
125323-May-0725-May-07
333102-Jan-0904-Jan-09
333217-Mar-0917-Mar-09
As you can see, it's split the entries into date ranges. If there is a 'lone' date, the 'period start' and the 'period end' are the same date.
I have a two date fields in my form; valid from date and expiry date.
Currently my valid from date has an inital value property of $$date$$ which automaitcally brings up todays date.
I need my expiry date to automatically show a date 15 years after this date?
i was using sql server there is time keyword but in oracle which keyword i should take instead of time keyword?
View 7 Replies View RelatedI created a table of Number(20,4) column. I inserted an amount value 999999999999999.5555 but this value is rounded off to 1000000000000000.0000 automatically in Oracle. How to avoid this? I tried for less number of digits and I am getting the exact value. Is there any way to get the exact value without changing the datatype?
View 1 Replies View RelatedI am using Anchored datatype wheere the table_name which lies in another schema and the current scheam has select insert update delete access on the the said table of the schema.
Example in current schema LL_TAR
I have defined a varaible in a script/procedure
V_TAG LL_TMR.TAG_DETAILS.TAG_VAL%type where TAG_VALUE column lies in a table TAG_DETAILS which lies
in LL_TMR.
During compilation it gives me an error PLS-00904 saying insufficient privilege. This issue and still use anchored datatype.Or anchored datatype of tables which lie in different schema on the same database server is not allowed? Cause i had read that on some websites that it is allowed for a table which resides on a different schema on a database.
I have created an Object Type and this Type is mapped to a column datatype in a table.This Table has values inserted.
create or replace
type column_type as object (
col_name varchar2(30),
col_comment varchar2(4000)
);
[code]....
ORA-02303: cannot drop or replace a type with type or table dependents...how to resolve this issue without having to delete any column from the table?
Can we use long data type in where clause of the query ?
View 2 Replies View RelatedI have a table which have almost 90000 rows.
1. The datatype of some columns is NVARCHAR2. I want to change it to VARCHAR2 and NUMBER for some.
Query that I want to run:
exec DBMS_METADATA.SET_TRANSFORM_PARAM(DBMS_METADATA.SESSION_TRANSFORM,'SEGMENT_ATTRIBUTES', false);
result: E;;45;45 ;45 ;45 ;S 45
I am not sure but may be I need to set long size before running above query. But when I try to set long size gives below error. "The output from DBMS_METADATA.GET_DDL is a LONG datatype. When using SQL*Plus, your output may be truncated by default. Issue the following SQL*Plus command before issuing the
DBMS_METADATA.GET_DDL statement to ensure that your output is not truncated:"SQL> SET LONG 9999error: Unhandled SET statement: "SET LONG 9999"
I've this problem:
create table t1 ( x long );
Table created.
create table t2 ( x long );
Table created.
insert into t1 values ( 'test long type' );
1 row created.
insert into t2 select * from t1;
*
ERROR at line 1:
ORA-00997: illegal use of LONG datatype
How can I issue this error, I need use also dblink with long type.
I do not want to use the copy command.
I know that you can solve this problem with a stored procedure or anonymous block.
on this query. I need to get a particular value from a column which is a BLOB datatype. Here is the sample
data ID TESTDATA1 Best Buy
00001234 12222 30 00 2
Lowes 00001234 12222 100 00 3
Walmart 00001234 12222 129 00 4
abc 00001234 12222 5000 00 5
Toshiba 00001234 12222 21 00 6
abcdefghij 00001234 12222 49 00
Where '00001234' is the Invoice , '12222' is Netamount field and highlighted in red is the $ amount for that invoice.
The only data i need query to return 12222 (netamount)= $amount. I tried using substr select substr((TESTDATA),19,26)test from TABLEA; But this gives me the only the first row but not other amount which have different positions.
Here is the desired output
OutputID TESTDATA 1
12222 30 2 12222 100 3
12222 129 4 12222 5000 5
12222 21 6 12222 49
The below table and functions are examples, but issue is like this.
i have one issue while forming below sql , Application will form this query at run time wih required inputs
it is failing because the application will not support the clob datatype.
Table : T_E (similar to EMP table structure)
This table has data similar to emp but bulk data around 10k records.
Query formed
select empno,ename, get_employees(deptno)
from t_e;
This sql query this is failing when function return varchar2 string more than 4000 size.Because in sql query size should not exceed 4000 for varchar2 data type , function return size can be upto 20000
Function which
CREATE OR REPLACE FUNCTION get_employees (p_deptno in emp.deptno%TYPE)
RETURN varchar2
IS
l_text varchar2(32767) := NULL;
BEGIN
FOR cur_rec IN (SELECT ename FROM t_e WHERE deptno = p_deptno) LOOP
l_text := l_text || ',' || cur_rec.ename;
END LOOP;
RETURN LTRIM(l_text, ',');
END;
I can try this with clob but application doesn't support that..so i tried with using clob in above function , after that while returning to application i want to conver the clob to char and return the entire string
select empno,ename, to_char(substring(get_employees(deptno),1,4000)) -- first 4000 characters
, to_char(substring(get_employees(deptno),4000,8000)) -- next 4000 characters
from t_e;
But this is failing how to return the entire string in above sql
I am updating a table column which is xml datatype and am getting above error.Below is the process what i did. since the xml is too large i split them into small chunks.
DECLARE
conditionXML CLOB;
ls_xml_2 Clob;
ls_xml_3 clob;
ls_xml_4 Clob;
ls_xml_5 Clob;
ls_xml_6 clob;
ls_xml_7 Clob;
[code]...
how can i update CLOB values in Oracle? I am passing string values to Clob datatype from .Net Eg '13223311','12122112','122125552'
View 6 Replies View RelatedI have a source data in a column with LONG datatype. I want to insert that data into a separate table in a column which has BLOB datatype.
View 9 Replies View Related i am running one query which is here
INSERT INTO shiftsample (Empid, PPDate, Inpunch, outpunch)( SELECT Emp_ID, PDate, In_Punch, Out_Punch FROM ProcessDailyData WHERE PDate = to_char(2012-10-15,'yyyy-MM-dd') AND Emp_ID = '00000001' );
in this query pdate has timestamp datatype and in shift sample ppdate column has date type. so i am not able to insert value from process daily data table.
getting this error.
SQL Error: ORA-01481: invalid number format model
01481. 00000 - "invalid number format model"
*Cause: The user is attempting to either convert a number to a string
via TO_CHAR or a string to a number via TO_NUMBER and has
supplied an invalid number format model parameter.
How to get max and min value from a varchar2 datatype column?
CREATE TABLE TEST
(
WEIGHT VARCHAR2(20)
);
INSERT INTO TEST VALUES('100');
INSERT INTO TEST VALUES('120');
INSERT INTO TEST VALUES('113');
INSERT INTO TEST VALUES('145');
INSERT INTO TEST VALUES('204');
INSERT INTO TEST VALUES('130');
I've to find the max and min weight from this data.
I have question related to LONG datatype. Actually from google and get to know that one table can have only one LONG datatype when i searched for reason . i got these resons:-
With 9i (I believe) and later versions, Oracle deprecates using the long datatype in favor of the lob (clob, nclob and blog) datatypes. It is only supported for backward compatibility.
Restriction:- It can not be used in create type as an attribute of the defined type.
It can not be used in where conditions.
There can be no indexes on long columns.
Regular Expression are not possible.
long can not be returned from a stored function.
SQL can not call functions that have an attribute of type long.
And even more restrictions.
So I want to know that is only reason because of that Oracle doesn't allow us to make two Column or is there any strong reason which make it more logical Like storing of data in Row blocks or some thing else.
I have two tables with BLOB datatype. I am trying to copy from one column to another column , i am getting errors
CREATE OR REPLACE PROCEDURE update_blob_lob_copy(
v_id in integer,
v_string in varchar
)
as
auditlob lobdemoaudit.theblob%type;
sourcelob lobdemo.THEBLOB%type;
[code]...