Wednesday, March 31, 2010

sp_helptext in Oracle

To get a result similar to sp_helptext SQL Server procedure in Oracle, you can use the following query:

 

SET LINESIZE 132
SET LONG 4000
SELECT TEXT 
  FROM ALL_SOURCE
 WHERE NAME = 'YOUR_PROCEDURE_NAME'

 

If you have another solution, please let me know… I didn’t find anything better than this…

PS: You should use the command window to be able to execute this query

Monday, March 22, 2010

XSD generator (converts XML to an XSD file)

For those who needs an XSD file and doesn’t have enough time to learn how to do it, you can use the functions in this website to get your xml converted in xsd:

 

http://www.hitsw.com/xml_utilites/

 

 

Thursday, March 4, 2010

Regular Expressions Code Template in VBScript

The template below is to be used when you have a string and you want to get date information.

varString = the original string that will be used
iItem = Number of ocurrency (1 = first , 2 = second and so on)
sDate = The date time based on a month retrieved from the original string.

Example: 12345 12MAR 25APR 3MAY (Remember: the months are in English)…

Function CheckDate(varString, iItem, sDate)

    Dim iIndex
    Dim objRegExp, objMatch, objMatches
    Dim sDay
    Dim iMonthChar
    Dim bIsDate
    Dim strMonths
    Dim strMonth
   
    bIsDate = False
    'check if the string contains a month
    Set objRegExp = CreateObject("VBScript.RegExp")
    objRegExp.Pattern = "JAN|FEB|MAR|APR|MAY|JUN|JUL|AUG|SEP|OCT|NOV|DEC"
    objRegExp.IgnoreCase = True
    objRegExp.Global = True
   
    'get the matches if there be
    Set objMatches = objRegExp.Execute(varString)
    iIndex = 1
    For Each objMatch In objMatches
        If iIndex = iItem Then
            strMonth = objMatch.value
            iMonthChar = objMatch.FirstIndex
            Exit For
        Else
            iIndex = iIndex + 1
        End If
    Next
    
    If strMonth = "" Then
        sDate = ""
    Else
        sDay = Mid(varString, iMonthChar - 1, 2)
        If IsNumeric(sDay) Then
            sDate = GetFormattingData(sDay & strMonth, False)
            bIsDate = IsDate(sDate)
        End If
    End If
     CheckDate = bIsDate
 End Function

Controlling oracle transactions using VBScript

Very nice sample!

 

http://dev-notes.com/code.php?q=67

 

You can also use Oracle OleDBprovider, it is not mandatory to use MSDAORA.

 

 

Tuesday, March 2, 2010

How to create/drop/enable/disable a primary key in oracle

Hopefully this link works forever, hahahahaha

 

http://www.techonthenet.com/oracle/primary_keys.php