internal DbIns(Reach smb) { init(); //TBD Db db = new Db(new ctx().DbDrivers); DbIns ret = null; Zone bktFilter = new Zone(new Pile <string>(), new Pile <string>("", true, "(", ")", "||:0")); Zone strFilter = new Zone(new Pile <string>(), new Pile <string>("", true, "\"", "\"", "||:1")); /* * string insstr = "Grid(\"prdrln\").sC(\"sbj, obj, vb, rul, steps, excerpt, trust\").INS(XXXX)"; * insstr = insstr.Replace("XXXX", "Grid(\"prdrln p1, prdvrb pv1, prdrln p2, prdvrb pv2, kndrln sc, itmrln si, prdvrb pv, prdrul pr, itmrln oi, kndrln oc\", cd(\"p1.obj\").EQ(\"p2.sbj\")).sC(\"si.id, oi.id, pv.id, pr.id, 0, '', 0.5\").sR(XXXX).SLD"); * insstr = insstr.Replace("XXXX", "cd(\"0\").EQ(Grid(\"prdrln prdrln\").sC(\"count(*)\").sR(cd(\"sbj\").EQ(\"si.id\"), cd(\"obj\").EQ(\"oi.id\"), cd(\"vb\").EQ(\"pr.vb\")).SLC ), XXXX"); * insstr = bktFilter.on(insstr).text; * insstr = insstr.Replace("XXXX", "cd(\"0\").EQ(Grid(\"prdrln prdrln\").sC(\"count(*)\").sR(cd(\"sbj\").EQ(\"si.id\"), cd(\"obj\").EQ(\"oi.id\"), cd(\"vb\").EQ(\"pr.vb\")).SLC ), XXXX"); */ Reach gridDef = smb - bktFilter.on(smb); Reach ins = gridDef.at(".INS("); if (ins.len == 0) { throw new Exception("DbIns Constructor: invalid symbolic Definition"); } DbGrid res = db.Grid(smb.before(ins)); smb = smb.after(ins).before(-1, ")"); if (smb.startsWith("Grid(")) { ret = res.INS(new DbSlc(smb)); } else { Pile <string> val = new Pile <string>(); while (smb.len > 0) { if (smb.startsWith("ds(")) { val.Push(db.ds(smb.after(1, "\"").before(1, "\""))); smb = smb.after(1, "),").Trim(); } else { val.Push(smb.before(1, ",").Trim()); smb = smb.after(1, ",").Trim(); } } ret = res.INS(val.array()); } into = ret.into; fields = ret.fields.Clone(); //new Pile<string>(ret.fieldNames); values = ret.values; slc = ret.slc; }
internal DbIns(string into, Pile <DbField> fields, DbSlc select) { init(); this.slc = select; this.fields.Add(fields); //fields = fields.Trim(); while (fields.Length > 0) { this.fields.Add(utl.cutl(ref fields, ",").Trim()); fields = fields.Trim(); } this.into = into.Trim(); string tShort = utl.cutl(ref into, ",").Trim().ToLower(); string tName = utl.cutl(ref tShort, " ").Trim(); tShort = tShort.Trim(); if (tShort.Length == 0) { tShort = tName; } into = tName.Trim() + " " + tShort.Trim(); }