約 2,076,528 件
https://w.atwiki.jp/atyou/pages/57.html
SQLPLUSを起動し繰り返しSQLを実行(Linux・Unix) sqlを実行する → @ファイル もしくは / sqlを編集する → ed ローカルのフォルダを移動する → host cd 移動先 表示行数を増やす → set lin 行数 iSQL*Plusは、iSQL*Plus Serverを使用し、クライアントからはWebブラウザ経由で接続します。事前にiSQL*Plusのリスナープロセスをサーバで起動させておく必要があります。 $ isqlplusctl start Database Control同様、$ORACLE_HOME/install/portlist.iniファイルを確認すれば、iSQL*Plusのポート番号が確認できます。 iSQL*Plus HTTPポート番号 =5560 確認したポート番号を使用して、iSQL*Plusに接続します。 http //hostname 5560/isqlplus http //www.confrage.com/oracle/sqlplus/
https://w.atwiki.jp/dai1357/pages/18.html
SQL*Plus と iSQL*Plus SQL*Plus,iSQL*Plus DBの起動や停止、記憶域の操作、オブジェクトの作成、 表に対してSQL文を実行することができる。 できること ・データベース管理操作の実行 ・データベース内の表の問い合わせ ・データベース内の表の挿入、更新、削除 ・PL/SQLコマンドの入力 ・検索結果の書式設定 ・検索結果のOSファイル出力 SQL*Plusの実行 $ sqlplus または $ sqlplus /nolog iSQL*Plusの実行 iSQL*Plusリスナー・プロセスの起動 $ isqlplusctl start iSQL*Plusへのアクセス http //hostname 5560/isqlplus
https://w.atwiki.jp/dai1357/pages/19.html
iSQL*Plus SQL*Plusにまとめて書いてます。
https://w.atwiki.jp/mieyanman/pages/22.html
zip2 zip3 [sqlplus_csv] clsDesc.vb Public Class clsDesc Public Property c0Name As String = "" Public Property c1Null As String = "" Public Property c2Type As String = "" End Class clsSelectionRowsMove.vb Public Class clsSelectionRowsMove Dim m_DataGridView As DataGridView = Nothing Dim m_RowsCount As Integer = 0 Dim m_SelectedRowsCount As Integer = 0 Dim m_SelectedRowMin As Integer = 0 Dim m_SelectedRowMax As Integer = 0 Dim m_MoveUpEnabled As Boolean = False Dim m_MoveDownEnabled As Boolean = False Public ReadOnly Property RowsCount() As Integer Get Return m_RowsCount End Get End Property Public ReadOnly Property SelectedRowsCount() As Integer Get Return m_SelectedRowsCount End Get End Property Public ReadOnly Property SelectedRowMin() As Integer Get Return m_SelectedRowMin End Get End Property Public ReadOnly Property SelectedRowMax() As Integer Get Return m_SelectedRowMax End Get End Property Public ReadOnly Property MoveUpEnabled() As Boolean Get Return m_MoveUpEnabled End Get End Property Public ReadOnly Property MoveDownEnabled() As Boolean Get Return m_MoveDownEnabled End Get End Property Public Enum MoveType Top Up Down Bottom End Enum Public Sub New(wp_DataGridView As DataGridView) If wp_DataGridView Is Nothing Then Return End If m_DataGridView = wp_DataGridView m_RowsCount = m_DataGridView.Rows.Count If m_RowsCount 0 Then m_SelectedRowsCount = m_DataGridView.SelectedRows.Count If m_SelectedRowsCount 0 Then Dim w_RowMin As Integer = m_RowsCount Dim w_RowMax As Integer = 0 For i As Integer = m_SelectedRowsCount - 1 To 0 Step -1 If w_RowMin m_DataGridView.SelectedRows(i).Index Then w_RowMin = m_DataGridView.SelectedRows(i).Index End If If w_RowMax m_DataGridView.SelectedRows(i).Index Then w_RowMax = m_DataGridView.SelectedRows(i).Index End If Next m_SelectedRowMin = w_RowMin m_SelectedRowMax = w_RowMax If m_RowsCount 1 Then If m_SelectedRowMin 0 Then m_MoveUpEnabled = True End If If m_SelectedRowMax m_RowsCount - 1 Then m_MoveDownEnabled = True End If End If End If End If End Sub Public Sub SelectionRowsMove(wp_Move As MoveType) If m_DataGridView.SelectedRows.Count = 0 Then Return End If Dim w_SelectionRowList As New List(Of DataGridViewRow) For Each r As DataGridViewRow In m_DataGridView.SelectedRows w_SelectionRowList.Add(r) m_DataGridView.Rows.Remove(r) Next Dim w_Row1 As Integer = 0 Select Case wp_Move Case MoveType.Top w_Row1 = 0 Case MoveType.Up w_Row1 = m_SelectedRowMin - 1 Case MoveType.Down w_Row1 = m_SelectedRowMin + 1 Case MoveType.Bottom w_Row1 = m_DataGridView.Rows.Count Case Else End Select Dim w_Row2 As Integer = w_Row1 + w_SelectionRowList.Count - 1 m_DataGridView.Rows.Insert(w_Row1, w_SelectionRowList.Count) For i As Integer = 0 To w_SelectionRowList.Count - 1 For j As Integer = 0 To m_DataGridView.Columns.Count - 1 m_DataGridView.Rows(w_Row2 - i).Cells(j).Value = w_SelectionRowList(i).Cells(j).Value Next Next m_DataGridView.CurrentCell = m_DataGridView.Rows(w_Row1).Cells(0) For i As Integer = w_Row1 To w_Row2 m_DataGridView.Rows(i).Selected = True Next End Sub End Class frmCsvFile.Designer.vb Global.Microsoft.VisualBasic.CompilerServices.DesignerGenerated() _ Partial Class frmCsvFile Inherits System.Windows.Forms.Form フォームがコンポーネントの一覧をクリーンアップするために dispose をオーバーライドします。 System.Diagnostics.DebuggerNonUserCode() _ Protected Overrides Sub Dispose(ByVal disposing As Boolean) Try If disposing AndAlso components IsNot Nothing Then components.Dispose() End If Finally MyBase.Dispose(disposing) End Try End Sub Windows フォーム デザイナーで必要です。 Private components As System.ComponentModel.IContainer メモ 以下のプロシージャは Windows フォーム デザイナーで必要です。 Windows フォーム デザイナーを使用して変更できます。 コード エディターを使って変更しないでください。 System.Diagnostics.DebuggerStepThrough() _ Private Sub InitializeComponent() Me.components = New System.ComponentModel.Container() Me.Label1 = New System.Windows.Forms.Label() Me.Label2 = New System.Windows.Forms.Label() Me.TxtConnect = New System.Windows.Forms.TextBox() Me.TxtTableName = New System.Windows.Forms.TextBox() Me.Button1 = New System.Windows.Forms.Button() Me.Label3 = New System.Windows.Forms.Label() Me.TxtWorkFolder = New System.Windows.Forms.TextBox() Me.DataGridView1 = New System.Windows.Forms.DataGridView() Me.Column1 = New System.Windows.Forms.DataGridViewTextBoxColumn() Me.Column2 = New System.Windows.Forms.DataGridViewTextBoxColumn() Me.Column3 = New System.Windows.Forms.DataGridViewTextBoxColumn() Me.ContextMenuStrip1 = New System.Windows.Forms.ContextMenuStrip(Me.components) Me.TmiOpen = New System.Windows.Forms.ToolStripMenuItem() Me.TmiAdd = New System.Windows.Forms.ToolStripMenuItem() Me.Label4 = New System.Windows.Forms.Label() Me.Label5 = New System.Windows.Forms.Label() Me.Label6 = New System.Windows.Forms.Label() Me.TxtCsvFile = New System.Windows.Forms.TextBox() Me.TxtSqlFile = New System.Windows.Forms.TextBox() Me.TxtBatFile = New System.Windows.Forms.TextBox() Me.Button2 = New System.Windows.Forms.Button() Me.Button3 = New System.Windows.Forms.Button() Me.ChkDelWorkFile = New System.Windows.Forms.CheckBox() Me.DataGridView2 = New System.Windows.Forms.DataGridView() Me.DataGridViewTextBoxColumn1 = New System.Windows.Forms.DataGridViewTextBoxColumn() Me.DataGridViewTextBoxColumn3 = New System.Windows.Forms.DataGridViewTextBoxColumn() Me.ContextMenuStrip2 = New System.Windows.Forms.ContextMenuStrip(Me.components) Me.TmiTop = New System.Windows.Forms.ToolStripMenuItem() Me.TmiUp = New System.Windows.Forms.ToolStripMenuItem() Me.TmiDown = New System.Windows.Forms.ToolStripMenuItem() Me.TmiBottom = New System.Windows.Forms.ToolStripMenuItem() Me.SplitContainer1 = New System.Windows.Forms.SplitContainer() CType(Me.DataGridView1, System.ComponentModel.ISupportInitialize).BeginInit() Me.ContextMenuStrip1.SuspendLayout() CType(Me.DataGridView2, System.ComponentModel.ISupportInitialize).BeginInit() Me.ContextMenuStrip2.SuspendLayout() CType(Me.SplitContainer1, System.ComponentModel.ISupportInitialize).BeginInit() Me.SplitContainer1.Panel1.SuspendLayout() Me.SplitContainer1.Panel2.SuspendLayout() Me.SplitContainer1.SuspendLayout() Me.SuspendLayout() Label1 Me.Label1.AutoSize = True Me.Label1.Location = New System.Drawing.Point(12, 9) Me.Label1.Name = "Label1" Me.Label1.Size = New System.Drawing.Size(47, 12) Me.Label1.TabIndex = 0 Me.Label1.Text = "Connect" Label2 Me.Label2.AutoSize = True Me.Label2.Location = New System.Drawing.Point(12, 35) Me.Label2.Name = "Label2" Me.Label2.Size = New System.Drawing.Size(62, 12) Me.Label2.TabIndex = 1 Me.Label2.Text = "TableName" TxtConnect Me.TxtConnect.Location = New System.Drawing.Point(81, 6) Me.TxtConnect.Name = "TxtConnect" Me.TxtConnect.Size = New System.Drawing.Size(100, 19) Me.TxtConnect.TabIndex = 2 TxtTableName Me.TxtTableName.Location = New System.Drawing.Point(81, 31) Me.TxtTableName.Name = "TxtTableName" Me.TxtTableName.Size = New System.Drawing.Size(100, 19) Me.TxtTableName.TabIndex = 3 Button1 Me.Button1.Location = New System.Drawing.Point(435, 2) Me.Button1.Name = "Button1" Me.Button1.Size = New System.Drawing.Size(75, 23) Me.Button1.TabIndex = 4 Me.Button1.Text = "csv作成" Me.Button1.UseVisualStyleBackColor = True Label3 Me.Label3.AutoSize = True Me.Label3.Location = New System.Drawing.Point(12, 59) Me.Label3.Name = "Label3" Me.Label3.Size = New System.Drawing.Size(62, 12) Me.Label3.TabIndex = 5 Me.Label3.Text = "WorkFolder" TxtWorkFolder Me.TxtWorkFolder.Location = New System.Drawing.Point(81, 56) Me.TxtWorkFolder.Name = "TxtWorkFolder" Me.TxtWorkFolder.Size = New System.Drawing.Size(100, 19) Me.TxtWorkFolder.TabIndex = 6 Me.TxtWorkFolder.Text = "C \Temp\sql" DataGridView1 Me.DataGridView1.AllowUserToAddRows = False Me.DataGridView1.AllowUserToDeleteRows = False Me.DataGridView1.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize Me.DataGridView1.Columns.AddRange(New System.Windows.Forms.DataGridViewColumn() {Me.Column1, Me.Column2, Me.Column3}) Me.DataGridView1.ContextMenuStrip = Me.ContextMenuStrip1 Me.DataGridView1.Dock = System.Windows.Forms.DockStyle.Fill Me.DataGridView1.Location = New System.Drawing.Point(0, 0) Me.DataGridView1.Name = "DataGridView1" Me.DataGridView1.ReadOnly = True Me.DataGridView1.RowTemplate.Height = 21 Me.DataGridView1.Size = New System.Drawing.Size(434, 383) Me.DataGridView1.TabIndex = 7 Column1 Me.Column1.HeaderText = "名前" Me.Column1.Name = "Column1" Me.Column1.ReadOnly = True Column2 Me.Column2.HeaderText = "NULL?" Me.Column2.Name = "Column2" Me.Column2.ReadOnly = True Column3 Me.Column3.HeaderText = "型" Me.Column3.Name = "Column3" Me.Column3.ReadOnly = True ContextMenuStrip1 Me.ContextMenuStrip1.Items.AddRange(New System.Windows.Forms.ToolStripItem() {Me.TmiOpen, Me.TmiAdd}) Me.ContextMenuStrip1.Name = "ContextMenuStrip1" Me.ContextMenuStrip1.Size = New System.Drawing.Size(154, 48) TmiOpen Me.TmiOpen.Name = "TmiOpen" Me.TmiOpen.Size = New System.Drawing.Size(153, 22) Me.TmiOpen.Text = "tabファイルを開く" TmiAdd Me.TmiAdd.Name = "TmiAdd" Me.TmiAdd.Size = New System.Drawing.Size(153, 22) Me.TmiAdd.Text = "列追加" Label4 Me.Label4.AutoSize = True Me.Label4.Location = New System.Drawing.Point(234, 9) Me.Label4.Name = "Label4" Me.Label4.Size = New System.Drawing.Size(42, 12) Me.Label4.TabIndex = 8 Me.Label4.Text = "csvFile" Label5 Me.Label5.AutoSize = True Me.Label5.Location = New System.Drawing.Point(234, 35) Me.Label5.Name = "Label5" Me.Label5.Size = New System.Drawing.Size(39, 12) Me.Label5.TabIndex = 9 Me.Label5.Text = "sqlFile" Label6 Me.Label6.AutoSize = True Me.Label6.Location = New System.Drawing.Point(234, 59) Me.Label6.Name = "Label6" Me.Label6.Size = New System.Drawing.Size(40, 12) Me.Label6.TabIndex = 10 Me.Label6.Text = "batFile" TxtCsvFile Me.TxtCsvFile.Location = New System.Drawing.Point(280, 6) Me.TxtCsvFile.Name = "TxtCsvFile" Me.TxtCsvFile.Size = New System.Drawing.Size(100, 19) Me.TxtCsvFile.TabIndex = 11 TxtSqlFile Me.TxtSqlFile.Location = New System.Drawing.Point(280, 31) Me.TxtSqlFile.Name = "TxtSqlFile" Me.TxtSqlFile.Size = New System.Drawing.Size(100, 19) Me.TxtSqlFile.TabIndex = 12 Me.TxtSqlFile.Text = "csv.sql" TxtBatFile Me.TxtBatFile.Location = New System.Drawing.Point(280, 56) Me.TxtBatFile.Name = "TxtBatFile" Me.TxtBatFile.Size = New System.Drawing.Size(100, 19) Me.TxtBatFile.TabIndex = 13 Me.TxtBatFile.Text = "csv.bat" Button2 Me.Button2.Location = New System.Drawing.Point(435, 27) Me.Button2.Name = "Button2" Me.Button2.Size = New System.Drawing.Size(75, 23) Me.Button2.TabIndex = 14 Me.Button2.Text = "csv開く" Me.Button2.UseVisualStyleBackColor = True Button3 Me.Button3.Location = New System.Drawing.Point(435, 52) Me.Button3.Name = "Button3" Me.Button3.Size = New System.Drawing.Size(75, 23) Me.Button3.TabIndex = 15 Me.Button3.Text = "フォルダ開く" Me.Button3.UseVisualStyleBackColor = True ChkDelWorkFile Me.ChkDelWorkFile.AutoSize = True Me.ChkDelWorkFile.Checked = True Me.ChkDelWorkFile.CheckState = System.Windows.Forms.CheckState.Checked Me.ChkDelWorkFile.Location = New System.Drawing.Point(551, 5) Me.ChkDelWorkFile.Name = "ChkDelWorkFile" Me.ChkDelWorkFile.Size = New System.Drawing.Size(85, 16) Me.ChkDelWorkFile.TabIndex = 16 Me.ChkDelWorkFile.Text = "DelWorkFile" Me.ChkDelWorkFile.UseVisualStyleBackColor = True DataGridView2 Me.DataGridView2.AllowUserToAddRows = False Me.DataGridView2.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize Me.DataGridView2.Columns.AddRange(New System.Windows.Forms.DataGridViewColumn() {Me.DataGridViewTextBoxColumn1, Me.DataGridViewTextBoxColumn3}) Me.DataGridView2.ContextMenuStrip = Me.ContextMenuStrip2 Me.DataGridView2.Dock = System.Windows.Forms.DockStyle.Fill Me.DataGridView2.Location = New System.Drawing.Point(0, 0) Me.DataGridView2.Name = "DataGridView2" Me.DataGridView2.ReadOnly = True Me.DataGridView2.RowTemplate.Height = 21 Me.DataGridView2.Size = New System.Drawing.Size(302, 383) Me.DataGridView2.TabIndex = 17 DataGridViewTextBoxColumn1 Me.DataGridViewTextBoxColumn1.HeaderText = "名前" Me.DataGridViewTextBoxColumn1.Name = "DataGridViewTextBoxColumn1" Me.DataGridViewTextBoxColumn1.ReadOnly = True DataGridViewTextBoxColumn3 Me.DataGridViewTextBoxColumn3.HeaderText = "型" Me.DataGridViewTextBoxColumn3.Name = "DataGridViewTextBoxColumn3" Me.DataGridViewTextBoxColumn3.ReadOnly = True ContextMenuStrip2 Me.ContextMenuStrip2.Items.AddRange(New System.Windows.Forms.ToolStripItem() {Me.TmiTop, Me.TmiUp, Me.TmiDown, Me.TmiBottom}) Me.ContextMenuStrip2.Name = "ContextMenuStrip2" Me.ContextMenuStrip2.Size = New System.Drawing.Size(99, 92) TmiTop Me.TmiTop.Name = "TmiTop" Me.TmiTop.Size = New System.Drawing.Size(98, 22) Me.TmiTop.Text = "最上" TmiUp Me.TmiUp.Name = "TmiUp" Me.TmiUp.Size = New System.Drawing.Size(98, 22) Me.TmiUp.Text = "上へ" TmiDown Me.TmiDown.Name = "TmiDown" Me.TmiDown.Size = New System.Drawing.Size(98, 22) Me.TmiDown.Text = "下へ" TmiBottom Me.TmiBottom.Name = "TmiBottom" Me.TmiBottom.Size = New System.Drawing.Size(98, 22) Me.TmiBottom.Text = "最下" SplitContainer1 Me.SplitContainer1.Anchor = CType((((System.Windows.Forms.AnchorStyles.Top Or System.Windows.Forms.AnchorStyles.Bottom) _ Or System.Windows.Forms.AnchorStyles.Left) _ Or System.Windows.Forms.AnchorStyles.Right), System.Windows.Forms.AnchorStyles) Me.SplitContainer1.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle Me.SplitContainer1.Location = New System.Drawing.Point(14, 81) Me.SplitContainer1.Name = "SplitContainer1" SplitContainer1.Panel1 Me.SplitContainer1.Panel1.Controls.Add(Me.DataGridView1) SplitContainer1.Panel2 Me.SplitContainer1.Panel2.Controls.Add(Me.DataGridView2) Me.SplitContainer1.Size = New System.Drawing.Size(744, 385) Me.SplitContainer1.SplitterDistance = 436 Me.SplitContainer1.TabIndex = 18 frmCsvFile Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 12.0!) Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font Me.ClientSize = New System.Drawing.Size(770, 478) Me.Controls.Add(Me.SplitContainer1) Me.Controls.Add(Me.ChkDelWorkFile) Me.Controls.Add(Me.Button3) Me.Controls.Add(Me.Button2) Me.Controls.Add(Me.TxtBatFile) Me.Controls.Add(Me.TxtSqlFile) Me.Controls.Add(Me.TxtCsvFile) Me.Controls.Add(Me.Label6) Me.Controls.Add(Me.Label5) Me.Controls.Add(Me.Label4) Me.Controls.Add(Me.TxtWorkFolder) Me.Controls.Add(Me.Label3) Me.Controls.Add(Me.Button1) Me.Controls.Add(Me.TxtTableName) Me.Controls.Add(Me.TxtConnect) Me.Controls.Add(Me.Label2) Me.Controls.Add(Me.Label1) Me.Name = "frmCsvFile" Me.Text = "tabファイルを基にcsvファイルを作成" CType(Me.DataGridView1, System.ComponentModel.ISupportInitialize).EndInit() Me.ContextMenuStrip1.ResumeLayout(False) CType(Me.DataGridView2, System.ComponentModel.ISupportInitialize).EndInit() Me.ContextMenuStrip2.ResumeLayout(False) Me.SplitContainer1.Panel1.ResumeLayout(False) Me.SplitContainer1.Panel2.ResumeLayout(False) CType(Me.SplitContainer1, System.ComponentModel.ISupportInitialize).EndInit() Me.SplitContainer1.ResumeLayout(False) Me.ResumeLayout(False) Me.PerformLayout() End Sub Friend WithEvents Label1 As System.Windows.Forms.Label Friend WithEvents Label2 As System.Windows.Forms.Label Friend WithEvents TxtConnect As System.Windows.Forms.TextBox Friend WithEvents TxtTableName As System.Windows.Forms.TextBox Friend WithEvents Button1 As System.Windows.Forms.Button Friend WithEvents Label3 As System.Windows.Forms.Label Friend WithEvents TxtWorkFolder As System.Windows.Forms.TextBox Friend WithEvents DataGridView1 As System.Windows.Forms.DataGridView Friend WithEvents Column1 As System.Windows.Forms.DataGridViewTextBoxColumn Friend WithEvents Column2 As System.Windows.Forms.DataGridViewTextBoxColumn Friend WithEvents Column3 As System.Windows.Forms.DataGridViewTextBoxColumn Friend WithEvents Label4 As System.Windows.Forms.Label Friend WithEvents Label5 As System.Windows.Forms.Label Friend WithEvents Label6 As System.Windows.Forms.Label Friend WithEvents TxtCsvFile As System.Windows.Forms.TextBox Friend WithEvents TxtSqlFile As System.Windows.Forms.TextBox Friend WithEvents TxtBatFile As System.Windows.Forms.TextBox Friend WithEvents Button2 As System.Windows.Forms.Button Friend WithEvents Button3 As System.Windows.Forms.Button Friend WithEvents ChkDelWorkFile As System.Windows.Forms.CheckBox Friend WithEvents DataGridView2 As System.Windows.Forms.DataGridView Friend WithEvents DataGridViewTextBoxColumn1 As System.Windows.Forms.DataGridViewTextBoxColumn Friend WithEvents DataGridViewTextBoxColumn3 As System.Windows.Forms.DataGridViewTextBoxColumn Friend WithEvents ContextMenuStrip1 As System.Windows.Forms.ContextMenuStrip Friend WithEvents TmiOpen As System.Windows.Forms.ToolStripMenuItem Friend WithEvents TmiAdd As System.Windows.Forms.ToolStripMenuItem Friend WithEvents ContextMenuStrip2 As System.Windows.Forms.ContextMenuStrip Friend WithEvents TmiTop As System.Windows.Forms.ToolStripMenuItem Friend WithEvents TmiUp As System.Windows.Forms.ToolStripMenuItem Friend WithEvents TmiDown As System.Windows.Forms.ToolStripMenuItem Friend WithEvents TmiBottom As System.Windows.Forms.ToolStripMenuItem Friend WithEvents SplitContainer1 As System.Windows.Forms.SplitContainer End Class frmCsvFile.vb Imports System.Text.RegularExpressions Public Class frmCsvFile Private Enum me_Col1 c0Name c1Null c2Type End Enum Private Enum me_Col2 c0Name c1Type End Enum Private m_SelectionRowsMove As New clsSelectionRowsMove(Me.DataGridView2) Private Sub Form1_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load Me.TxtConnect.Text = pf_GetIni("", "CSV", "Connect", "ユーザ名/パスワード@ネットサービス名") Me.TxtTableName.Text = pf_GetIni("", "CSV", "TableName", "DUAL") Me.TxtWorkFolder.Text = pf_GetIni("", "CSV", "WorkFolder", "C \Temp\sql") Me.TxtCsvFile.Text = pf_GetIni("", "CSV", "csvFile", "csv.csv") Me.TxtSqlFile.Text = pf_GetIni("", "CSV", "sqlFile", "csv.sql") Me.TxtBatFile.Text = pf_GetIni("", "CSV", "batFile", "csv.bat") Me.TmiTop.Enabled = False Me.TmiUp.Enabled = False Me.TmiDown.Enabled = False Me.TmiBottom.Enabled = False End Sub Private Sub Form1_FormClosed(sender As Object, e As System.Windows.Forms.FormClosedEventArgs) Handles Me.FormClosed Call ps_PutIni("", "CSV", "Connect", Me.TxtConnect.Text) Call ps_PutIni("", "CSV", "TableName", Me.TxtTableName.Text) Call ps_PutIni("", "CSV", "WorkFolder", Me.TxtWorkFolder.Text) Call ps_PutIni("", "CSV", "csvFile", Me.TxtCsvFile.Text) Call ps_PutIni("", "CSV", "sqlFile", Me.TxtSqlFile.Text) Call ps_PutIni("", "CSV", "batFile", Me.TxtBatFile.Text) If Me.ChkDelWorkFile.Checked Then Dim w_SqlFile As String = String.Format("{0}\{1}", Me.TxtWorkFolder.Text, Me.TxtSqlFile.Text) Dim w_BatFile As String = String.Format("{0}\{1}", Me.TxtWorkFolder.Text, Me.TxtBatFile.Text) Call ms_DelFile(w_BatFile) Call ms_DelFile(w_SqlFile) End If End Sub Private Sub DataGridView1_CellPainting(sender As Object, e As System.Windows.Forms.DataGridViewCellPaintingEventArgs) Handles DataGridView1.CellPainting If e.ColumnIndex 0 AndAlso e.RowIndex = 0 Then Call e.Paint(e.ClipBounds, DataGridViewPaintParts.All) Dim rect As Rectangle = e.CellBounds Call rect.Inflate(-2, -2) Call TextRenderer.DrawText(e.Graphics, (e.RowIndex + 1).ToString(), e.CellStyle.Font, rect, e.CellStyle.ForeColor, TextFormatFlags.Right Or TextFormatFlags.VerticalCenter) e.Handled = True End If End Sub Private Sub DataGridView2_CellPainting(sender As Object, e As System.Windows.Forms.DataGridViewCellPaintingEventArgs) Handles DataGridView2.CellPainting If e.ColumnIndex 0 AndAlso e.RowIndex = 0 Then Call e.Paint(e.ClipBounds, DataGridViewPaintParts.All) Dim rect As Rectangle = e.CellBounds Call rect.Inflate(-2, -2) Call TextRenderer.DrawText(e.Graphics, (e.RowIndex + 1).ToString(), e.CellStyle.Font, rect, e.CellStyle.ForeColor, TextFormatFlags.Right Or TextFormatFlags.VerticalCenter) e.Handled = True End If End Sub Private Sub DataGridView2_SelectionChanged(sender As Object, e As System.EventArgs) Handles DataGridView2.SelectionChanged m_SelectionRowsMove = New clsSelectionRowsMove(Me.DataGridView2) If Me.TmiUp.Enabled m_SelectionRowsMove.MoveUpEnabled Then Me.TmiUp.Enabled = m_SelectionRowsMove.MoveUpEnabled Me.TmiTop.Enabled = m_SelectionRowsMove.MoveUpEnabled End If If Me.TmiDown.Enabled m_SelectionRowsMove.MoveDownEnabled Then Me.TmiDown.Enabled = m_SelectionRowsMove.MoveDownEnabled Me.TmiBottom.Enabled = m_SelectionRowsMove.MoveDownEnabled End If End Sub Private Sub TsbTop_Click(sender As System.Object, e As System.EventArgs) Handles TmiTop.Click Call m_SelectionRowsMove.SelectionRowsMove(clsSelectionRowsMove.MoveType.Top) End Sub Private Sub TsbUp_Click(sender As System.Object, e As System.EventArgs) Handles TmiUp.Click Call m_SelectionRowsMove.SelectionRowsMove(clsSelectionRowsMove.MoveType.Up) End Sub Private Sub TsbDown_Click(sender As System.Object, e As System.EventArgs) Handles TmiDown.Click Call m_SelectionRowsMove.SelectionRowsMove(clsSelectionRowsMove.MoveType.Down) End Sub Private Sub TsbBottom_Click(sender As System.Object, e As System.EventArgs) Handles TmiBottom.Click Call m_SelectionRowsMove.SelectionRowsMove(clsSelectionRowsMove.MoveType.Bottom) End Sub Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click If Me.DataGridView1.Rows.Count = 0 Then MsgBox("tabファイルを開いてください。", MsgBoxStyle.SystemModal) Return End If If Me.DataGridView2.Rows.Count = 0 Then MsgBox("列追加してください。", MsgBoxStyle.SystemModal) Return End If Me.TxtCsvFile.Text = String.Format("{0}.csv", Me.TxtTableName.Text) Dim w_CsvFile As String = String.Format("{0}\{1}.csv", Me.TxtWorkFolder.Text, Me.TxtTableName.Text) Dim w_TableName As String = Me.TxtTableName.Text.ToUpper Dim w_CsvSql As String = mf_GetCsvSql(w_CsvFile, w_TableName, Me.TxtConnect.Text) Dim w_SqlFile As String = String.Format("{0}\{1}", Me.TxtWorkFolder.Text, Me.TxtSqlFile.Text) Call ms_StreamWriter(w_SqlFile, w_CsvSql) Dim w_BatCommand As String = String.Format("SQLPLUS {0} @{1}", Me.TxtConnect.Text, w_SqlFile) Dim w_BatFile As String = String.Format("{0}\{1}", Me.TxtWorkFolder.Text, Me.TxtBatFile.Text) Call ms_StreamWriter(w_BatFile, w_BatCommand) Call ms_StartProcessWaitForExit(w_BatFile) Select Case MsgBox("csvファイルを開きますか。", MsgBoxStyle.YesNo Or MsgBoxStyle.DefaultButton2 Or MsgBoxStyle.SystemModal, "確認") Case MsgBoxResult.Yes Call ms_StartProcess(w_CsvFile) Case Else End Select End Sub Private Sub Button2_Click(sender As System.Object, e As System.EventArgs) Handles Button2.Click Me.TxtCsvFile.Text = String.Format("{0}.csv", Me.TxtTableName.Text) Dim w_CsvFile As String = String.Format("{0}\{1}.csv", Me.TxtWorkFolder.Text, Me.TxtTableName.Text) Call ms_StartProcess(w_CsvFile) End Sub Private Sub Button3_Click(sender As System.Object, e As System.EventArgs) Handles Button3.Click Dim w_WorkFolder As String = Me.TxtWorkFolder.Text Call ms_StartProcess(w_WorkFolder) End Sub Private Sub TmiOpen_Click(sender As System.Object, e As System.EventArgs) Handles TmiOpen.Click Dim w_tabFile As String = mf_FileOpenDialog() If w_tabFile = "" Then Return End If Me.TxtTableName.Text = System.IO.Path.GetFileNameWithoutExtension(w_tabFile) Me.TxtCsvFile.Text = String.Format("{0}.csv", Me.TxtTableName.Text) Dim w_FileText As String = mf_GetFileText(w_tabFile) Dim w_DescList As List(Of clsDesc) = mf_FileTextToDescList(w_FileText) Me.DataGridView1.Rows.Clear() If w_DescList.Count 0 Then Me.DataGridView1.Rows.Add(w_DescList.Count) For i As Integer = 0 To w_DescList.Count - 1 Me.DataGridView1.Rows(i).Cells(me_Col1.c0Name).Value = w_DescList(i).c0Name Me.DataGridView1.Rows(i).Cells(me_Col1.c1Null).Value = w_DescList(i).c1Null Me.DataGridView1.Rows(i).Cells(me_Col1.c2Type).Value = w_DescList(i).c2Type Next Me.DataGridView1.AutoResizeColumns(DataGridViewAutoSizeColumnsMode.AllCells) End If End Sub Private Sub TmiAdd_Click(sender As System.Object, e As System.EventArgs) Handles TmiAdd.Click Dim w_ColumnList As List(Of clsDesc) = mf_GetSelectionColumns() Call ms_AddQuery(w_ColumnList) End Sub Private Function mf_GetCsvSql(wp_TxtFile As String, wp_TableName As String, wp_Connect As String) As String Dim sb As New sb() sb.Add("connect {0}", wp_Connect) sb.Add("set echo off") sb.Add("set heading off") sb.Add("set pagesize 0") sb.Add("set feedback off") sb.Add("set linesize 32767") sb.Add("set trimspool on") sb.Add("spool {0}", wp_TxtFile) sb.Add("SELECT ""列番"" ") For i As Integer = 0 To Me.DataGridView2.Rows.Count - 1 sb.Add(" || ,""{0}"" ", i + 1) Next sb.Add(" AS 列番") sb.Add("FROM DUAL;") sb.Add("SELECT ""列型"" ") For i As Integer = 0 To Me.DataGridView2.Rows.Count - 1 sb.Add(" || ,""{0}"" ", mf_ObjectToString(Me.DataGridView2.Rows(i).Cells(me_Col2.c1Type).Value)) Next sb.Add(" AS 列型") sb.Add("FROM DUAL;") sb.Add("SELECT ""列名"" ") For i As Integer = 0 To Me.DataGridView2.Rows.Count - 1 sb.Add(" || ,""{0}"" ", mf_ObjectToString(Me.DataGridView2.Rows(i).Cells(me_Col2.c0Name).Value)) Next sb.Add(" AS 列名") sb.Add("FROM DUAL;") sb.Add("SELECT ""明細"" ") For i As Integer = 0 To Me.DataGridView2.Rows.Count - 1 Dim w_c0Name As String = mf_ObjectToString(Me.DataGridView2.Rows(i).Cells(me_Col2.c0Name).Value) Dim w_c1Type As String = mf_ObjectToString(Me.DataGridView2.Rows(i).Cells(me_Col2.c1Type).Value) Select Case True Case w_c1Type Like "NUMBER*" w_c0Name = String.Format(" || ,"" || TO_CHAR({0}) || "" ", w_c0Name) Case w_c1Type Like "DATE*" w_c0Name = String.Format(" || ,"" || TO_CHAR({0}, YYYY/MM/DD HH24 MI SS ) || "" ", w_c0Name) Case Else w_c0Name = String.Format(" || ,"" || {0} || "" ", w_c0Name) End Select sb.Add("{0}", w_c0Name) Next sb.Add(" AS 明細") sb.Add("FROM {0};", wp_TableName) sb.Add("spool off") sb.Add("set linesize 80") sb.Add("clear") sb.Add("exit") Return sb.ToString End Function Private Sub ms_StreamWriter(wp_File As String, wp_Text As String) Dim enc As System.Text.Encoding = System.Text.Encoding.GetEncoding("shift_jis") Dim sw As New System.IO.StreamWriter(wp_File, False, enc) sw.Write(wp_Text) sw.Close() End Sub Private Sub ms_StartProcessWaitForExit(wp_BatFile As String) Dim p As System.Diagnostics.Process = System.Diagnostics.Process.Start(wp_BatFile) p.WaitForExit() p.Close() p.Dispose() End Sub Private Sub ms_StartProcess(wp_File As String) Dim p As System.Diagnostics.Process = System.Diagnostics.Process.Start(wp_File) End Sub Private Function mf_GetFileText(wp_TxtFile As String) As String Dim ret As String = "" Dim enc As System.Text.Encoding = System.Text.Encoding.GetEncoding("shift_jis") Dim sr As New System.IO.StreamReader(wp_TxtFile, enc) ret = sr.ReadToEnd() sr.Close() Return ret End Function Private Function mf_FileTextToDescList(wp_FileText As String) As List(Of clsDesc) Dim ret As New List(Of clsDesc) Dim a1 As String() = Split(wp_FileText, vbCrLf, -1, CompareMethod.Text) For i As Integer = 0 To a1.Count - 1 Dim a2 As String() = Split(a1(i), vbTab, -1, CompareMethod.Text) Select Case a2.Count Case 3 Dim w_Desc As New clsDesc() w_Desc.c0Name = a2(0) w_Desc.c1Null = a2(1) w_Desc.c2Type = a2(2) ret.Add(w_Desc) Case Else End Select Next Return ret End Function Private Function mf_ObjectToString(wp_Object As Object) As String Dim ret As String = "" If Not wp_Object Is Nothing Then ret = wp_Object.ToString End If Return ret End Function Private Sub ms_DelFile(wp_File As String) System.IO.File.Delete(wp_File) End Sub Private Function mf_FileOpenDialog() As String Dim ret As String = "" Dim d As New OpenFileDialog() d.FileName = "" d.InitialDirectory = Me.TxtWorkFolder.Text d.Filter = "tabファイル(*.tab)|*.tab|すべてのファイル(*.*)|*.*" d.FilterIndex = 1 d.Title = "開くファイルを選択してください" d.RestoreDirectory = True If d.ShowDialog() = DialogResult.OK Then ret = d.FileName End If Return ret End Function Private Function mf_GetSelectionColumns() As List(Of clsDesc) Dim ret As New List(Of clsDesc) For Each r As DataGridViewRow In Me.DataGridView1.SelectedRows Dim w As New clsDesc() w.c0Name = mf_ObjectToString(r.Cells(me_Col1.c0Name).Value) w.c1Null = mf_ObjectToString(r.Cells(me_Col1.c1Null).Value) w.c2Type = mf_ObjectToString(r.Cells(me_Col1.c2Type).Value) ret.Add(w) r.Selected = False Next Return ret End Function Private Sub ms_AddQuery(wp_ColumnList As List(Of clsDesc)) If wp_ColumnList.Count = 0 Then Return End If For Each r As DataGridViewRow In Me.DataGridView2.Rows If r.Selected Then r.Selected = False End If Next Me.DataGridView2.Rows.Add(wp_ColumnList.Count) For i As Integer = 0 To wp_ColumnList.Count - 1 Dim w_Row As Integer = Me.DataGridView2.Rows.Count - i - 1 Me.DataGridView2.Rows(w_Row).Cells(me_Col2.c0Name).Value = wp_ColumnList(i).c0Name Me.DataGridView2.Rows(w_Row).Cells(me_Col2.c1Type).Value = wp_ColumnList(i).c2Type Me.DataGridView2.Rows(w_Row).Selected = True Next Me.DataGridView2.AutoResizeColumns(DataGridViewAutoSizeColumnsMode.AllCells) Me.DataGridView2.Focus() End Sub End Class mdlInit.vb Imports System.Runtime.InteropServices Module mdlInit DllImport("KERNEL32.DLL", CharSet =CharSet.Auto) _ Public Function GetPrivateProfileString( _ ByVal lpAppName As String, _ ByVal lpKeyName As String, _ ByVal lpDefault As String, _ ByVal lpReturnedString As System.Text.StringBuilder, _ ByVal nSize As Integer, _ ByVal lpFileName As String) As Integer End Function DllImport("KERNEL32.DLL") _ Public Function WritePrivateProfileString( _ ByVal lpAppName As String, _ ByVal lpKeyName As String, _ ByVal lpString As String, _ ByVal lpFileName As String) As Integer End Function Public Function pf_GetIni(ByVal wp_path As String, ByVal wp_section As String, ByVal wp_key As String, ByVal wp_Default As String) As String Dim ret As String = wp_Default Dim sb As New System.Text.StringBuilder sb.Capacity = 256 Dim i As Integer = GetPrivateProfileString(wp_section, wp_key, wp_Default, sb, sb.Capacity, mf_path(wp_path)) ret = sb.ToString Return ret End Function Public Sub ps_PutIni(ByVal wp_path As String, ByVal wp_section As String, ByVal wp_key As String, ByVal wp_value As String) Dim i As Integer = WritePrivateProfileString(wp_section, wp_key, wp_value, mf_path(wp_path)) End Sub Private Function mf_path(ByVal wp_path As String) As String Dim ret As String = wp_path If ret = "" Then Dim w_path As String = Application.StartupPath If w_path.EndsWith("\") = False Then w_path = w_path "\" End If ret = String.Format("{0}{1}.ini", w_path, My.Application.Info.AssemblyName) End If Return ret End Function End Module sb.vb Public Class sb Private m_sb As System.Text.StringBuilder Public Sub New() m_sb = New System.Text.StringBuilder() End Sub Public Overrides Function ToString() As String Return m_sb.ToString() End Function Public Function Add(ByVal wp_String As String, ByVal ParamArray wp_Args() As Object) m_sb.AppendFormat(wp_String, wp_Args) m_sb.Append(ControlChars.CrLf) Return m_sb End Function Public Function ToStringRemoveLastCrLf() As String Dim ret As String = m_sb.ToString If ret.Length = vbCrLf.Length Then Dim i As Integer = ret.Length - vbCrLf.Length Dim w As String = ret.Substring(i) If w = vbCrLf Then ret = ret.Substring(0, i) End If End If Return ret End Function Public Sub cb() Clipboard.SetText(m_sb.ToString()) End Sub End Class
https://w.atwiki.jp/kylico/pages/32.html
SQL*Plus 勉強用ユーザー ユーザー :study パスワード:oracle ログをとるには ログ記録開始 SPOOL [ファイル名] ログ記録終了 SPOOL OFF SPOOL OFFした後に、一気に吐かれるようです。 バックスペースが効かない場合 設定ファイル(.cshrc とか .login)に以下を追加 stty erase ^? サイレントモードでSQL実行 実行SQLファイルにquitを記述しないと終わりません。 sqlplus -s ユーザー名/パスワード @ 実行SQLファイル 画面表示サイズの変更 これはlogin.sqlに入れておくと楽 横幅の変更 set linesize 横幅数 縦幅の変更 set pagesize 縦幅数 エディターの変更 これはlogin.sqlに入れておくと楽 set _EDITOR="vi"
https://w.atwiki.jp/mieyanman/pages/23.html
myfolder? [sqlplus_desc] clsDesc.vb Public Class clsDesc Public Property c0Name As String = "" Public Property c1Null As String = "" Public Property c2Type As String = "" End Class frmTabFile.Designer.vb Global.Microsoft.VisualBasic.CompilerServices.DesignerGenerated() _ Partial Class frmTabFile Inherits System.Windows.Forms.Form フォームがコンポーネントの一覧をクリーンアップするために dispose をオーバーライドします。 System.Diagnostics.DebuggerNonUserCode() _ Protected Overrides Sub Dispose(ByVal disposing As Boolean) Try If disposing AndAlso components IsNot Nothing Then components.Dispose() End If Finally MyBase.Dispose(disposing) End Try End Sub Windows フォーム デザイナーで必要です。 Private components As System.ComponentModel.IContainer メモ 以下のプロシージャは Windows フォーム デザイナーで必要です。 Windows フォーム デザイナーを使用して変更できます。 コード エディターを使って変更しないでください。 System.Diagnostics.DebuggerStepThrough() _ Private Sub InitializeComponent() Me.Label1 = New System.Windows.Forms.Label() Me.Label2 = New System.Windows.Forms.Label() Me.TxtConnect = New System.Windows.Forms.TextBox() Me.TxtTableName = New System.Windows.Forms.TextBox() Me.Button1 = New System.Windows.Forms.Button() Me.Label3 = New System.Windows.Forms.Label() Me.TxtWorkFolder = New System.Windows.Forms.TextBox() Me.DataGridView1 = New System.Windows.Forms.DataGridView() Me.Column1 = New System.Windows.Forms.DataGridViewTextBoxColumn() Me.Column2 = New System.Windows.Forms.DataGridViewTextBoxColumn() Me.Column3 = New System.Windows.Forms.DataGridViewTextBoxColumn() Me.Label4 = New System.Windows.Forms.Label() Me.Label5 = New System.Windows.Forms.Label() Me.Label6 = New System.Windows.Forms.Label() Me.TxtTxtFile = New System.Windows.Forms.TextBox() Me.TxtSqlFile = New System.Windows.Forms.TextBox() Me.TxtBatFile = New System.Windows.Forms.TextBox() Me.Button2 = New System.Windows.Forms.Button() Me.Button3 = New System.Windows.Forms.Button() Me.ChkDelWorkFile = New System.Windows.Forms.CheckBox() CType(Me.DataGridView1, System.ComponentModel.ISupportInitialize).BeginInit() Me.SuspendLayout() Label1 Me.Label1.AutoSize = True Me.Label1.Location = New System.Drawing.Point(12, 9) Me.Label1.Name = "Label1" Me.Label1.Size = New System.Drawing.Size(47, 12) Me.Label1.TabIndex = 0 Me.Label1.Text = "Connect" Label2 Me.Label2.AutoSize = True Me.Label2.Location = New System.Drawing.Point(12, 35) Me.Label2.Name = "Label2" Me.Label2.Size = New System.Drawing.Size(62, 12) Me.Label2.TabIndex = 1 Me.Label2.Text = "TableName" TxtConnect Me.TxtConnect.Location = New System.Drawing.Point(81, 6) Me.TxtConnect.Name = "TxtConnect" Me.TxtConnect.Size = New System.Drawing.Size(100, 19) Me.TxtConnect.TabIndex = 2 TxtTableName Me.TxtTableName.Location = New System.Drawing.Point(81, 31) Me.TxtTableName.Name = "TxtTableName" Me.TxtTableName.Size = New System.Drawing.Size(100, 19) Me.TxtTableName.TabIndex = 3 Button1 Me.Button1.Location = New System.Drawing.Point(435, 2) Me.Button1.Name = "Button1" Me.Button1.Size = New System.Drawing.Size(75, 23) Me.Button1.TabIndex = 4 Me.Button1.Text = "tab作成" Me.Button1.UseVisualStyleBackColor = True Label3 Me.Label3.AutoSize = True Me.Label3.Location = New System.Drawing.Point(12, 59) Me.Label3.Name = "Label3" Me.Label3.Size = New System.Drawing.Size(62, 12) Me.Label3.TabIndex = 5 Me.Label3.Text = "WorkFolder" TxtWorkFolder Me.TxtWorkFolder.Location = New System.Drawing.Point(81, 56) Me.TxtWorkFolder.Name = "TxtWorkFolder" Me.TxtWorkFolder.Size = New System.Drawing.Size(100, 19) Me.TxtWorkFolder.TabIndex = 6 Me.TxtWorkFolder.Text = "C \Temp" DataGridView1 Me.DataGridView1.AllowUserToAddRows = False Me.DataGridView1.AllowUserToDeleteRows = False Me.DataGridView1.Anchor = CType((((System.Windows.Forms.AnchorStyles.Top Or System.Windows.Forms.AnchorStyles.Bottom) _ Or System.Windows.Forms.AnchorStyles.Left) _ Or System.Windows.Forms.AnchorStyles.Right), System.Windows.Forms.AnchorStyles) Me.DataGridView1.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize Me.DataGridView1.Columns.AddRange(New System.Windows.Forms.DataGridViewColumn() {Me.Column1, Me.Column2, Me.Column3}) Me.DataGridView1.Location = New System.Drawing.Point(14, 81) Me.DataGridView1.Name = "DataGridView1" Me.DataGridView1.ReadOnly = True Me.DataGridView1.RowTemplate.Height = 21 Me.DataGridView1.Size = New System.Drawing.Size(744, 385) Me.DataGridView1.TabIndex = 7 Column1 Me.Column1.HeaderText = "名前" Me.Column1.Name = "Column1" Me.Column1.ReadOnly = True Column2 Me.Column2.HeaderText = "NULL?" Me.Column2.Name = "Column2" Me.Column2.ReadOnly = True Column3 Me.Column3.HeaderText = "型" Me.Column3.Name = "Column3" Me.Column3.ReadOnly = True Label4 Me.Label4.AutoSize = True Me.Label4.Location = New System.Drawing.Point(234, 9) Me.Label4.Name = "Label4" Me.Label4.Size = New System.Drawing.Size(38, 12) Me.Label4.TabIndex = 8 Me.Label4.Text = "txtFile" Label5 Me.Label5.AutoSize = True Me.Label5.Location = New System.Drawing.Point(234, 35) Me.Label5.Name = "Label5" Me.Label5.Size = New System.Drawing.Size(39, 12) Me.Label5.TabIndex = 9 Me.Label5.Text = "sqlFile" Label6 Me.Label6.AutoSize = True Me.Label6.Location = New System.Drawing.Point(234, 59) Me.Label6.Name = "Label6" Me.Label6.Size = New System.Drawing.Size(40, 12) Me.Label6.TabIndex = 10 Me.Label6.Text = "batFile" TxtTxtFile Me.TxtTxtFile.Location = New System.Drawing.Point(280, 6) Me.TxtTxtFile.Name = "TxtTxtFile" Me.TxtTxtFile.Size = New System.Drawing.Size(100, 19) Me.TxtTxtFile.TabIndex = 11 Me.TxtTxtFile.Text = "desc.txt" TxtSqlFile Me.TxtSqlFile.Location = New System.Drawing.Point(280, 31) Me.TxtSqlFile.Name = "TxtSqlFile" Me.TxtSqlFile.Size = New System.Drawing.Size(100, 19) Me.TxtSqlFile.TabIndex = 12 Me.TxtSqlFile.Text = "desc.sql" TxtBatFile Me.TxtBatFile.Location = New System.Drawing.Point(280, 56) Me.TxtBatFile.Name = "TxtBatFile" Me.TxtBatFile.Size = New System.Drawing.Size(100, 19) Me.TxtBatFile.TabIndex = 13 Me.TxtBatFile.Text = "desc.bat" Button2 Me.Button2.Location = New System.Drawing.Point(435, 27) Me.Button2.Name = "Button2" Me.Button2.Size = New System.Drawing.Size(75, 23) Me.Button2.TabIndex = 14 Me.Button2.Text = "tab開く" Me.Button2.UseVisualStyleBackColor = True Button3 Me.Button3.Location = New System.Drawing.Point(435, 52) Me.Button3.Name = "Button3" Me.Button3.Size = New System.Drawing.Size(75, 23) Me.Button3.TabIndex = 15 Me.Button3.Text = "フォルダ開く" Me.Button3.UseVisualStyleBackColor = True ChkDelWorkFile Me.ChkDelWorkFile.AutoSize = True Me.ChkDelWorkFile.Checked = True Me.ChkDelWorkFile.CheckState = System.Windows.Forms.CheckState.Checked Me.ChkDelWorkFile.Location = New System.Drawing.Point(551, 5) Me.ChkDelWorkFile.Name = "ChkDelWorkFile" Me.ChkDelWorkFile.Size = New System.Drawing.Size(85, 16) Me.ChkDelWorkFile.TabIndex = 16 Me.ChkDelWorkFile.Text = "DelWorkFile" Me.ChkDelWorkFile.UseVisualStyleBackColor = True Form1 Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 12.0!) Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font Me.ClientSize = New System.Drawing.Size(770, 478) Me.Controls.Add(Me.ChkDelWorkFile) Me.Controls.Add(Me.Button3) Me.Controls.Add(Me.Button2) Me.Controls.Add(Me.TxtBatFile) Me.Controls.Add(Me.TxtSqlFile) Me.Controls.Add(Me.TxtTxtFile) Me.Controls.Add(Me.Label6) Me.Controls.Add(Me.Label5) Me.Controls.Add(Me.Label4) Me.Controls.Add(Me.DataGridView1) Me.Controls.Add(Me.TxtWorkFolder) Me.Controls.Add(Me.Label3) Me.Controls.Add(Me.Button1) Me.Controls.Add(Me.TxtTableName) Me.Controls.Add(Me.TxtConnect) Me.Controls.Add(Me.Label2) Me.Controls.Add(Me.Label1) Me.Name = "Form1" Me.Text = "TableNameを基にtabファイルを作成" CType(Me.DataGridView1, System.ComponentModel.ISupportInitialize).EndInit() Me.ResumeLayout(False) Me.PerformLayout() End Sub Friend WithEvents Label1 As System.Windows.Forms.Label Friend WithEvents Label2 As System.Windows.Forms.Label Friend WithEvents TxtConnect As System.Windows.Forms.TextBox Friend WithEvents TxtTableName As System.Windows.Forms.TextBox Friend WithEvents Button1 As System.Windows.Forms.Button Friend WithEvents Label3 As System.Windows.Forms.Label Friend WithEvents TxtWorkFolder As System.Windows.Forms.TextBox Friend WithEvents DataGridView1 As System.Windows.Forms.DataGridView Friend WithEvents Column1 As System.Windows.Forms.DataGridViewTextBoxColumn Friend WithEvents Column2 As System.Windows.Forms.DataGridViewTextBoxColumn Friend WithEvents Column3 As System.Windows.Forms.DataGridViewTextBoxColumn Friend WithEvents Label4 As System.Windows.Forms.Label Friend WithEvents Label5 As System.Windows.Forms.Label Friend WithEvents Label6 As System.Windows.Forms.Label Friend WithEvents TxtTxtFile As System.Windows.Forms.TextBox Friend WithEvents TxtSqlFile As System.Windows.Forms.TextBox Friend WithEvents TxtBatFile As System.Windows.Forms.TextBox Friend WithEvents Button2 As System.Windows.Forms.Button Friend WithEvents Button3 As System.Windows.Forms.Button Friend WithEvents ChkDelWorkFile As System.Windows.Forms.CheckBox End Class frmTabFile.vb Imports System.Text.RegularExpressions Public Class frmTabFile Private Enum me_Col c0Name c1Null c2Type End Enum Private Sub Form1_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load Me.TxtConnect.Text = pf_GetIni("", "DESC", "Connect", "ユーザ名/パスワード@ネットサービス名") Me.TxtTableName.Text = pf_GetIni("", "DESC", "TableName", "DUAL") Me.TxtWorkFolder.Text = pf_GetIni("", "DESC", "WorkFolder", "C \Temp") Me.TxtTxtFile.Text = pf_GetIni("", "DESC", "txtFile", "desc.txt") Me.TxtSqlFile.Text = pf_GetIni("", "DESC", "sqlFile", "desc.sql") Me.TxtBatFile.Text = pf_GetIni("", "DESC", "batFile", "desc.bat") End Sub Private Sub Form1_FormClosed(sender As Object, e As System.Windows.Forms.FormClosedEventArgs) Handles Me.FormClosed Call ps_PutIni("", "DESC", "Connect", Me.TxtConnect.Text) Call ps_PutIni("", "DESC", "TableName", Me.TxtTableName.Text) Call ps_PutIni("", "DESC", "WorkFolder", Me.TxtWorkFolder.Text) Call ps_PutIni("", "DESC", "txtFile", Me.TxtTxtFile.Text) Call ps_PutIni("", "DESC", "sqlFile", Me.TxtSqlFile.Text) Call ps_PutIni("", "DESC", "batFile", Me.TxtBatFile.Text) If Me.ChkDelWorkFile.Checked Then Dim w_TxtFile As String = String.Format("{0}\{1}", Me.TxtWorkFolder.Text, Me.TxtTxtFile.Text) Dim w_SqlFile As String = String.Format("{0}\{1}", Me.TxtWorkFolder.Text, Me.TxtSqlFile.Text) Dim w_BatFile As String = String.Format("{0}\{1}", Me.TxtWorkFolder.Text, Me.TxtBatFile.Text) Call ms_DelFile(w_BatFile) Call ms_DelFile(w_SqlFile) Call ms_DelFile(w_TxtFile) End If End Sub Private Sub DataGridView1_CellPainting(sender As Object, e As System.Windows.Forms.DataGridViewCellPaintingEventArgs) Handles DataGridView1.CellPainting If e.ColumnIndex 0 AndAlso e.RowIndex = 0 Then Call e.Paint(e.ClipBounds, DataGridViewPaintParts.All) Dim rect As Rectangle = e.CellBounds Call rect.Inflate(-2, -2) Call TextRenderer.DrawText(e.Graphics, (e.RowIndex + 1).ToString(), e.CellStyle.Font, rect, e.CellStyle.ForeColor, TextFormatFlags.Right Or TextFormatFlags.VerticalCenter) e.Handled = True End If End Sub Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click Dim w_TxtFile As String = String.Format("{0}\{1}", Me.TxtWorkFolder.Text, Me.TxtTxtFile.Text) Dim w_TableName As String = Me.TxtTableName.Text.ToUpper Dim w_Desc As String = mf_Desc(w_TxtFile, w_TableName, Me.TxtConnect.Text) Dim w_SqlFile As String = String.Format("{0}\{1}", Me.TxtWorkFolder.Text, Me.TxtSqlFile.Text) Call ms_StreamWriter(w_SqlFile, w_Desc) Dim w_BatCommand As String = String.Format("SQLPLUS {0} @{1}", Me.TxtConnect.Text, w_SqlFile) Dim w_BatFile As String = String.Format("{0}\{1}", Me.TxtWorkFolder.Text, Me.TxtBatFile.Text) Call ms_StreamWriter(w_BatFile, w_BatCommand) Call ms_StartProcessWaitForExit(w_BatFile) Dim w_FileText As String = mf_GetFileText(w_TxtFile) Dim w_StringList As List(Of String) = mf_FileTextToStringList(w_FileText) Dim w_DescList As List(Of clsDesc) = mf_StringListToDescList(w_StringList) Me.DataGridView1.Rows.Clear() If w_DescList.Count 0 Then Me.DataGridView1.Rows.Add(w_DescList.Count) For i As Integer = 0 To w_DescList.Count - 1 Me.DataGridView1.Rows(i).Cells(me_Col.c0Name).Value = w_DescList(i).c0Name Me.DataGridView1.Rows(i).Cells(me_Col.c1Null).Value = w_DescList(i).c1Null Me.DataGridView1.Rows(i).Cells(me_Col.c2Type).Value = w_DescList(i).c2Type Next Me.DataGridView1.AutoResizeColumns(DataGridViewAutoSizeColumnsMode.AllCells) Dim sb As New sb() For i As Integer = 0 To Me.DataGridView1.Rows.Count - 1 Dim w_c0Name As String = mf_ObjectToString(Me.DataGridView1.Rows(i).Cells(me_Col.c0Name).Value) Dim w_c1Null As String = mf_ObjectToString(Me.DataGridView1.Rows(i).Cells(me_Col.c1Null).Value) Dim w_c2Type As String = mf_ObjectToString(Me.DataGridView1.Rows(i).Cells(me_Col.c2Type).Value) sb.Add("{1}{0}{2}{0}{3}", vbTab, w_c0Name, w_c1Null, w_c2Type) Next Dim w_tabFile As String = String.Format("{0}\{1}.tab", Me.TxtWorkFolder.Text, Me.TxtTableName.Text) Call ms_StreamWriter(w_tabFile, sb.ToString) Select Case MsgBox("tabファイルを開きますか。", MsgBoxStyle.YesNo Or MsgBoxStyle.DefaultButton2 Or MsgBoxStyle.SystemModal, "確認") Case MsgBoxResult.Yes Call ms_StartProcess(w_tabFile) Case Else End Select End If End Sub Private Sub Button2_Click(sender As System.Object, e As System.EventArgs) Handles Button2.Click Dim w_tabFile As String = String.Format("{0}\{1}.tab", Me.TxtWorkFolder.Text, Me.TxtTableName.Text) Call ms_StartProcess(w_tabFile) End Sub Private Sub Button3_Click(sender As System.Object, e As System.EventArgs) Handles Button3.Click Dim w_WorkFolder As String = Me.TxtWorkFolder.Text Call ms_StartProcess(w_WorkFolder) End Sub Private Function mf_Desc(wp_TxtFile As String, wp_TableName As String, wp_Connect As String) As String Dim sb As New sb() sb.Add("connect {0}", wp_Connect) sb.Add("set echo off") sb.Add("set heading off") sb.Add("set pagesize 0") sb.Add("set feedback off") sb.Add("set linesize 80") sb.Add("set trimspool on") sb.Add("spool {0}", wp_TxtFile) sb.Add("desc {0}", wp_TableName) sb.Add("spool off") sb.Add("set linesize 80") sb.Add("clear") sb.Add("exit") Return sb.ToString End Function Private Sub ms_StreamWriter(wp_File As String, wp_Text As String) Dim enc As System.Text.Encoding = System.Text.Encoding.GetEncoding("shift_jis") Dim sw As New System.IO.StreamWriter(wp_File, False, enc) sw.Write(wp_Text) sw.Close() End Sub Private Sub ms_StartProcessWaitForExit(wp_BatFile As String) Dim p As System.Diagnostics.Process = System.Diagnostics.Process.Start(wp_BatFile) p.WaitForExit() p.Close() p.Dispose() End Sub Private Sub ms_StartProcess(wp_File As String) Dim p As System.Diagnostics.Process = System.Diagnostics.Process.Start(wp_File) End Sub Private Function mf_GetFileText(wp_TxtFile As String) As String Dim ret As String = "" Dim enc As System.Text.Encoding = System.Text.Encoding.GetEncoding("shift_jis") Dim sr As New System.IO.StreamReader(wp_TxtFile, enc) ret = sr.ReadToEnd() sr.Close() Return ret End Function Private Function mf_FileTextToStringList(wp_FileText As String) As List(Of String) Dim ret As New List(Of String) Dim a As String() = Split(wp_FileText, vbCrLf, -1, CompareMethod.Text) For i As Integer = 0 To a.Count - 1 Dim w As String = a(i).Trim If w "" Then If Not mf_Header(w) Then If Not mf_Separator(w) Then ret.Add(w) End If End If End If Next Return ret End Function Private Function mf_Header(wp_String As String) As Boolean Dim ret As Boolean = False Dim w As String = wp_String.Replace(" ", "") If w.Trim = "名前NULL?型" Then ret = True End If Return ret End Function Private Function mf_Separator(wp_String As String) As Boolean Dim ret As Boolean = False Dim w As String = wp_String.Replace("-", "") If w.Trim = "" Then ret = True End If Return ret End Function Private Function mf_StringListToDescList(wp_StringList As List(Of String)) As List(Of clsDesc) Dim ret As New List(Of clsDesc) For i As Integer = 0 To wp_StringList.Count - 1 Dim w_input As String = wp_StringList(i) Dim w_pattern As String = " +" Dim w_replacement As String = vbTab Dim w As String = Regex.Replace(w_input, w_pattern, w_replacement, RegexOptions.Multiline Or RegexOptions.IgnoreCase) Dim a As String() = Split(w, vbTab, -1, CompareMethod.Text) Select Case a.Count Case 2 Dim w_Desc As New clsDesc() w_Desc.c0Name = a(0) w_Desc.c2Type = a(1) ret.Add(w_Desc) Case 3 Dim w_Desc As New clsDesc() w_Desc.c0Name = a(0) w_Desc.c1Null = a(1) w_Desc.c2Type = a(2) ret.Add(w_Desc) Case Else End Select Next Return ret End Function Private Function mf_ObjectToString(wp_Object As Object) As String Dim ret As String = "" If Not wp_Object Is Nothing Then ret = wp_Object.ToString End If Return ret End Function Private Sub ms_DelFile(wp_File As String) System.IO.File.Delete(wp_File) End Sub End Class mdlInit.vb Imports System.Runtime.InteropServices Module mdlInit DllImport("KERNEL32.DLL", CharSet =CharSet.Auto) _ Public Function GetPrivateProfileString( _ ByVal lpAppName As String, _ ByVal lpKeyName As String, _ ByVal lpDefault As String, _ ByVal lpReturnedString As System.Text.StringBuilder, _ ByVal nSize As Integer, _ ByVal lpFileName As String) As Integer End Function DllImport("KERNEL32.DLL") _ Public Function WritePrivateProfileString( _ ByVal lpAppName As String, _ ByVal lpKeyName As String, _ ByVal lpString As String, _ ByVal lpFileName As String) As Integer End Function Public Function pf_GetIni(ByVal wp_path As String, ByVal wp_section As String, ByVal wp_key As String, ByVal wp_Default As String) As String Dim ret As String = wp_Default Dim sb As New System.Text.StringBuilder sb.Capacity = 256 Dim i As Integer = GetPrivateProfileString(wp_section, wp_key, wp_Default, sb, sb.Capacity, mf_path(wp_path)) ret = sb.ToString Return ret End Function Public Sub ps_PutIni(ByVal wp_path As String, ByVal wp_section As String, ByVal wp_key As String, ByVal wp_value As String) Dim i As Integer = WritePrivateProfileString(wp_section, wp_key, wp_value, mf_path(wp_path)) End Sub Private Function mf_path(ByVal wp_path As String) As String Dim ret As String = wp_path If ret = "" Then Dim w_path As String = Application.StartupPath If w_path.EndsWith("\") = False Then w_path = w_path "\" End If ret = String.Format("{0}{1}.ini", w_path, My.Application.Info.AssemblyName) End If Return ret End Function End Module sb.vb Public Class sb Private m_sb As System.Text.StringBuilder Public Sub New() m_sb = New System.Text.StringBuilder() End Sub Public Overrides Function ToString() As String Return m_sb.ToString() End Function Public Function Add(ByVal wp_String As String, ByVal ParamArray wp_Args() As Object) m_sb.AppendFormat(wp_String, wp_Args) m_sb.Append(ControlChars.CrLf) Return m_sb End Function Public Function ToStringRemoveLastCrLf() As String Dim ret As String = m_sb.ToString If ret.Length = vbCrLf.Length Then Dim i As Integer = ret.Length - vbCrLf.Length Dim w As String = ret.Substring(i) If w = vbCrLf Then ret = ret.Substring(0, i) End If End If Return ret End Function Public Sub cb() Clipboard.SetText(m_sb.ToString()) End Sub End Class
https://w.atwiki.jp/wiki7_az/pages/39.html
SQL*Plusコマンド ファイルに記述されたSQLを実行する SQL @test.sql SQL start test.sql SQLバッファ内をホストOSのエディタで編集する SQL ed[it] SQLバッファ内のカレント行の終わりに文字列を追加する SQL a[ppend] SQLバッファ内のSQLコマンドを実行する SQL / 現在のSQLバッファを表示する SQL l[ist] 現在のSQLバッファ内をホストOSのファイルとして保存する SQL sav[e] ファイル名 現在のSQL*Plus環境をホストOSのファイルとして保存する SQL store set ファイル名 問い合わせ結果をファイルに出力する SQL show spool spool OFF SQL spool on SQL spool c \test.txt SQL spool off SQL*Plus でテーブル名を指定してcsv出力(OTN Japan Code Tips# 764) $ sqlplus scott/tiger SQL @mk_csv.sql SQL Enter value for max_line_size 32767 SQL DATETIME FORMAT YYYY-MM-DD HH24 MI SS SQL TABLE NAME user_tables SQL OUTPUT FILE NAME user_tables.csv ----- mk_csv.sql ここから set pagesize 0 set linesize 32767 set linesize MAX_LINE_SIZE set trimspool on set feedback off set verify off ACCEPT DT_FMT CHAR PROMPT DATETIME FORMAT ALTER SESSION SET NLS_DATE_FORMAT = DT_FMT ; ACCEPT TABLE CHAR PROMPT TABLE NAME ACCEPT FILE CHAR PROMPT OUTPUT FILE NAME set termout off spool tmp_csv.sql SELECT SELECT FROM DUAL; SELECT CHR(9) || DECODE( DATA_TYPE, VARCHAR2 , " || REPLACE( , CHAR , " || REPLACE( , NULL ) || COLUMN_NAME || DECODE( DATA_TYPE, VARCHAR2 , , " , "" ) || ", || , CHAR , , " , "" ) || ", || , || , || ) FROM USER_TAB_COLUMNS WHERE TABLE_NAME = UPPER( TABLE ) AND COLUMN_ID != ( SELECT MAX( COLUMN_ID ) FROM USER_TAB_COLUMNS WHERE TABLE_NAME = UPPER( TABLE ) ) ORDER BY COLUMN_ID; SELECT CHR(9) || DECODE( DATA_TYPE, VARCHAR2 , " || REPLACE( , CHAR , " || REPLACE( , NULL ) || COLUMN_NAME || DECODE( DATA_TYPE, VARCHAR2 , , " , "" ) || " , CHAR , , " , "" ) || " , NULL ) FROM USER_TAB_COLUMNS WHERE TABLE_NAME = UPPER( TABLE ) AND COLUMN_ID = ( SELECT MAX( COLUMN_ID ) FROM USER_TAB_COLUMNS WHERE TABLE_NAME = UPPER( TABLE ) ); SELECT FROM TABLE; FROM DUAL; spool off spool FILE @tmp_csv spool off set termout on ----- mk_csv.sql ここまで
https://w.atwiki.jp/tdd1tessa/pages/40.html
SQL*PlusはSQLコマンドを入力することによりデータベースを管理するツールである。以下のような操作が可能。 表データの検索 表へのデータの追加、更新、削除 表の作成、削除 データベースの管理作業 SQLをスクリプトファイルに記述し、バッチ形式で実行することもできる。 SQL*Plusの使用方法 "sqlplus"コマンドを実行する。 【データベースへの接続】 CONNECTコマンドを実行する。 CONNECT ユーザー名/パスワード 戻る
https://w.atwiki.jp/pokese/pages/22.html
iSQL*Plusの起動・停止 1.起動状態の確認 Linuxを再起動してiSQL*Plusに接続しようとしたら接続エラーになりました。 以下のコマンドを実行してiSQL*Plusが起動しているか確認します。 isqlplusctl status 結果は stop なので停止しています・・・ 2.起動・停止 以下のコマンドを実行するとiSQL*Plusが起動します。 isqlplusctl start 停止する場合は以下のコマンドを実行します。 isqlplusctl stop 参照 風の吹く場所
https://w.atwiki.jp/adsl243/pages/20.html
Enterprise Managerの使用ポート番号の確認 emctl status dbconsole 又は $ORACLE_HOME/hostname_SID/sysman/config/emd.properties のREPOSITORY_URLの項目から確認出来ます。 Enterprise Managerの使用ポート番号の変更 emca -reconfig ports -DBCONTROL_HTTP_PORT ポート番号 iSQL*Plus関連 サービスの開始 isqlplusctl start サービスの停止 isqlplusctl stop 接続先の変更(ポート番号orホスト名) ①と②のファイルを編集します。 ①vi $ORACLE_HOME¥hostname_SID¥sysman¥config¥emoms.properties 下記二点を編集 oracle.sysman.db.isqlplusUrl=http¥ //host.domain¥ 5560/isqlplus/dynamic oracle.sysman.db.isqlplusWebDBAUrl=http¥ //host.domain¥ 5560/isqlplus/dynamic ②vi $ORACLE_HOME¥oc4j¥j2ee¥isqlplus¥config¥http-web-site.xml web-site要素のport属性を変更 web-site port="5560" ...