SQL Developer: to_date function..
Hi..
Can anyone tell me what is wrong with the following:
select to_date('02-Jun-2008 12:10:00', 'DD-MON-RR:HH24:MI:SS') - 2 "Subtract 2 days" from dual;
I get the following result:
31-MAY-08
I thought the format mask supplied would generate the result in the requested format with HH:MI:SS but, as you can see...it doesn't. The nls_date_format is DD-MON-RR, but that shoudn't matter as I have supplied an alternate mask to use (should it..?).
It's just bugging me..using SQL Developer Version 1.5.5
Thanks,
Rory
Hi Roy,
I'm sorry, but You're wrong.
The format mask you provided is only to transform a text into date format. Not for displaying a date. So the default format mask used to display the date is the one defined in NLD_DATE_FORMAT.
If you want display date in 'DD-MON-RR:HH24:MI:SS' format you should either modify the NLS_DATE_FORMAT or use a TO_CHAR in your select ... from dual;
Pierre.
Similar Messages
-
Sql query to_date function
hi all,
I am working on a project where some sql scripts are already been developed by
someone else.
In the code i found
Select col_name
from table_name
where txn_dt between to_date(to_date('05-dec-2007') - 6) and to_date('05-dec-2007');
I am wondering whats the usage of 2 to_date function in the where clause.
This can be achieved using this as well:
Select col_name
from table_name
where txn_dt between to_date('05-dec-2007') - 6 and to_date('05-dec-2007');
Can anybody tell me this diff if there is any?
Thanks
Shaneto_date(to_date('05-dec-2007') - 6)This is an error. Not a syntax error, but a runtime error waiting to happen.
The inner to_date is fine (except it should have a format mask) but the outer to_date is expecting a character type and it's getting a date. So it has to be converted.
All this depends on the nls settings which could change.
Ideally, the code should read:
Select col_name
from table_name
where txn_dt between to_date('05-dec-2007','dd-mon-yyyy') - 6 and to_date('05-dec-2007','dd-mon-yyyy');
(on second thought...if the nls settings match this date format, it should convert without error in both to_date functions, but still...why do it?)
Edited by: SomeoneElse on Dec 12, 2008 9:12 AM -
Hi I need to import multiple records (5000) in a table . I am using sql developer 1.5.1 but import function is not working properly. please suggest the steps .
thanks
RuchiI would say that the import function in Sql Developer is still evolving...
So far I have tried it in 1.5.1 (where it mostly does NOT work, especially with Excel files), with 1.5.3 (where I think works the best) and with 1.5.4 where new import requirements make it unnecessarily hard to work with.
What I mean by that, is that although in 1.5.3 you can match your CSV text columns to existing Table columns, in 1.5.4 you immediately get an error and the import aborts if the CSV text columns do not match in number and name the existing table column. I would like to have the option to match the columns myself, since I do not always have the luxury of importing all the columns with the names provided in the CSV file. -
Sql developer search functionality could be better
the search window closes after the first match,
when I am looking for all matches for a string, it takes more time.
There are plenty of example for good search functionality, with what I have experienced , the search feature in TEXTPAD is simple and works well.
oralce sql developer 2.1.1.64
I hope oracle recognizances this enhancement.
- DineshHave you tried using any of the shortcut keys to aid in your searching?
Alt-F3 : Find Next Result
Shift-F3 : Find Previous Result
(In a SQL Worksheet) Ctrl-F Brings the search menu back up
(In a Code Editor Window) Ctrl-F Brings you to the search bar at the top of the editor. Ctrl-F twice will bring the search menu back up. -
Problem in deploying Java Extension to ORacle SQL Developer
Hi all,
I have developed a simple Java extension using Oracle Jdeveloper. This extension creates a preference in Tools->Preferences.
I have deployed it on Jdeveloper and it works fine. But when I deploy it on Oracle SQL Developer its functionality does not work
I am using JDeveloper 11.1.1.4
and Oracle SQL Developer 3.2.20.09 (Latest Version).Hello,
You are giving few informations. Is the extension listed in the extensions tab in the 'About' tab? Are you able to deploy any extension to SQLD?
Joop -
SQL Developer not accepting certain characters from the keyboard
Hello,
I have been using SQL Developer for 5 or 6 months now, with minor issues and great satisfaction.
A few days ago, just out of the blue, in the middle of the day, SQL developer started not accepting the following characters:
Ctrlv, Ctrl + c, F5, F9 (I Think all function keys), BackSpace, Delete, Enter and arrow keys.+*
T*his is only happening in the text editor part*. I am able to use this keys in the results, whether they were a script output or an execute query output.
SQL developer also functions properly (if i paste using the mouse, paste works.. and all the other keys)
I checked the pc for viruses, using AVG, no viruses were found (my avg is updated daily and runs daily virus checks on a schedule, and this issue has been here for the past 1 or 2 weeks, so it was a virus, i think it should have been discoverd, besides, the keys are still working in sql developer, only not in the text editor part)
Needless to say, but if i run notepad and type, keys work properly.
I also reinstalled it in another folder with no luck
Tried so many restarts .. no luck
Tried it in safe mode .. no luck
I am using SQL developer Version 1.5.4, Build MAIN-5940.. on Windows Xp
I am suspecting there's some option in it that I disabled without paying attention..
HELP!!!
Regards,
CharlesAll that time trying possible solutions is understandable, but then typing them in your post... when searching the forum would have given you the solution under 1 minute:
Preferences - Accelerators - Load Preset - Default
Hope that helps,
K. -
Password change fails in SQL Developer with verify function...
A couple of months ago I enforced a password verify function on our 11.2.0.3 databases and also one legacy 10.2.0.4 database.
At the time I tested on my account (which had elevated privileges...doh!). Now some users are hitting expiry, they can't change it via SQL Developer.
If I create a user with 'create session' privilege and set their profile to one that uses the verify function (see both below), I then log in to SQL Developer (we have tried with versions 3.1 (Windows) and 3.2 (Linux) with same failure results.
BTW,.. the password verify function enforces the following:
password must be minimum of 8 characters
password must not be the same as the user name, or user name (1-100)
password must contain at least a single digit
password must contain at least a single character
1. Works = I log into the local server and run command line SQLPlus, type 'password' and update. I can successfully change my password.
2. Fails = I log into the local server and run command line SQLPlus, type 'alter user <me> identified by <newpwd>;' I get:
TEST: SUTEMP > alter user sutemp identified by carport9999;
alter user sutemp identified by carport9999
ERROR at line 1:
ORA-28221: REPLACE not specified
This error is because the account does not have the 'alter user' privilege. I'm okay with this, as I don't want our users having this privilege.
3. I start SQL Developer 3.2, type 'alter user <me> identified by <newpwd>;' I get the same ORA-28221 error as above. That is fine, and as expected.
4. Now in SQL Developer, I type 'password', set a valid password, but I get 'Failed to change password' in the Script Output tab.
I have a database 'after servererror on database' trigger set, and querying the database table it is logging into, I see a record with a date stamp matching my failure with a server_error=28221 (the same as above).
So I'm wondering if I'm doing something wrong here, or if this is a bug in SQL Developer. I don't want standard users having 'alter user' privileges, but I do want to enforce password verification.
I get the same result on three 11.2.0.3 databases (haven't tried any more but suspect same results for others) and one legacy 10.2.0.4 database, and using SQL Developer 3.1 and 3.2.
DBA_PROFILE used:
PROFILE
RESOURCE_NAME
RESOURCE LIMIT
CTRU
COMPOSITE_LIMIT
KERNEL DEFAULT
CTRU
SESSIONS_PER_USER
KERNEL 10
CTRU
CPU_PER_SESSION
KERNEL DEFAULT
CTRU
CPU_PER_CALL
KERNEL DEFAULT
CTRU
LOGICAL_READS_PER_SESSION KERNEL DEFAULT
CTRU
LOGICAL_READS_PER_CALL
KERNEL DEFAULT
CTRU
IDLE_TIME
KERNEL DEFAULT
CTRU
CONNECT_TIME
KERNEL DEFAULT
CTRU
PRIVATE_SGA
KERNEL DEFAULT
CTRU
FAILED_LOGIN_ATTEMPTS
PASSWORD 10
CTRU
PASSWORD_LIFE_TIME
PASSWORD 180
CTRU
PASSWORD_REUSE_TIME
PASSWORD DEFAULT
CTRU
PASSWORD_REUSE_MAX
PASSWORD 5
CTRU
PASSWORD_VERIFY_FUNCTION PASSWORD VERIFY_FUNCTION_11G
CTRU
PASSWORD_LOCK_TIME
PASSWORD .002
CTRU
PASSWORD_GRACE_TIME
PASSWORD 21
16 rows selected.
Verify Function used:
$ cat utlpwdmg.sql
Rem
Rem $Header: utlpwdmg.sql 02-aug-2006.08:18:05 asurpur Exp $
Rem
Rem utlpwdmg.sql
Rem
Rem Copyright (c) 2006, Oracle. All rights reserved.
Rem
Rem NAME
Rem utlpwdmg.sql - script for Default Password Resource Limits
Rem
Rem DESCRIPTION
Rem This is a script for enabling the password management features
Rem by setting the default password resource limits.
Rem
Rem NOTES
Rem This file contains a function for minimum checking of password
Rem complexity. This is more of a sample function that the customer
Rem can use to develop the function for actual complexity checks that the
Rem customer wants to make on the new password.
Rem
Rem MODIFIED (MM/DD/YY)
Rem suren 05/09/13 - customise for NIHI use
Rem asurpur 05/30/06 - fix - 5246666 beef up password complexity check
Rem nireland 08/31/00 - Improve check for username=password. #1390553
Rem nireland 06/28/00 - Fix null old password test. #1341892
Rem asurpur 04/17/97 - Fix for bug479763
Rem asurpur 12/12/96 - Changing the name of password_verify_function
Rem asurpur 05/30/96 - New script for default password management
Rem asurpur 05/30/96 - Created
Rem
-- This script sets the default password resource parameters
-- This script needs to be run to enable the password features.
-- However the default resource parameters can be changed based
-- on the need.
-- A default password complexity function is also provided.
-- This function makes the minimum complexity checks like
-- the minimum length of the password, password not same as the
-- username, etc. The user may enhance this function according to
-- the need.
-- This function must be created in SYS schema.
-- connect sys/<password> as sysdba before running the script
CREATE OR REPLACE FUNCTION verify_function_11G
(username varchar2,
password varchar2,
old_password varchar2)
RETURN boolean IS
n boolean;
m integer;
differ integer;
isdigit boolean;
ischar boolean;
ispunct boolean;
db_name varchar2(40);
digitarray varchar2(20);
punctarray varchar2(25);
chararray varchar2(52);
i_char varchar2(10);
simple_password varchar2(10);
reverse_user varchar2(32);
BEGIN
digitarray:= '0123456789';
chararray:= 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
-- Check for the minimum length of the password
IF length(password) < 8 THEN
raise_application_error(-20001, 'Password length less than 8');
END IF;
-- Check if the password is same as the username or username(1-100)
IF NLS_LOWER(password) = NLS_LOWER(username) THEN
raise_application_error(-20002, 'Password same as or similar to user');
END IF;
FOR i IN 1..100 LOOP
i_char := to_char(i);
if NLS_LOWER(username)|| i_char = NLS_LOWER(password) THEN
raise_application_error(-20005, 'Password same as or similar to user name ');
END IF;
END LOOP;
-- Check if the password contains at least one letter, one digit
-- 1. Check for the digit
isdigit:=FALSE;
m := length(password);
FOR i IN 1..10 LOOP
FOR j IN 1..m LOOP
IF substr(password,j,1) = substr(digitarray,i,1) THEN
isdigit:=TRUE;
GOTO findchar;
END IF;
END LOOP;
END LOOP;
IF isdigit = FALSE THEN
raise_application_error(-20008, 'Password must contain at least one digit, one character');
END IF;
-- 2. Check for the character
<<findchar>>
ischar:=FALSE;
FOR i IN 1..length(chararray) LOOP
FOR j IN 1..m LOOP
IF substr(password,j,1) = substr(chararray,i,1) THEN
ischar:=TRUE;
GOTO endsearch;
END IF;
END LOOP;
END LOOP;
IF ischar = FALSE THEN
raise_application_error(-20009, 'Password must contain at least one digit, and one character');
END IF;
<<endsearch>>
-- Check if the password differs from the previous password by at least
-- 3 letters
IF old_password IS NOT NULL THEN
differ := length(old_password) - length(password);
differ := abs(differ);
IF differ < 3 THEN
IF length(password) < length(old_password) THEN
m := length(password);
ELSE
m := length(old_password);
END IF;
FOR i IN 1..m LOOP
IF substr(password,i,1) != substr(old_password,i,1) THEN
differ := differ + 1;
END IF;
END LOOP;
IF differ < 3 THEN
raise_application_error(-20011, 'Password should differ from the old password by at least 3 characters');
END IF;
END IF;
END IF;
-- Everything is fine; return TRUE ;
RETURN(TRUE);
END;
alter profile ctru limit password_verify_function verify_function_11g;
alter profile default limit password_verify_function verify_function_11g;
alter profile web_and_it limit password_verify_function verify_function_11g;okay,... I just saw another website which shows I should put in the 'replace <oldpwd>' clause in.
This works in SQL Developer: alter user sutemp identified by carport999 replace garage999;
So why does the 'password' command fail? (Developers: it would also be helpful to have the ORA- error displayed as opposed to 'Failed to change password') -
EA2--Oracle SQL Developer 1.5 issue with open,function, procedurres.
Hi Friends,
After install SQL Developer 1.5, I can connection to database and see table object, view. However, I am not able to view codes of package, procedure and function and got an error message :
an error was encountered performing the requested operation: closed Connection Vendor code 17008 when I try to explorer folder of package, function and procedure.
Any suggestion for this issue?
Thanks,
JImmyI am on version 1.2.1 and I am getting this error message more and more when compiling packages. I am tired of restarting SQL developer.
-
Sql Developer - View source code of procedures, functions & packages in another schema
Our developers need the ability to view procedures, function, packages etc. in the production database (using SQL DEVELOPER). They don't have access to sign on as the owner of these
objects in Production. They must use their own limited access UserID for this purpose.
This limited access UserID has been granted select privilege on DBA_SOURCE & DBA_OBJECTS. The developers need the ability to view the source of these object via
the tree view in SQL DEV. They should be able to click on "other users" in the SQL DEV tree view and see a listing of the owner schema objects. Then they should
be able to select the desired object and view the source code. These developers are used to using GUI interfaces. Selecting from DBA_SOURCE would not be an
option for them.
I understand that if the limited user is granted SELECT ANY DICTIONARY or SELECT_CATALOG_ROLE then this functionality will work. The problem is those
privileges/roles provide much more access than should be granted to these limited access users. Granting DBA to these users is also not an option.
In TOAD and other end-user tools this functionality works when only select privilege on DBA_SOURCE & DBA_OBJECTS has been granted. We need this same functionality
in SQL DEV.
While searching this forum and the internet, I see that other installations have this same issue.
Please enhance SQL Developer with this functionality.
Thank you, ellenJust to double check that I'm interpreting the problem correctly, is the following true:
select * from all_objects where object_name = 'DBA_SOURCE'
returns nothing
select * from dba_source where name = your PL/SQL module
returns all the code -
Equivalent of to_date function in Ms SQL and using it in Evaluate function
Hi,
I am trying to find out a function in MS SQL which is equivalent to to_date function in oracle. Please find below the advanced filter i am trying to use in OBIEE.
Evaluate('to_date(%1,%2)' as date ,SUBSTRING(TIMES.CALENDAR_MONTH_NAME FROM 1 FOR 3)||'-'||cast(TIMES.CALENDAR_YEAR as char(4)),'MON-YYYY')>=Evaluate('to_date(%1,%2)' as date,'@{pv_mth}'||'@{pv_yr}','MON-YYYY') and Evaluate('to_date(%1,%2)' as date ,SUBSTRING(TIMES.CALENDAR_MONTH_NAME FROM 1 FOR 3)||'-'||cast(TIMES.CALENDAR_YEAR as char(4)),'MON-YYYY') <=timestampadd(sql_tsi_month,4,Evaluate('to_date(%1,%2)' as date,'@{pv_mth}'||'@{pv_yr}','MON-YYYY'))
The statement above works fines with oracle DB with to_date function. The same statement throws an error with MS SQL since to_date is not a built in function.
With MS SQL I tried with CAST, not sure how to pass parameters %1 and %2.
Please help me how to use Evaluate function and passing parameters along with to_date funtion in MS SQL.
Regards!
RRHi,
please refer to this thread for useful information on using to_char and to_date functions of oracle in MS SQL server:
http://database.ittoolbox.com/groups/technical-functional/sql-server-l/how-to-write-to-to_char-and-to_date-sql-server-351831
Hope this helps.
Thanks,
-Amith. -
Function will not run (and shows with red cross in SQL Developer)
I have created the function below by typing into the "Enter SQL Statement" box in the SQL Developer tool and running. I see the message "create or REPLACE FUNCTION Statement Processed". I see the Function in the tree view, but it has a red cross icon next to it, so I guess somethings wrong with it. When I try to run it I get the message "The selected program is in an invalid state for running. Recompile the program and try again." If I right-click the function and compile then I get no errors but the red cross remains and I still can't run it.
What am I doing wrong?
Also, I am planning on supplying a SQL script to customers that will have this function at the top of the script, and then I will use the function throughout the rest of the script to decide whether or not to drop a table before re-creating it. Will that be ok? i.e. will the function be available to the rest of the script, or would the function creation need to be followed by a commit/grant/other?
CREATE OR REPLACE FUNCTION CHECK_TABLE_EXISTS(tableName VARCHAR2)
RETURN BOOLEAN IS
tableExists NUMBER(1,0);
BEGIN
SELECT COUNT(*) INTO tableExists FROM user_tables WHERE table_name=tableName;
IF tableExists = 1 THEN
RETURN TRUE;
ELSE
RETURN FALSE;
END IF;
END CHECK_TABLE_EXISTS;Thanks,
PaulHello Try the same at sqlplus and see how it goes. It should not throw any error messages as I tried the same as a normal user Scott with only (connect, resource) priveleges. You dont have to grant any specific previleges for user_tables.
-Sri
SRI>conn scott/tiger@sri
Connected.
SRI>CREATE OR REPLACE FUNCTION CHECK_TABLE_EXISTS(tableName VARCHAR2)
2 RETURN BOOLEAN IS
3 tableExists NUMBER(1,0);
4 BEGIN
5 SELECT COUNT(*) INTO tableExists FROM user_tables WHERE table_name=tableName;
6 IF tableExists = 1 THEN
7 RETURN TRUE;
8 ELSE
9 RETURN FALSE;
10 END IF;
11 END CHECK_TABLE_EXISTS;
12 /
Function created.
SRI>set serverout on
SRI>begin
2 if check_table_exists('EMP') = TRUE
3 THEN
4 dbms_output.put_line('Found');
5 else
6 dbms_output.put_line('Not Found');
7 end if;
8 end;
9 /
Found
PL/SQL procedure successfully completed. -
Sql developer with compute function/ add total to column.
Hello experts i've been strugglin for a couple of hours on this. and im not sure if this is the forum i should be posting this but i could not found a forum directly related to sql developer.
I would like to use the compute function in sql developer but it does not appear to work can someone please point me in the right direction.
i followed this documentation
http://download.oracle.com/docs/cd/B19306_01/server.102/b14357/ch6.htm
but it does not seem to do the trick. I basically just would like to add a total at the end of my query ?...
can someone throw me a bone on this one.
Miguelcolumn DUMMY NOPRINT
compute sum of aamt on DUMMY
break on dummy
select a_fa_idoc, b_fr_idoc, a_amt, b_amt, (a_amt-b_amt)
from
(SELECT a.fa_idoc a_fa_idoc, SUM(a.amt) a_amt from fwrinva a group by a.fa_idoc) fwarinva_summary
inner join
(SELECT b.fr_idoc b_fr_idoc, sum(b.amt) b_amt from fwrinvc b group by b.fr_idoc) fwrinvc_summary
on( fwarinva_summary.a_fa_idoc = fwrinvc_summary.b_fr_idoc)
where (a_amt - b_amt) = 0;here is my query but it does not put a total on the end? -
How to debug a Package / function in PL SQL developer ??
How can we debug a Package / function in PL SQL developer ??
i want to debug a code line by lineKarthick_Arp wrote:
This question does not belong to this fourm. We have a {forum:id=260} forum for such question.Not even there Karthick. PL/SQL Developer is a 3rd party tool, not Oracle's SQL Developer, so it doesn't even belong on the Oracle forums. -
Using XML functions in SQL Developer
Hi,
I'm using OSD 1.5.3 on a WinXP machine. I love OSD and use it every day! But I think i found a little bug. When you use some Oracle XML functions like (XMLELEMENTS and XMLAGG) in your query (these functions return CLOB values) it hangs OSD.
For Example:
SELECT XMLELEMENT("Relation",
XMLELEMENT("Name", 'Dennis'),
XMLELEMENT("DateOfBirth", '09/28/1975')
) as Relation
FROM DUAL;
Are there some parameters I can set to prevent this, or is this a bug?
Kind Regards,
D.Your query works fine for me from SQL Dev 1.5.3 (JDK 1.6.0_06), using either a JDBC or TNS connection (Oracle Client 9.2) to a 10.2.0.3 DB. Another thing which I have no idea if it is relevant (someone else may be able to say) is the following line from Help > About > Properties:
oracle.xdkjava.compatibility.version 9.0.4
Given that it works fine over TNS connections from SQL*Plus and PL/SQL Developer, I would assume that it is something related to your SQL Developer setup, unless you are using a different version of the Oracle client for these tools.
theFurryOne -
Finding a function name in PL/SQL Developer
Hi,
Newbie here...Is there a feature in PL/SQL Developer that will let me search through all my api's for a function by a string contained in the function name? For instance I would like to see all the functions in any of the api's that contain the string 'get' rather than try to guess in what package the function I'm looking for resides,
Thanks in advance for any helpDo you mean PL/SQL Developer? If so, you're on the wrong forum.
SQL Developer 1.5 and above uses PLScope to search for PL/SQL objects, when connected to an Oracle Database 11g.
Sue
Maybe you are looking for
-
Add a button to the branch/root in a Flex Tree
Can someone provide me code or guide me how to add a button to all nodes that has children/leaf( but not to leaf). I tried from the example in this link http://www.remwebdevelopment.com/dev/a31/Flex-Checkbox-TreeItemRenderer.html , but I ma gettin
-
HT201210 IPOD WONT UPDATE OR RESTORE
I haven't been able to update my iPad 2 for the longest time now. I've tried to do it just through the device only for it to get stuck on calculating download time and then give me an error message. I've tried to go through my computer as well only t
-
Balance Score Card Configuration Guide
Hi Experts, Please guide me how to configure Balance Score Card In HCM. if any document is available please send that also to my id thanks Roopesh
-
Netflix issue, can't see all shows
Hi guys, I've got netflix linked up to my ATV3 and noticed I can't see some shows. An example is South Park, I can only see season 11-15 on ATV3 whereas on my computer I can scroll from season 1-15 (there's no 1-10 on ATV3). I've noticed I'm missing
-
Brspace command for Oracle on SAP system
Hi all! I need to perform a complete "reorg" of my sap BW 7 system (NW2004s). I check the sap note 646681 but I din't find anything for a complete database reorganization. I try to execute the following command: BRSPACE -F TBREORG -T SAPSR3DB after t