// GenerateSql can return NULL, if SQL cannot be generated for given dialect public string GenerateSql(ISqlDialect dialect, DbTypeBase targetType, IProgressInfo progress) { try { return(dialect.GenerateScript(dmp => { dmp.ProgressInfo = progress; GenerateSql(dmp, targetType); })); } catch (SyntaxNotSupportedError) { return(null); } }
public void Reformat() { if (EditPropertiesForm.Run(ReformatProps, true)) { string sql = m_editor.Text; ISqlParser parser = m_dialect.CreateParser(sql); try { var code = parser.ParseCommand(); if (!parser.Tokernizer.IsEof) { throw new ParseError("DAE-00294 EOF expected"); } string res = m_dialect.GenerateScript(code.GenerateSql, ReformatProps); m_editor.SetCodeText(res, true); } catch (Exception err) { Errors.Report(err); } } }
public override bool SaveAs() { string name = InputBox.Run(Texts.Get("s_enter_object_name"), "new_table"); if (name != null) { try { ISpecificObjectStructure newStructure = CreateStructure(new NameWithSchema(name)); if (m_conn.DatabaseCaps.ExecuteSql) { string sql = Dialect.GenerateScript(dmp => { dmp.CreateSpecificObject(newStructure); }); if (!SqlConfirmForm.Run(sql, Dialect)) { return(false); } } m_conn.CreateObject(newStructure); if (m_pars != null && m_pars.SavedCallback != null) { m_pars.SavedCallback(); } m_obj = m_conn.InvokeLoadSpecificObjectDetail(newStructure.ObjectType, newStructure.ObjectName); FillFromStructure(); UpdateTitle(); return(true); } catch (Exception err) { Errors.Report(err); } } return(false); }
public static string GenerateScript(this ISqlDialect dialect, Action <ISqlDumper> script) { return(dialect.GenerateScript(script, SqlFormatProperties.Default)); }