Untitled

mail@pastecode.io avatar
unknown
plain_text
2 years ago
1.1 kB
1
Indexable
Never
for (unsigned i = 0; i < current_data.authors.size(); i++)
                {
                    result r = tx.exec("SELECT * FROM public.author WHERE \"First_Name\"=\'%s\' AND \"Middle_Name\"=\'%s\' AND \"Last_Name\"=\'%s\'", W.esc(current_data.authors[i].first_name).c_str(), W.esc(current_data.authors[i].middle_name).c_str(), W.esc(current_data.authors[i].last_name).c_str());
                    int count = 0;
                    int id;
                    for(auto const &row: r)
                    {
                        for(auto const &col: row)
                        {
                            id = field;
                        }
                        count++;
                    }
                    if(!count)sprintf(buffer, "INSERT INTO public.author(\"First_Name\", \"Middle_Name\", \"Last_Name\") VALUES(\'%s\', \'%s\', \'%s\');", W.esc(current_data.authors[i].first_name).c_str(), W.esc(current_data.authors[i].middle_name).c_str(), W.esc(current_data.authors[i].last_name).c_str());
                    else // use id to insert paper paper.authorid = id;
                }