Ejemplo n.º 1
0
        // copy tab(cols) from <file> <where> =>
        // insert into tab(cols) select * from foreign_table(<file>) <where>
        //
        public CopyStmt(BaseTableRef targetref, List <string> cols, string fileName, Expr where, string text) : base(text)
        {
            cols       = cols.Count != 0 ? cols : null;
            targetref_ = targetref; fileName_ = fileName; where_ = where;

            var colrefs = new List <Expr>();

            Utils.Assumes(cols is null);
            if (cols is null)
            {
                colrefs = targetref.AllColumnsRefs();
            }
            ExternalTableRef sourcetab = new ExternalTableRef(fileName, targetref, colrefs);
            SelectStmt       select    = new SelectStmt(new List <Expr> {
                new SelStar(null)
            },
                                                        new List <TableRef> {
                sourcetab
            }, where, null, null, null, null, null, null, text);

            insert_ = new InsertStmt(targetref, cols, null, select, text)
            {
                queryOpt_ = queryOpt_
            };
        }