Customer Portal

Output to DDL SQL files

Comments 1

  • Avatar
    avackova
    0
    Comment actions Permalink
    Hello Maxani,
    we don't have writer, that creates such output, but it can be easily achieved with Reformat component with transform attribute as follows:
    //#CTL1
    string query;
    record(Metadata4) input;
    // Transforms input record into output record.
    function transform() {
    int i;
    input = @0;
    query = "insert into " + $table + " (";
    for (i =0; i < length(input); i++) {
    if (get_field_name(input,i) != "table") {
    query = concat(query, get_field_name(input,i), ',');
    }
    }
    query = substring(query,0,length(query) - 1);
    query = query + ") values ('";
    for (i =0; i < length(input); i++) {
    if (get_field_name(input,i) != "table") {
    if (get_field_type(input,i) == "string") {
    query = concat(query, replace(nvl(input[i],''), "'", "\\\\'"), "','");
    }else{
    query = concat(query, input[i], "','");
    }
    }
    }
    query = substring(query,0,length(query) - 2);
    query = concat(query, ')');
    $query := query;
    }

Please sign in to leave a comment.