SQL Editor is a part of dataPro and provides useful editing functions, including cut, copy, paste, and dragging operations. User can execute any SQL command that is supported by the current Database type.
For example
"Select * from Companies".
The result of the select query will be shown as a formatted table.
To execute a command user should type the SQL statement in the Edit window and either hit the Ctrl and Enter buttons on the keyboard, click on the Execute (Run) button or select Execute menu item from the SQL popup menu.
If there are more than one Sql query in the edit window the editor will execute the query based on the cursor position.
User can force the program to execute any SQL statement by highlighting it.
User can save the entire content of the Editor window to the file or load the text file by using File popup menu commands.
Drag and drop:
One of the useful dataPro functions is the drag and drop feature. User can drag table or column name from database tree view window to the Editor and drop in at any point. By using drag and drop capabilities of dataPro it is very easy to construct complex SQL queries by using the mouse and very little typing.
SQL Editor also allows you to enter full SELECT or INSERT statement for the particular table just by using popup menu commands Paste SELECT or Paste INSERT.
Retrieving "Create" statements:
To retrieve "Create" SQL statement for the database object user should highlight it in the database browser pane and click on Edit menu item Retrieve Create SQL. The "Create" SQL code will be placed in the Editor window.
Running SQL scripts:
To run SQL script load it contents in the Editor and hit Run Script.
Warning:
dataPro may give errors when running scripts containing stored procedures, triggers or functions while using default terminator ";" or no terminators at all.
To avoid this problem use SET_TERMINATOR command to change default terminator. For example:
SET_TERMINATOR |
DROP TRIGGER IF EXISTS Transaction_DT|
Create TRIGGER Transaction_DT BEFORE UPDATE ON Transaction_Master
FOR EACH ROW BEGIN
set NEW.Updated = now();
END;
|