Showing posts with label Oracle 10g:SQL. Show all posts
Showing posts with label Oracle 10g:SQL. Show all posts

Wednesday, April 6, 2011

Oracle SQL: Convert a String to DateTime


 Convert a  string (with a data & time)  To  DateTime in SQL:

select to_date(TO_CHAR(sysdate,'MM/DD/YYYY')||' 12:00:01 AM','MM/DD/YYYY hh:mi:ss pm') from dual;




highlighted one will be String containing date time.

:-)

Tuesday, June 1, 2010

Oracle : Delete & Update Queries Using Joins

The SQL's are consutructed using dummy table.. below are the just framework. 
Modify according to your  requirement

Delete Query :-
---------------------

Delete from table1 A
where exists (select * from  table2 B
WHERE A.EMPLID = B.EMPLID AND A.EFFDT = B.EFFDT AND A.EFFSEQ = B.EFFSEQ AND
B.Col5 = 6556 AND B.Col_status = 'S')


Update Query:-
-------------

update table2 A set A.STATUS = 'V'
where exists (Select * from table1 B
WHERE A.EMPLID = B.EMPLID AND A.EFFDT = B.EFFDT AND A.EFFSEQ = B.EFFSEQ AND
B.col5 = 6556 AND B.col_status = 'S')


Thanks
Srinivas

Sunday, May 9, 2010

Regular Expressions in Oracle 10g

In Oracle Database 10g, you can use both SQL and PL/SQL to implement regular expression support. Regular expressions are a method of describing both simple and complex patterns for searching and manipulating.


To implement regular expression support in either SQL or PL/SQL, you use a new set of functions. These functions are:
Function Name Description
REGEXP_LIKE Similar to the LIKE operator, but performs regular expression matching instead of simple pattern matching
REGEXP_INSTR Searches for a given string for a regular expression pattern and returns the position were the match is found
REGEXP_REPLACE Searches for a regular expression pattern and replaces it with a replacement string
REGEXP_SUBSTR Searches for a regular expression pattern within a given string and returns the matched substring

POSIX Metacharacters in Oracle Database Regular Expressions

Metacharacters are special characters that have a special meaning, such as a wild card character, a repeating character, a nonmatching character, or a range of characters.
You can use several predefined metacharacter symbols in the pattern matching with the functions.
Symbol Description
*
Matches zero or more occurrences
|
Alternation operator for specifying alternative matches
^/$
     
Matches the start of line and the end of line
[]
Bracket expression for a matching list matching any one of the expressions represented in the list
[^exp]
If the caret is inside the bracket, it negates the expression.
{m}
Matches exactly m times
{m,n}
Matches at least m times but no more than n times
[: :]
Specifies a character class and matches any character in that class
\
Can have four different meanings: (1) stand for itself; (2) quote the next character; (3) introduce an operator; (4) do nothing
+
Matches one or more occurrences
?
Matches zero or one occurrence
.
Matches any character in the supported character set (except NULL)
()
Grouping expression (treated as a single subexpression)
\n
Backreference expression
[==]
     
Specifies equivalence classes
[..]
     
Specifies one collation element (such as a multicharacter element)

More on
Oracle

:-)