Using input variables Please use speaker notes for additional information!

Slides:



Advertisements
Similar presentations
Creating an Oracle Database Table Additional information is available in speaker notes!
Advertisements

Reports Using SQL Script Please check speaker notes for additional information!
Line Efficiency     Percentage Month Today’s Date
Group functions using SQL Additional information in speaker notes!
PL/SQL - Using IF statements Please use speaker notes for additional information!
More on IF statements Use speaker notes for additional information!
SQL Use of Functions Character functions Please use speaker notes for additional information!
SQL functions - numeric and date Speaker notes contain additional information!
Cursors in PL/SQL Includes cursor example and continuation of first cursor example Please use speaker notes for additional information!
More on variables with Oracle’s SQL*Plus As always, speaker notes will contain additional information!
1 Press Ctrl-A ©G Dear2009 – Not to be sold/Free to use Displaying Multiple Data Sets Stage 6 - Year 12 General Mathematic (HSC)
Neal Stublen Computer Memory (Simplified)  Remember, all programming decisions came down to a true or false evaluation  Consider.
More on views Please refer to speaker notes for additional information!
SQL and Conditions Speaker notes will provide additional information!
Variables When programming it is often necessary to store a value for use later on in the program. A variable is a label given to a location in memory.
Indexes in Oracle An Introduction Please check speaker notes for additional information!
Introduction to Oracle - SQL Additional information is available in speaker notes!
1. switch statement 2. “Nested” statements Conditionals, part 2 1.
Introduction to PL/SQL As usual, use speaker notes for additional information!
More SQL functions As usual,there is additional information in the speaker notes!
13 Arrays CE : Fundamental Programming Techniques June 161.
Jan 2016 Solar Lunar Data.

Introduction to Procedures
Q1 Jan Feb Mar ENTER TEXT HERE Notes
Please see speaker notes for additional information!

Project timeline # 3 Step # 3 is about x, y and z # 2
Average Monthly Temperature and Rainfall

Using SQL with Access I am adding queries to the stu table in SecondDB.accdb – a database that I created in class. SQL stands for structured query language.
2017 Jan Sun Mon Tue Wed Thu Fri Sat
Introduction to Views and Reports


Gantt Chart Enter Year Here Activities Jan Feb Mar Apr May Jun Jul Aug
Q1 Q2 Q3 Q4 PRODUCT ROADMAP TITLE Roadmap Tagline MILESTONE MILESTONE
Free PPT Diagrams : ALLPPT.com



Step 3 Step 2 Step 1 Put your text here Put your text here
MONTH CYCLE BEGINS CYCLE ENDS DUE TO FINANCE JUL /2/2015
Jan Sun Mon Tue Wed Thu Fri Sat
2009 TIMELINE PROJECT PLANNING 12 Months Example text Jan Feb March

JavaScript.

Electricity Cost and Use – FY 2016 and FY 2017

Text for section 1 1 Text for section 2 2 Text for section 3 3
Text for section 1 1 Text for section 2 2 Text for section 3 3
Text for section 1 1 Text for section 2 2 Text for section 3 3
Text for section 1 1 Text for section 2 2 Text for section 3 3
Q1 Q2 Q3 Q4 PRODUCT ROADMAP TITLE Roadmap Tagline MILESTONE MILESTONE
Free PPT Diagrams : ALLPPT.com


Text for section 1 1 Text for section 2 2 Text for section 3 3
Text for section 1 1 Text for section 2 2 Text for section 3 3
Text for section 1 1 Text for section 2 2 Text for section 3 3
Text for section 1 1 Text for section 2 2 Text for section 3 3
Text for section 1 1 Text for section 2 2 Text for section 3 3
Text for section 1 1 Text for section 2 2 Text for section 3 3
Project timeline # 3 Step # 3 is about x, y and z # 2
Using SQL with Access I create a database named
TIMELINE NAME OF PROJECT Today 2016 Jan Feb Mar Apr May Jun

2009 TIMELINE PROJECT PLANNING 12 Months Example text Jan Feb March
Q1 Q2 Q3 Q4 PRODUCT ROADMAP TITLE Roadmap Tagline MILESTONE MILESTONE
Presentation transcript:

Using input variables Please use speaker notes for additional information!

User input variables SQL> SELECT * 2 FROM first_pay 3 WHERE jobcode = &jobcode; Enter value for jobcode: 'CI' old 3: WHERE jobcode = &jobcode new 3: WHERE jobcode = 'CI' PAY_ NAME JO STARTDATE SALARY BONUS Linda Costa CI 15-JAN Richard Jones CI 30-OCT Donald Brown CI 05-NOV SQL> SELECT * 2 FROM first_pay; PAY_ NAME JO STARTDATE SALARY BONUS Linda Costa CI 15-JAN John Davidson IN 25-SEP Susan Ash AP 05-FEB Stephen York CM 03-JUL Richard Jones CI 30-OCT Joanne Brown IN 18-AUG Donald Brown CI 05-NOV Paula Adams IN 12-DEC An & in front a an undefined variable name will cause a prompt to the user asking for the contents of the variable. It will then respond with the old which is the variable name with the & in front and the new which is the value that was entered. Note that when I keyed in the jobcode of CI, I surrounded in with single quotes because it was a string variable. All the records with jobcode of CI are displayed.

