使用MySQL中的if条件触发不起作用

时间:2018-08-17 18:00:10

标签: mysql triggers

import json
import yaml

# input file containing json file
with open('data.json') as f:
    json_data = json.load(f)

# json schema in yaml format

def gettype(type):
    for i in ['string','boolean','integer']:
        if type in i:
            return i
    return type   

def parser(json_data):
    d = {}
    if type(json_data) is dict:
        d['type'] = 'object'
        for key in json_data:
            d[key] = parser(json_data[key])
        return d
    elif type(json_data) is list:
        d['type'] = 'array'
        if len(json_data) != 0:
            d['items'] = parser(json_data[0])
        else:
            d['items'] = 'object'
        return d
    else:
        d['type'] = gettype(type(json_data).__name__)
        return d

p = parser(json_data)
with open('out.yaml','w') as outfile:
    yaml.dump(p,outfile, default_flow_style=False)

我有一个类别表,其中有CREATE TRIGGER triggerchild AFTER INSERT ON category FOR EACH ROW BEGIN IF(catagory.parent_id>0) THEN UPDATE catagory SET total_child=total_child+1 WHERE c_id=new.parent_id; END IF; END; category_idcategory_nameparent_id,并且我想在插入子类别后增加total_child的值

我有一个触发器,并尝试在插入子类别后增加其值,但发生了错误。

0 个答案:

没有答案