9 1 DBM Databases CGI/Perl Programming By Diane Zak.

Slides:



Advertisements
Similar presentations
How to Create a Local Collection
Advertisements

Introduction to PHP MIS 3501, Fall 2014 Jeremy Shafer
The Web Warrior Guide to Web Design Technologies
Guide to Oracle10G1 Introduction To Forms Builder Chapter 5.
Chapter 12: ADO.NET and ASP.NET Programming with Microsoft Visual Basic.NET, Second Edition.
A Guide to Oracle9i1 Introduction To Forms Builder Chapter 5.
Guide To UNIX Using Linux Third Edition
ASP.NET Programming with C# and SQL Server First Edition Chapter 8 Manipulating SQL Server Databases with ASP.NET.
DBM Databases Please use speaker notes for additional information!
 2004 Prentice Hall, Inc. All rights reserved. Chapter 25 – Perl and CGI (Common Gateway Interface) Outline 25.1 Introduction 25.2 Perl 25.3 String Processing.
Chapter 9 Using Perl for CGI Programming. Computation is required to support sophisticated web applications Computation can be done by the server or the.
8 Chapter Eight Server-side Scripts. 8 Chapter Objectives Create dynamic Web pages that retrieve and display database data using Active Server Pages Process.
NETWORK CENTRIC COMPUTING (With included EMBEDDED SYSTEMS)
© Yanbu University College YANBU UNIVERSITY COLLEGE Management Science Department © Yanbu University College Module 6:WEB SERVER AND SERVER SIDE SCRPTING,
A Guide to SQL, Eighth Edition Chapter Three Creating Tables.
Chapter 5 Java Script And Forms JavaScript, Third Edition.
Programming with Microsoft Visual Basic 2012 Chapter 13: Working with Access Databases and LINQ.
ASP.NET Programming with C# and SQL Server First Edition
Chapter 2 Basic SQL SELECT Statements Oracle 10g: SQL.
PHP Programming with MySQL Slide 8-1 CHAPTER 8 Working with Databases and MySQL.
Student Learning Environment on the World Wide Web l CGI-programming in Perl for the connection of databases over the Internet. l Web authoring using Frontpage.
Nael Alian Introduction to PHP
2 1 Sending Data Using a Hyperlink CGI/Perl Programming By Diane Zak.
Microsoft Access Get a green book. Page AC 2 Define Access Define database.
Exploring Office Grauer and Barber 1 Introduction to Access: What is a Database?(Wk1)
9 Chapter Nine Compiled Web Server Programs. 9 Chapter Objectives Learn about Common Gateway Interface (CGI) Create CGI programs that generate dynamic.
USING PERL FOR CGI PROGRAMMING
Chapter 6 Generating Form Letters, Mailing Labels, and a Directory
Web Server Administration Chapter 7 Installing and Testing a Programming Environment.
Exploring Microsoft Access 97 Chapter 1 Introduction to Microsoft Access: What Is A Database? Office graphic copyright by Microsoft Corp.
Word Lesson 12 Creating Mail Merge Documents Microsoft Office 2010 Advanced Cable / Morrison 1.
15/10/20151 PHP & MySQL 'Slide materials are based on W3Schools PHP tutorial, 'PHP website 'MySQL website.
JavaScript, Fourth Edition Chapter 5 Validating Form Data with JavaScript.
4 1 Array and Hash Variables CGI/Perl Programming By Diane Zak.
Chapter 8 Collecting Data with Forms. Chapter 8 Lessons Introduction 1.Plan and create a form 2.Edit and format a form 3.Work with form objects 4.Test.
11 1 Cookies CGI/Perl Programming By Diane Zak Objectives In this chapter, you will: Learn the difference between temporary and persistent cookies.
Copyright © 2010 Certification Partners, LLC -- All Rights Reserved Perl Specialist.
Creating PHPs to Insert, Update, and Delete Data CS 320.
To access our web services, go to……. Click on Customer Login.
Introduction to PHP Advanced Database System Lab no.1.
1 Committed to Shaping the Next Generation of IT Experts. Chapter 1- Introduction to Access: What is a Database? Robert Grauer and Maryann Barber Exploring.
3 1 Sending Data Using an Online Form CGI/Perl Programming By Diane Zak.
7 1 User-Defined Functions CGI/Perl Programming By Diane Zak.
Exploring Microsoft Access Chapter 1 Introduction to Microsoft Access: What Is A Database?
Introduction to JavaScript CS101 Introduction to Computing.
5 1 Data Files CGI/Perl Programming By Diane Zak.
XP Tutorial 8 Adding Interactivity with ActionScript.
10 1 Hidden Fields and CGI/Perl Programming By Diane Zak.
Copyright © 2003 ProsoftTraining. All rights reserved. Perl Fundamentals.
13-1 Sequential File Processing Chapter Chapter Contents Overview of Sequential File Processing Sequential File Updating - Creating a New Master.
BlackBerry Applications using Microsoft Visual Studio and Database Handling.
Microsoft FrontPage 2003 Illustrated Complete Integrating a Database with a Web Site.
Lesson 13 Databases Unit 2—Using the Computer. Computer Concepts BASICS - 22 Objectives Define the purpose and function of database software. Identify.
 2001 Prentice Hall, Inc. All rights reserved. Chapter 7 - Introduction to Common Gateway Interface (CGI) Outline 7.1Introduction 7.2A Simple HTTP Transaction.
