简体   繁体   English

顺序迁移-游标

[英]Sequelize migration - cursor

is there anyway to use cursor in sequelize migration ? 无论如何,在sequelize migration使用游标? i am trying to create DML script ,the idea is to loop the values in table ie. 我试图创建DML脚本,想法是循环表中的值,即。 day using cursor and then insert values to other table ie. 天使用光标,然后将值插入其他表,即。 mealday inside the cursor. 光标所在的饭日。

table : day
dayId
dayName

table : meal
mealId
mealName

table : mealday
mealdayId
dayId
mealId

the insert statement i should use inside cursor is : 我应该在游标中使用的插入语句是:

insert into mealday (dayId,mealId) 
select **dayIdFromCursor**,mealId from meal

as a work around i can simply repeat the insert statement 7 times (number of days in day table) and hard code dayId 作为解决方法,我可以简单地重复insert语句7次( dayId中的天数)和硬代码dayId

insert into mealday (dayId,mealId) 
select 1,mealId from meal

insert into mealday (dayId,mealId) 
select 2,mealId from meal

...

insert into mealday (dayId,mealId) 
select 7,mealId from meal

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM