Presentation is loading. Please wait.

Presentation is loading. Please wait.

Data Virtualization Tutorial: Introduction to SQL Script

Similar presentations


Presentation on theme: "Data Virtualization Tutorial: Introduction to SQL Script"— Presentation transcript:

1 Data Virtualization Tutorial: Introduction to SQL Script
Hello, and welcome to the Tutorial Series for Cisco Information Server, or CIS. In this tutorial, we introduce SQL Script.

2 For more details… Resources: Additional information: Archives
Documentation Training Resources: Archives Data files Tutorial Document Note that Tutorials are NOT meant to be comprehensive training modules. Instead, they demonstrate a very basic use case that can be built quickly and easily. However, the Data Virtualization Knowledge Base contains additional information that will help you learn more and go deeper. Additional resources in the Knowledge Base include: <CLICK> Resources used to build the tutorial, such as Data Virtualization Archive files, data source files, and a document version of this tutorial… <CLICK> … and additional information, including documentation and training materials.

3 Agenda What is it and why does it matter? How-to Summary
Here is our agenda. We begin by defining SQL Script and outlining its importance in Data Virtualization projects. Next we demonstrate the basics of SQL Script. Finally, we summarize the contents of this tutorial.

4 Agenda What is it and why does it matter? How-to Summary
Let’s begin by discussing what SQL Script is, and why it is important for Data Virtualization.

5 What is it? SQL Script ANSI-SQL-compliant Scripting Language
Enables procedural logic, including Conditional execution Looping Pipelining Exception handling Etc. SQL Script is CIS’s ANSI-SQL-compliant scripting language. It enables procedural logic for data integration, including conditional execution, looping, pipelining, exception handling, and many other features.

6 Why does it matter? SQL Script Procedural logic
Parameter-driven processing Calls to system procedures and custom procedures Exception handling and logging SQL Script is important in an enormous range of Data Virtualization use cases. It enables users to write procedural logic for scenarios that are difficult to handle in declarative SQL. It enables parameter-driven processing. SQL Script procedures can make calls to other procedures, including system utility procedures and custom procedures written in Java. SQL Script enables exception handling and logging, which can be important in many Data Virtualization projects.

7 Agenda What is it and why does it matter? How-to Summary
Next, let’s walk through a very basic demo of SQL Script.

8 Here is the business problem…
SQL Script is an extremely full-featured and flexible feature that can be used in countless use cases. We can only scratch the surface of SQL Script in this brief introductory tutorial. We’ll walk through a very simple use case that shows a few basic features of SQL Script. After using this tutorial, you will be ready to learn more about SQL Script’s many capabilities. In this use case, we want to make data available from the CIS System database, which is published as a virtual database in Composite Data Services. This database contains the CIS metadata repository, as well as a number of tables that hold operational data. <CLICK> Specifically, we want to write a script that returns data from the table SYS_REQUESTS, which records information about individual data requests made by users. However, we have some special security requirements. <CLICK> The user named Admin can retrieve data for any user… <CLICK> … but other users can only retrieve their own data. We’ll use SQL Script to solve this problem.

9 Before you begin… You can easily build this SQL Script from scratch. However, the Knowledge Base also contains a Data Virtualization Archive File with this script. <CLICK> If you want to follow this demo exactly, create users named Admin, and Another-Admin.

10 Compose the Script Now we’re ready to begin. Create a folder for your work. <CLICK> Right-click the folder and select New SQL Script. <CLICK> Name the script… <CLICK> … and a script skeleton appears in the editor.

11 Compose the Script First, define the script’s parameters. Parameters are placed between the parentheses that immediately follow the name of the script. <CLICK> We’ll use an Input parameter that holds the name of the user for whom we want to retrieve Request data. <CLICK> We’ll return an Output parameter that is a Cursor containing the returned data.

12 Compose the Script The script’s statements are placed between the BEGIN and END statements. <CLICK> We declare a work area we’ll be using… <CLICK> An Exception object… <CLICK> … and another work area for building the message we want to associate with the Exception. Notice that statements must end with a semi-colon.

13 Compose the Script One reason that SQL Script is so powerful is that scripts can call other procedures that are written in SQL Script or Java. CIS delivers a large library of procedures we can call. <CLICK> We need to verify the caller’s identity, so we’ll make use of a CIS procedure called GetProperty, which is found in the util folder of the procedure library. <CLICK> Open the procedure, and the Info tab will tell you how to use it. <CLICK> Pass in the constant CURRENT_USER_NAME and the procedure will return the current user.

