Home > database >  How to import Excel table structure to Powerdesigner
How to import Excel table structure to Powerdesigner

Time:10-20

PD modeling in the
PD in the menu bar, click on the "Tools - & gt; in turn Excute Commands - & gt; Edit/Run Script


'start
Option Explicit

Dim MDL 'the current model
The Set of MDL=ActiveModel
If (MDL Is Nothing) Then
MsgBox "There is no Active Model", "
End the If

Dim HaveExcel
Dim RQ
RQ=vbYes' MsgBox (" Is Excel Installed on your machine?" , vbYesNo + vbInformation, "Confirmation")
If RQ=vbYes Then
HaveExcel=True
'Open & amp; The Create Excel Document
Dim x1 '
Set the x1=CreateObject (" Excel. Application ")
X1. Workbooks. The Open D: \ "My Data \ Project \ Data \ DIM \ D table \ MOD_NODE XLS" excel document specified path '
X1. Workbooks (1). Worksheets (" Sheet1 "). The Activate 'assigned to open the sheet name
The Else
HaveExcel=False
End the If

A x1, MDL

Sub a (x1, MDL)
Dim rwIndex
Dim tableName
Dim colname
Dim table
Dim col
Dim the count

On the error Resume Next

Set the table=MDL. Tables. CreateNew entities' to create a table
Table. The Name="Sheet1" 'specifies the Name of the table, if in the Excel document, also can. Cells (rwIndex, 3). The Value that specify
Table. The Code specify table name="Sheet1" '
The count=count + 1

For rwIndex=2 To 1000 'line designated To traverse the Excel standard because line 1 is header, starting from the line 2
With the x1. Workbooks (1). Worksheets (" Sheet1 ")
If the Cells (rwIndex, 1.) Valuehttps://bbs.csdn.net/topics/="" Then
The Exit For
End the If

The set col=table. The Columns. CreateNew 'to create a column/field
'MsgBox. Cells (rwIndex, 1). The Value of vbOK + vbInformation, "column"
If the Cells (rwIndex, 1.) Valuehttps://bbs.csdn.net/topics/="" Then
Col. Name=. Cells (rwIndex, 1). The Value 'specified column Name
The Else
Col. Name=. Cells (rwIndex, 1). The Value
End the If
'MsgBox col. Name, vbOK + vbInformation, "column"
Ment=col.Com. Cells (rwIndex, 1). The Value 'specified column description
Col. Code=. Cells (rwIndex, 2). The Value 'specified column name
Col. DataType=. Cells (rwIndex, 3). The Value 'specified column data type
If the Cells (rwIndex, 4). Valuehttps://bbs.csdn.net/topics/="no" Then
Col. Mandatory=true 'specified column is nullable true for an empty
End the If
If rwIndex=2 Then
Col. Primary=true 'specified Primary key
End the If
End With
Next
MsgBox "generated data table structure of" + CStr (count), vbOK + vbInformation, "table"

The Exit Sub
End sub

CodePudding user response:

Option Explicit
Dim MDL 'the current model
The Set of MDL=ActiveModel
If (MDL Is Nothing) Then
MsgBox "There is no Active Model", "
End the If

Dim HaveExcel
Dim RQ
RQ=vbYes' MsgBox (" Is Excel Installed on your machine?" , vbYesNo + vbInformation, "Confirmation")
If RQ=vbYes Then
HaveExcel=True
'Open & amp; The Create Excel Document
Dim x1 '
Set the x1=CreateObject (" Excel. Application ")
X1. Workbooks. Open "d: \ User_1 XLSX" here the directory name, file name change
X1. Workbooks (1). Worksheets (" Sheet1 "). The Activate
The Else
HaveExcel=False
End the If

A x1, MDL

Sub a (x1, MDL)
Dim rwIndex
Dim tableName
Dim colname
Dim table
Dim col
Dim the count

'on the error Resume Next
For rwIndex=1 To 1000 step 1
With the x1. Workbooks (1). Worksheets (" Sheet1 ")
'MsgBox "generate the data table structure for a total of 1=" + CStr () Cells (2, 2). The Value), vbOK + vbInformation, "table", "
If the Cells (rwIndex, 1.) Valuehttps://bbs.csdn.net/topics/="" Then
The Exit For
End the If
If the Cells (rwIndex, 3). Valuehttps://bbs.csdn.net/topics/="" Then
Set the table=MDL. Tables. CreateNew
Table. The Name=. Cells (rwIndex, 1). The Value
Table. Code=. Cells (rwIndex, 2). The Value
The count=count + 1
The Else
ColName=. Cells (rwIndex, 1). The Value
The set of col=table. The Columns. CreateNew
'MsgBox. Cells (rwIndex, 1). The Value of vbOK + vbInformation, "column"
Col. Name=. Cells (rwIndex, 1). The Value
'MsgBox col. Name, vbOK + vbInformation, "column"
Col. Code=. Cells (rwIndex, 2). The Value
Ment=col.Com. Cells (rwIndex, 1). The Value
Col. DataType=. Cells (rwIndex, 3). The Value
End the If
End With
Next

MsgBox "generated data table structure of" + CStr (count), vbOK + vbInformation, "table"

The Exit Sub
End sub

CodePudding user response:

V_sdate:=to_char (i_sdate, 'yyyymmddhh24miss');
V_sdate:=to_char (i_sdate, 'yyyyMMdd') | | '000000'. - the format yyyymmddhh24miss
V_edate:=to_char (i_edate, 'yyyyMMdd') | | '235959'. Minutes - format yyyymmddhh24miss, date for '23:59:59'
S_TIME:=to_char (i_sdate, 'yyyymmdd');
E_TIME:=to_char (i_edate, 'yyyymmdd');

Err_msg VARCHAR2 (200); - the error message
V_sdate VARCHAR2 (8); - start time
V_edate VARCHAR2 (8); - end time
V_area VARCHAR2 (200); - the regional information

The begin
V_sdate:=to_char (i_sdate, 'yyyymmdd');
V_edate:=to_char (i_edate, 'yyyymmdd');

IF (i_area IS NULL) THEN
The SELECT to_char (WMSYS WM_CONCAT (area_id)) INTO v_area FROM tbl_area;
- the query to the data in a v_area, comma-separated
The ELSE
V_area:=i_area;
END the IF;

WHERE u.a rea_id IN (SELECT regexp_substr (v_area, '[^,] +' 1, LEVEL) FROM dual
CONNECT BY LEVEL & lt; nullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnull
  • Related