Skip to main content

Notifications

Drop a custom view using SQLBuilder in D365FO

Hi,

In this post will present the code to drop a view using SQLBuilder classes in D365FO. For demo purpose, created a view by name SampleView and deleted it.

  •  Created a table by name SampleTable and loaded some data into it.
  •  Created a view by name SampleView using SampleTable.
  •  Dropped the view SampleView from the SQL Server database using SQLBuilder classes of D365FO.
  •  Note: CG_DropViewUsingSQLBuilder is a runnable class and the view that was dropped is a custom one.

class CG_DropViewUsingSQLBuilder
{       
    /// <summary>
    /// Runs the class with the specified arguments.
    /// </summary>
    /// <param name = "_args">The specified arguments.</param>
    public static void main(Args _args)
    {
        SQLBuilderViewNavn  viewId = viewstr(SampleView);
        boolean             isViewDropped;

        isViewDropped = SQLBuilderView::dropView(viewId);

        if (isViewDropped == true)
        {
            info(strFmt("View %1 is dropped", viewId));
        }
        else
        {
            info(strFmt("View %1 is not dropped", viewId));
        }
    }

}

Output: InfoMessage

Regards,

Chaitanya Golla

Comments

*This post is locked for comments