SQL> SELECT * FROM first_pay WHERE jobcode = '&jobcode'; Enter value for jobcode: CI old 1: SELECT * FROM first_pay WHERE jobcode = '&jobcode' new 1: SELECT * FROM first_pay WHERE jobcode = 'CI' PAY_ NAME JO STARTDATE SALARY BONUS Linda Costa CI 15-JAN Richard Jones CI 30-OCT Donald Brown CI 05-NOV User input variables SQL> SELECT * 2 FROM first_pay; PAY_ NAME JO STARTDATE SALARY BONUS Linda Costa CI 15-JAN John Davidson IN 25-SEP Susan Ash AP 05-FEB Stephen York CM 03-JUL Richard Jones CI 30-OCT Joanne Brown IN 18-AUG Donald Brown CI 05-NOV Paula Adams IN 12-DEC In this example, the whole select is on one line so when the old and new come back the entire select is shown, not just the part that contains the prompt. NOTE: In this example the &jobcode is enclosed in single quotes within the select. Therefore, when the user enters the jobcode of CI, it does not have to be enclosed in quotes. Notice that when the new is shown, CI is enclosed in the necessary single quotes.

Using input variables SQL> SELECT * 2 FROM first_pay; PAY_ NAME JO STARTDATE SALARY BONUS Linda Costa CI 15-JAN John Davidson IN 25-SEP Susan Ash AP 05-FEB Stephen York CM 03-JUL Richard Jones CI 30-OCT Joanne Brown IN 18-AUG Donald Brown CI 05-NOV Paula Adams IN 12-DEC SQL> SELECT * 2 FROM first_pay 3 WHERE salary = &salary; Enter value for salary: old 3: WHERE salary = &salary new 3: WHERE salary = PAY_ NAME JO STARTDATE SALARY BONUS Richard Jones CI 30-OCT Salary is numeric so single quotes are not needed as shown in this example.

Using input variables SQL> SELECT * 2 FROM first_pay; PAY_ NAME JO STARTDATE SALARY BONUS Linda Costa CI 15-JAN John Davidson IN 25-SEP Susan Ash AP 05-FEB Stephen York CM 03-JUL Richard Jones CI 30-OCT Joanne Brown IN 18-AUG Donald Brown CI 05-NOV Paula Adams IN 12-DEC SQL> SELECT * 2 FROM first_pay 3 WHERE UPPER(name) = UPPER('&name'); Enter value for name: stephen york old 3: WHERE UPPER(name) = UPPER('&name') new 3: WHERE UPPER(name) = UPPER('stephen york') PAY_ NAME JO STARTDATE SALARY BONUS Stephen York CM 03-JUL In this example, the user enters the name without quotes using any combination of upper and lower case. The name will be converted to upper for the comparison. Notice the name is also enclosed in single quotes when the new is shown. The name on the table is also converted to upper case so that we will match upper case to upper case.

User input variables old 3: WHERE &condname new 3: WHERE jobcode = 'CI' NAME SALARY JO Linda Costa CI Richard Jones CI Donald Brown CI SQL> SELECT &col1_tosee, &col2_tosee, &col3_tosee 2 FROM &tablename 3 WHERE &condname; Enter value for col1_tosee: name Enter value for col2_tosee: salary Enter value for col3_tosee: jobcode old 1: SELECT &col1_tosee, &col2_tosee, &col3_tosee new 1: SELECT name, salary, jobcode Enter value for tablename: first_pay old 2: FROM &tablename new 2: FROM first_pay Enter value for condname: jobcode = 'CI' In this example, SELECT, FROM and WHERE are hard coded. All the other information comes from user input at the variable prompt.

Using input variables SQL> SELECT &selectinfo; Enter value for selectinfo: name, salary, jobcode FROM first_pay WHERE jobcode = 'CI' old 1: SELECT &selectinfo new 1: SELECT name, salary, jobcode FROM first_pay WHERE jobcode = 'CI' NAME SALARY JO Linda Costa CI Richard Jones CI Donald Brown CI

Using input variables SQL> SELECT name, salary, &&jobentry 2 FROM first_pay 3 WHERE &&jobentry = 'CI'; Enter value for jobentry: jobcode old 1: SELECT name, salary, &&jobentry new 1: SELECT name, salary, jobcode old 3: WHERE &&jobentry = 'CI' new 3: WHERE jobcode = 'CI' NAME SALARY JO Linda Costa CI Richard Jones CI Donald Brown CI SQL> SELECT name, salary, &&jobentry 2 FROM first_pay 3 WHERE &&jobentry = 'CI'; old 1: SELECT name, salary, &&jobentry new 1: SELECT name, salary, jobcode old 3: WHERE &&jobentry = 'CI' new 3: WHERE jobcode = 'CI' NAME SALARY JO Linda Costa CI Richard Jones CI Donald Brown CI SQL> UNDEFINE jobentry; The use of && means that the user does not have to reenter the information. It is stored in a reusable variable. Note that the first time this SELECT was executed the prompt Enter value for jobentry came up and the user entered jobcode. Note that the second time the SELECT was execute the prompt did not appear and the SELECT got executed automatically using the reusable variable. To clear a reusable variable, use UNDEFINE followed by the name of the reusable variable.