Entering SQL

You can enter a SQL statement in four ways:

Pasting SQL

You can paste SELECT, INSERT, UPDATE, and DELETE statements to the view. Depending on which kind of statement you want to paste, PowerBuilder displays dialog boxes that guide you through painting the full statement.

StepsTo paste a SQL statement to the workspace:

  1. Click the Paste SQL button in the PainterBar, or select Paste Special>SQL from the Edit or pop-up menu.

    The SQL Statement Type dialog box displays, listing the types of SQL statements you can use.

  2. Double-click the appropriate icon to select the statement type.

    The Select Table dialog box displays.

  3. Select the table(s) you will reference in the SQL statement.

    You go to the Select, Insert, Update, or Delete painter, depending on the type of SQL statement you are pasting. The Insert, Update, and Delete painters are similar to the Select painter, but only the appropriate tabs display in the SQL toolbox at the bottom of the workspace.

    For more information about the Select painter, see “Selecting a data source”.

  4. Do one of the following:

  5. When you have finished painting the SQL statement, click the Return button in the PainterBar in the Select, Insert, Update, or Delete painter.

    You return to the Database painter with the SQL statement pasted into the ISQL view.

Typing SQL

Rather than paste, you can simply type one or more SQL statements directly in the ISQL view.

You can enter most statements supported by your DBMS, including statements you can paint as well as statements you cannot paint, such as a database stored procedure or CREATE TRIGGER statement. You cannot enter certain statements that could destabilize the PowerBuilder development environment. These include the SET statement and the USE database statement.

NoteSybase Adaptive Server Enterprise stored procedures When you use the Database painter to execute a Sybase Adaptive Server Enterprise system stored procedure, you must start the syntax with the keyword EXEC or EXECUTE. For example, enter EXEC SP_LOCK. You cannot execute the stored procedure simply by entering its name.

Importing SQL from a text file

You can import SQL that has been saved in a text file into the Database painter.

StepsTo read SQL from a file:

  1. Put the insertion point where you want to insert the SQL.

  2. Select Paste Special>From File from the Edit or pop-up menu.

  3. Select the file containing the SQL, and click OK.

Dragging a procedure or function from the Objects view

From the tree view in the Objects view, you can select an existing procedure or function that contains a SQL statement you want to enter, and drag it to the Interactive SQL view.