8 Chapter Eight Server-side Scripts. 8 Chapter Objectives Create dynamic Web pages that retrieve and display database data using Active Server Pages Process.
Clearly Visual Basic: Programming with Visual Basic 2008 Chapter 25 I’m Suffering from Information Overload.
Chapter 24 I’m Suffering from Information Overload (Access Databases) Clearly Visual Basic: Programming with Visual Basic nd Edition.
Form Processing Week Four. Form Processing Concepts The principal tool used to process Web forms stored on UNIX servers is a CGI (Common Gateway Interface)
XP New Perspectives on Microsoft Windows XP Tutorial 5 1 Microsoft Windows XP Bringing the World Wide Web to the Desktop Tutorial 5.
ECMM6018 Enterprise Networking For Electronic Commerce Tutorial 6 CGI/Perl and databases.
1 Chapter 2 Basic SQL SELECT Statements. 2 Chapter Objectives Distinguish between an RDBMS and an ORDBMS Identify keywords, mandatory clauses, and optional.
Notes: **A Row is considered one Record. **A Column is a Field. A Database is…  an organized set of stored information usually on one topic  a collection.
FILES AND EXCEPTIONS Topics Introduction to File Input and Output Using Loops to Process Files Processing Records Exceptions.
XP Chapter 1 Succeeding in Business with Microsoft Office Access 2003: A Problem-Solving Approach 1 Level 2 Objectives: Understanding and Creating Table.
ASP.NET Programming with C# and SQL Server First Edition
Introduction to Programming the WWW I
PHP Introduction.
ISC440: Web Programming 2 Server-side Scripting PHP 3
Intro to PHP.
Presentation transcript:

9 1 DBM Databases CGI/Perl Programming By Diane Zak

9 2 Objectives In this chapter, you will: Create and open a DBM database Add a record to a DBM database Modify and delete a record in a DBM database Determine whether a DBM database contains a specific key

9 3 Objectives In this chapter, you will: Close a DBM database Concatenate strings Create a “here” document

9 4 Introduction Most businesses store information in databases: –Inventory –Employee information –Customer information Databases can be created with a database software package: –Oracle –Microsoft Access –Sybase –MySQL

9 5 Introduction The Perl DBI module is used with the appropriate DBD file to manipulate the database –DBI = Database Interface –DBD = Database Driver One of the Perl DBM modules can also be used to create and manipulate a DBM database –DBM = Database Management

9 6 The Jeffrey Sikes Band Form

9 7 Planning and Coding the Jeffrey Sikes Band Script – is used to display a blank space in a Web page

