Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added ability to create database views. Closes #3.
Use the SQLCreateView class to generate a CREATE VIEW statement.
- Loading branch information
Showing
2 changed files
with
86 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
' ___________________________________________________ | ||
' | ||
' © Hi-Integrity Systems 2012. All rights reserved. | ||
' www.hisystems.com.au - Toby Wicks | ||
' ___________________________________________________ | ||
' | ||
|
||
Option Strict On | ||
Option Explicit On | ||
|
||
Namespace SQL | ||
|
||
Public Class SQLCreateView | ||
Inherits SQLStatement | ||
|
||
Private pstrName As String | ||
Private pobjSelect As SQLSelect | ||
|
||
Public Sub New() | ||
|
||
End Sub | ||
|
||
Public Sub New(ByVal strViewName As String, ByVal objSelectStatement As SQLSelect) | ||
|
||
Me.Name = strViewName | ||
Me.Select = objSelectStatement | ||
|
||
End Sub | ||
|
||
Public Property Name() As String | ||
Get | ||
|
||
Return pstrName | ||
|
||
End Get | ||
|
||
Set(ByVal Value As String) | ||
|
||
If String.IsNullOrEmpty(Value) Then | ||
Throw New ArgumentNullException() | ||
End If | ||
|
||
pstrName = Value | ||
|
||
End Set | ||
End Property | ||
|
||
Public Property [Select] As SQLSelect | ||
Get | ||
|
||
Return pobjSelect | ||
|
||
End Get | ||
|
||
Set(value As SQLSelect) | ||
|
||
If value Is Nothing Then | ||
Throw New ArgumentNullException | ||
End If | ||
|
||
pobjSelect = value | ||
|
||
End Set | ||
End Property | ||
|
||
Public Overrides ReadOnly Property SQL() As String | ||
Get | ||
|
||
If String.IsNullOrEmpty(Me.Name) Then | ||
Throw New Exceptions.DatabaseObjectsException("View name has not been set") | ||
ElseIf pobjSelect Is Nothing Then | ||
Throw New Exceptions.DatabaseObjectsException("Select statement has not been set") | ||
End If | ||
|
||
Return _ | ||
"CREATE VIEW " & _ | ||
SQLConvertIdentifierName(Me.Name, Me.ConnectionType) & " AS " & _ | ||
pobjSelect.SQL | ||
|
||
End Get | ||
End Property | ||
|
||
End Class | ||
|
||
End Namespace |