Chat now with support
Chat with Support

Toad for DB2 7.2 - Installation Guide

Add or Remove Application Code

You can easily add syntax for another development tool such as C# to the SQL statement in the Editor to paste it into the development tool's code. You can also remove any syntax specific to the code development tool from the SQL statement so you can execute it in Toad. The modified syntax is saved to the clipboard, leaving the original statement unchanged.

The following pre-defined syntax templates are included with Toad:

  • C#

  • C++

  • Delphi

  • Java

  • Perl

  • Visual Basic

Scenario

You have a query in Visual Basic to find all movies produced between 1990 and 2000. You need to remove all Visual Basic syntax so that you can run the query in your database.

Original Visual Basic Statement:

Dim SQL As String = _

"SELECT ""MOVIETITLE"".MOVIEID" 

" , ""MOVIETITLE"".TITLE"

" , ""MOVIECATEGORY"".CATEGORYNAME"

" , ""MOVIECATEGORY"".RENTALPRICE"

" , ""MOVIETITLE"".YEAR"

"FROM "

" DB2ADMIN.MOVIETITLE ""MOVIETITLE"" INNER JOIN"

" DB2ADMIN.MOVIECATEGORY ""MOVIECATEGORY"" ON (""MOVIETITLE"".CATEGORYID = ""MOVIECATEGORY"".CATEGORYID) INNER JOIN"

" DB2ADMIN.MOVIECOPY ""MOVIECOPY"" ON (""MOVIECOPY"".MOVIEID = ""MOVIETITLE"".MOVIEID) "

"WHERE (""MOVIETITLE"".YEAR BETWEEN '2000' AND '2007')";

Converted SQL Statement:

SELECT "MOVIETITLE".movieid, "MOVIETITLE".title, "MOVIECATEGORY".categoryname,

"MOVIECATEGORY".rentalprice, "MOVIETITLE".year       

FROM db2admin.movietitle "MOVIETITLE"        

INNER JOIN          

db2admin.moviecategory "MOVIECATEGORY"             

ON ("MOVIETITLE".categoryid = "MOVIECATEGORY".categoryid)          

INNER JOIN       

db2admin.moviecopy "MOVIECOPY"          

ON ("MOVIECOPY".movieid = "MOVIETITLE".movieid)       

WHERE ("MOVIETITLE".year BETWEEN '2000' AND '2007') 

To remove the Visual Basic code from your query

  1. Copy and paste the following code into Toad's Editor.

    Dim SQL As String = _

    "SELECT ""MOVIETITLE"".MOVIEID" 

    " , ""MOVIETITLE"".TITLE"

    " , ""MOVIECATEGORY"".CATEGORYNAME"

    " , ""MOVIECATEGORY"".RENTALPRICE"

    " , ""MOVIETITLE"".YEAR"

    "FROM "

    " DB2ADMIN.MOVIETITLE ""MOVIETITLE"" INNER JOIN"

    " DB2ADMIN.MOVIECATEGORY ""MOVIECATEGORY"" ON (""MOVIETITLE"".CATEGORYID = ""MOVIECATEGORY"".CATEGORYID) INNER JOIN"

    " DB2ADMIN.MOVIECOPY ""MOVIECOPY"" ON (""MOVIECOPY"".MOVIEID = ""MOVIETITLE"".MOVIEID) "

    "WHERE (""MOVIETITLE"".YEAR BETWEEN '2000' AND '2007')";

  2. Click on the Editor toolbar (ALT+D+R) to remove the Visual Basic code and copy the statement to the clipboard.  

  3. Paste the statement into a new Editor in Toad:

    SELECT "MOVIETITLE".movieid, "MOVIETITLE".title, "MOVIECATEGORY".categoryname,

    "MOVIECATEGORY".rentalprice, "MOVIETITLE".year       

    FROM db2admin.movietitle "MOVIETITLE"        

    INNER JOIN          

    db2admin.moviecategory "MOVIECATEGORY"             

    ON ("MOVIETITLE".categoryid = "MOVIECATEGORY".categoryid)          

    INNER JOIN       

    db2admin.moviecopy "MOVIECOPY"          

    ON ("MOVIECOPY".movieid = "MOVIETITLE".movieid)       

    WHERE ("MOVIETITLE".year BETWEEN '2000' AND '2007') 

    Note: Your original SQL statement is not modified when removing application code.  

To add application code

  1. Select the SQL statement you want to add application code to in the Editor.

  2. Click on the Editor toolbar (ALT+D+P) to copy the statement with the application code to the clipboard.

    Tip: You can select a different template or create a new template from the drop-down list beside the icon.

  3. Paste the statement into the other development tool.

    Note: Your original SQL statement is not modified when adding the application code.

 

Related Topics

Related Documents

The document was helpful.

Select Rating

I easily found the information I needed.

Select Rating