9 8 Creating and Opening a DBM Database Examples of Perl DBM modules: –ODBM_File.pm –NBDM_File.pm –SDBM_File.pm Will concentrate on SDBM because it is included in the standard Perl distribution for Windows and UNIX To use the module, need to include the line: –use SDBM_File;

9 9 Creating and Opening a DBM Database Good programming practice to plan a database before creating it –List the fields to include in each record –Identify the primary key in the list A unique identifier of a record In this mailing list database – address A primary key can be more than one field DBM modules store records on disk using a key/value format – like a hash –key – data entered in each record’s primary key field –value – data entered in the remaining fields in the record

9 10 Creating and Opening a DBM Database The tie function is used to create and open a DBM database on disk –The die function can be used to display a message and exit a script if the tie function fails

9 11 Creating and Opening a DBM Database

9 12 Adding and Modifying a Record in a DBM Database A record is added to a DBM database by adding a key/value pair to the hash tied to the database A record is modified by modifying the value corresponding to an existing key in the database Must make changes only through the tied hash –Cannot make changes directly to the DBM database

9 13 Adding and Modifying a Record in a DBM Database

9 14 Closing a DBM Database Use the untie function to close a DBM database –Remove the tie that binds the database to the hash –Syntax: untie (hash) –Example: untie (%mail)

9 15 The Jeffrey Sikes Band Script – add function

9 16 Determining if a Specific Key is in a DBM Database The exists function can be used to determine if a specific key is contained in a DBM database –Syntax: exists ($hash {key}) –Example: if (exists ($mail {$ }))

9 17 Deleting a Record From a DBM Database The delete function is used to delete a record from a DBM database –Syntax: delete ($hash {key}) –Example: delete ($mail {$ })

9 18 Concatenating Strings The concatenation operator (.) is used to connect multiple strings

9 19 The Jeffrey Sikes Band Script – remove function

9 20 Completed band.cgi Script

9 21 Creating a “here” Document Most CGI scripts contain many print statements specifically to output HTML code A “here” document allows you to use one print statement for a block of HTML code Syntax: print <<label; HTML instructions label

9 22 Creating a “here” Document Example of a “here” document: #create Web page print <<endHtml; The Jeffrey Sikes Band The Jeffrey Sikes Band Thank you, $name. We will send the monthly newsletter to $ . endHtml

9 23 Creating a “here” Document If the label of a “here” document is multiple words, you need to put single or double quotation marks around label. –If label is enclosed in single quotation marks, variable interpolation will not occur.

9 24 Summary A database is a collection of data that is stored in a disk file and organized so that its contents can be easily accessed, managed, and updated. One of the Perl DBM (Database Management) modules can be used to create and manipulate a DBM database: –SDBM_File.pm, ODBM_File.pm, NDBM_File.pm. The data contained in a DBM database is stored on disk using a key/value format. The tie function can be used to create and open a DBM database. –Syntax: tie (hash, module, filename, flag, mode) flag – O_CREAT, O_RDONLY, O_WRONLY, O_RDWR are defined in the Fcntl module mode – 0666 if O_CREAT flag, otherwise 0

9 25 Summary The tie function can be used to create and open a DBM database. –Syntax: tie (hash, module, filename, flag, mode) flag – O_CREAT, O_RDONLY, O_WRONLY, O_RDWR are defined in the Fcntl module mode – 0666 if O_CREAT flag, otherwise 0 The die function can be used to display a message and exit a script if tie function fails. To add or modify a record in a DBM database: –Syntax: $hash{key} = value; key – data in record’s primary key field value = data contained in remaining fields in record The untie function can be used to close a DBM database. –Syntax: untie (hash)

9 26 Summary The SDBM_File module creates 2 files for the database: filename.dir and filename.pag The exists function can be used to determine if a key is in a DBM database. –Syntax: exists ($hash {key}) The delete function can be used to remove a record from a DBM database. –Syntax: delete ($hash {key}) String concatenation operator is the period (.) A “here” document can be used to send HTML code to the browser