14 Compose the Script Here we make the call in our script. Notice that the fully-qualified name of the called procedure is lib/util/GetProperty. Simply drag the procedure into your script from the Studio Explorer, and the fully-qualified name will appear. When we execute this line, the user’s actual name will be placed in the work area field userActualIdentity, which we defined earlier.

15 Compose the Script Now we can use an IF statement to build the main logic we need. If this user is named Admin… <CLICK> We’ll query the SYS_REQUESTS table for any user. <CLICK> Again, note that you can drag in the SYS_REQUESTS table and the fully-qualified name will appear.

16 Compose the Script Our IF statement continues with this ELSEIF clause. The user’s name is NOT Admin, so we make sure that the requested information is for the actual caller… <CLICK> … and filter the SYS_REQUESTS rows appropriately.

17 Compose the Script Our IF statement concludes with an ELSE clause. If a user other than Admin requests someone else’s data, we format a message and raise an exception. <CLICK> Finally, here is the exception-handler block. This block calls two other useful procedures that are delivered with CIS. <CLICK> The Print procedure writes to the console. <CLICK> The Log procedure writes an informational message to the CIS Server Log file.

18 Test the Script Now we’re ready to test the script. Log in to Studio as the Admin user. This is the user who can access the data for any user. <CLICK> Open the script and click Execute on the editor toolbar. <CLICK> Enter Admin as the input parameter and click OK. <CLICK> The script returns Admin’s own requests.

19 Test the Script Now run the script again, and change the parameter to a different user. <CLICK> Because the actual user is admin, the script will return data for any specified user.

20 Test the Script Now log in as a different user.
<CLICK> Run the procedure and ask for data matching your current user name. <CLICK> Since the names match, the data is returned.

21 Test the Script Now run the script again, and ask for data that does NOT match your user name. Since you are not Admin, this is not permitted. <CLICK> No data is returned. <CLICK> The Console tab shows the expected error message. <CLICK> Check the end of the cs_server.log file in the logs directory of the CIS Installation Folder. Our Exception block has logged the issue correctly. We have used procedural logic to return a SQL cursor based on an input parameter, and used several library functions to perform security checking and logging. Our demo is complete.

22 Agenda What is it and why does it matter? How-to Summary
Let’s summarize what we have seen in this tutorial.

23 Summary: Definition SQL Script ANSI-SQL-compliant Scripting Language
Enables procedural logic, including Conditional execution Looping Pipelining Exception handling Etc. SQL Script is CIS’s ANSI-SQL-compliant scripting language. It enables procedural logic for data integration, including conditional execution, looping, pipelining, exception handling, and many other features.

24 Summary: Benefits SQL Script Procedural logic
Parameter-driven processing Calls to system procedures and custom procedures Exception handling and logging SQL Script is important in an enormous range of Data Virtualization use cases. It enables users to write procedural logic for scenarios that are difficult to handle in declarative SQL. It enables parameter-driven processing. SQL Script procedures can make calls to other procedures, including system utility procedures and custom procedures written in Java. SQL Script enables exception handling and logging, which can be important in many Data Virtualization projects.

25 Summary: Key Take-aways
SQL Script Scripts can call other resources, including: Other Scripts Java Procedures Packaged Queries CIS Procedure Library As you work with SQL Script in CIS, keep these key take-aways in mind. You can use scripts to build very sophisticated applications, since scripts can be used to call many other CIS resources, including other scripts, Java procedures, Packaged Queries, and the wide range of functionality available in the library of procedures delivered with CIS.

26 Summary: What’s next? Use your knowledge to implement procedural logic
Leverage your knowledge to take advantage of the CIS Procedure Library Learn advanced SQL Script capabilities Documented in CIS Reference Manual After completing this tutorial, you are ready to begin using SQL Script in your Data Virtualization projects. Use your learning from this tutorial to implement all types of procedural logic. Leverage your knowledge to explore the capabilities available in the CIS Procedure Library. Learn advanced SQL Script features. The CIS Reference Guide is your best source for advanced SQL Script. Thank you.

27


Download ppt "Data Virtualization Tutorial: Introduction to SQL Script"

Similar presentations


Ads by Google