質問編集履歴
4
categoryテーブル作成のSQLに間違いがあったので修正しました。
test
CHANGED
File without changes
|
test
CHANGED
@@ -90,6 +90,8 @@
|
|
90
90
|
|
91
91
|
FOR rec IN 0..loop_max LOOP
|
92
92
|
|
93
|
+
|
94
|
+
|
93
95
|
--category_wordに1つ目のカテゴリーを入れる。
|
94
96
|
|
95
97
|
select into category_word
|
@@ -130,6 +132,8 @@
|
|
130
132
|
|
131
133
|
loop_count:=loop_count+1;
|
132
134
|
|
135
|
+
|
136
|
+
|
133
137
|
END LOOP;
|
134
138
|
|
135
139
|
return 0;
|
@@ -182,8 +186,6 @@
|
|
182
186
|
|
183
187
|
, name character varying(255)
|
184
188
|
|
185
|
-
, name_all text
|
186
|
-
|
187
189
|
, constraint category_PKC primary key (id)
|
188
190
|
|
189
191
|
) ;
|
3
テーブル情報に記載漏れがあったので追加しました。
test
CHANGED
File without changes
|
test
CHANGED
@@ -12,7 +12,7 @@
|
|
12
12
|
|
13
13
|
|
14
14
|
|
15
|
-
・PREPAREやCOPY等
|
15
|
+
・PREPAREやCOPY等も調べましたが、重複処理をどうすればいいのか分からなかったです。
|
16
16
|
|
17
17
|
|
18
18
|
|
@@ -150,9 +150,9 @@
|
|
150
150
|
|
151
151
|
### 試したこと
|
152
152
|
|
153
|
-
C
|
153
|
+
COPY文を使って1度csvで出力して、csvで読み込もうとしました。
|
154
|
-
|
154
|
+
|
155
|
-
しかし、重複チェックをC
|
155
|
+
しかし、重複チェックをCOPY文でどうやればいいのか分からなくて止まっています。
|
156
156
|
|
157
157
|
|
158
158
|
|
@@ -238,4 +238,36 @@
|
|
238
238
|
|
239
239
|
on original(id);
|
240
240
|
|
241
|
+
|
242
|
+
|
243
|
+
comment on table category is 'category';
|
244
|
+
|
245
|
+
comment on column category.name_all is 'name_all';
|
246
|
+
|
247
|
+
comment on column category.id is 'id';
|
248
|
+
|
249
|
+
comment on column category.parent is 'parent';
|
250
|
+
|
251
|
+
comment on column category.name is 'name';
|
252
|
+
|
253
|
+
|
254
|
+
|
255
|
+
comment on table original is 'original';
|
256
|
+
|
257
|
+
comment on column original.id is 'id';
|
258
|
+
|
259
|
+
comment on column original.name is 'name';
|
260
|
+
|
261
|
+
comment on column original.condition_id is 'condition_id';
|
262
|
+
|
263
|
+
comment on column original.category_name is 'category_name';
|
264
|
+
|
265
|
+
comment on column original.brand is 'brand';
|
266
|
+
|
267
|
+
comment on column original.price is 'price';
|
268
|
+
|
269
|
+
comment on column original.shipping is 'shipping';
|
270
|
+
|
271
|
+
comment on column original.description is 'description';
|
272
|
+
|
241
273
|
```
|
2
コードにマークダウンを付けました。
test
CHANGED
File without changes
|
test
CHANGED
@@ -40,6 +40,10 @@
|
|
40
40
|
|
41
41
|
ソースコード
|
42
42
|
|
43
|
+
```lang-PostgreSQL
|
44
|
+
|
45
|
+
|
46
|
+
|
43
47
|
create or replace function insert_into_category(
|
44
48
|
|
45
49
|
Count INTEGER default null
|
@@ -140,6 +144,8 @@
|
|
140
144
|
|
141
145
|
select * from category order by id asc;
|
142
146
|
|
147
|
+
```
|
148
|
+
|
143
149
|
|
144
150
|
|
145
151
|
### 試したこと
|
@@ -160,6 +166,10 @@
|
|
160
166
|
|
161
167
|
テーブルのSQL文も記載します。
|
162
168
|
|
169
|
+
```lang-PostgreSQL
|
170
|
+
|
171
|
+
|
172
|
+
|
163
173
|
--category
|
164
174
|
|
165
175
|
create table category (
|
@@ -227,3 +237,5 @@
|
|
227
237
|
create unique index original_pki
|
228
238
|
|
229
239
|
on original(id);
|
240
|
+
|
241
|
+
```
|
1
使用しているテーブル情報を記載しました。
test
CHANGED
File without changes
|
test
CHANGED
@@ -155,3 +155,75 @@
|
|
155
155
|
<環境>
|
156
156
|
|
157
157
|
PostgreSql9.6,pgAdmin3
|
158
|
+
|
159
|
+
|
160
|
+
|
161
|
+
テーブルのSQL文も記載します。
|
162
|
+
|
163
|
+
--category
|
164
|
+
|
165
|
+
create table category (
|
166
|
+
|
167
|
+
name_all character varying(255)
|
168
|
+
|
169
|
+
, id serial not null
|
170
|
+
|
171
|
+
, parent integer
|
172
|
+
|
173
|
+
, name character varying(255)
|
174
|
+
|
175
|
+
, name_all text
|
176
|
+
|
177
|
+
, constraint category_PKC primary key (id)
|
178
|
+
|
179
|
+
) ;
|
180
|
+
|
181
|
+
|
182
|
+
|
183
|
+
create unique index category_pki
|
184
|
+
|
185
|
+
on category(id);
|
186
|
+
|
187
|
+
|
188
|
+
|
189
|
+
create index parent_id_index
|
190
|
+
|
191
|
+
on category(parent);
|
192
|
+
|
193
|
+
|
194
|
+
|
195
|
+
-- original
|
196
|
+
|
197
|
+
create table original (
|
198
|
+
|
199
|
+
id integer not null
|
200
|
+
|
201
|
+
, name character varying(255)
|
202
|
+
|
203
|
+
, condition_id integer
|
204
|
+
|
205
|
+
, category_name character varying(255)
|
206
|
+
|
207
|
+
, brand character varying(255)
|
208
|
+
|
209
|
+
, price double precision
|
210
|
+
|
211
|
+
, shipping integer
|
212
|
+
|
213
|
+
, description text
|
214
|
+
|
215
|
+
, constraint original_PKC primary key (id)
|
216
|
+
|
217
|
+
) ;
|
218
|
+
|
219
|
+
|
220
|
+
|
221
|
+
create index brand_index
|
222
|
+
|
223
|
+
on original(brand);
|
224
|
+
|
225
|
+
|
226
|
+
|
227
|
+
create unique index original_pki
|
228
|
+
|
229
|
+
on original(id);
|