Sponsored Content
Homework and Emergencies Homework & Coursework Questions UNIX- Database creating/viewing/updating assignment Post 302472391 by pludi on Wednesday 17th of November 2010 04:52:57 AM
Old 11-17-2010
Quick outline (pseudocode, no guarantee for correctness):
Code:
db=arg1
command=arg2

switch command:
    create:
        if exists db
            error
        if arg3 != ""
            echo arg3 > db
        else
            echo "Automobile Database" > db
        echo "New database created"
    add:
        make = arg3
        model = arg4
        year = arg5
        color = arg6

        if arg3 == ""
            ask make
        if arg4 == ""
            ask model
        if arg5 == ""
            ask year
        if arg6 == ""
            ask color
        if year < 1870 || year > 2020
            error
        echo "make, model, year, color" >> db
        echo "Successfully added a record to the database"
    view:
        switch arg3:
            max=$( wc -l db )
            all:
                cat db
            single:
                if arg4 > max
                    error
	        sed -ne "1p;arg4p" db
            range:
                if arg4 > max || arg5 > max || arg4 > arg5
                    error
	        sed -ne "1p;arg4,arg5p" db
    delete:
        switch arg3:
            max=$( wc -l db )
            all:
                sed -ie '2,$d' db
            single:
                if arg4 > max
                    error
	        sed -ie "arg4d" db
            range:
                if arg4 > max || arg5 > max || arg4 > arg5
                    error
	        sed -ie "arg4,arg5d" db
     *:
         show help

Useful reading:
Bash Beginners Guide
sed manpage
This User Gave Thanks to pludi For This Post:
 

7 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Updating and Creating Web pages wiht Unix

I am new to Unix and would like to update a website as well as add new content to the site but it must be done with UNIX. Can anyone give me some pointers as to what types of references are on the web or maybe even some basic commands? Thanks so much! (1 Reply)
Discussion started by: gsensebe
1 Replies

2. UNIX for Advanced & Expert Users

Creating database in shell, how?!

Hi, i'm newbie in Unix. How can i create my own database in unix shell? Not to create a database through shell to MySql, oracle etc, but to create a completely mine database system through shell. Please help me, give me directions, i'm desperate :( (1 Reply)
Discussion started by: vants
1 Replies

3. UNIX for Dummies Questions & Answers

Creating a table (graphic not database)

Hi, I want to create a table on our unix box that allows the user to tab through it and select certain option by putting an asterix or similair into it. e.g. -------------- |Start App | | |Stop App |*| etc... Can this be done using a script (never seen any graphics options in ksh, but... (2 Replies)
Discussion started by: dlam
2 Replies

4. UNIX for Dummies Questions & Answers

Updating a database

i've got a database setup that references user inputs to see if they are already inputted. What I am wanting to do is allow the user to update the database by typing "update: name" where name is someone already in the database. echo "Enter your name." read NAME location=`find . -name... (2 Replies)
Discussion started by: fufaso
2 Replies

5. Web Development

Updating Records in Mysql Database

so when i issue a command like the below: # mysql --pager=/usr/bin/less -u cactiman -p -e 'select * from data_input' cacti Enter password: ... (2 Replies)
Discussion started by: SkySmart
2 Replies

6. UNIX for Dummies Questions & Answers

Viewing XLSB file in Unix

Hello, Does anyone know how to view an XLSB file in unix? Thank you. (1 Reply)
Discussion started by: narachaid
1 Replies

7. UNIX for Advanced & Expert Users

Creating the script for updating or replacing the existing http.conf file

Hi I need some help with a task, i am an absolute newbie to any form of shell scripting and request guidance. I have been building a proxy server using the apache mod proxy currently my solution is working , but i need to automate the process , suppose if any changes need to be made on... (0 Replies)
Discussion started by: satej
0 Replies
AFQUERY(3)																AFQUERY(3)

NAME
afQuery, afQueryLong, afQueryDouble, afQueryPointer - query the capabilities of the Audio File Library SYNOPSIS
#include <audiofile.h> AUpvlist afQuery (int querytype, int arg1, int arg2, int arg3, int arg4); long afQueryLong (int querytype, int arg1, int arg2, int arg3, int arg4); double afQueryDouble (int querytype, int arg1, int arg2, int arg3, int arg4); void *afQueryPointer (int querytype, int arg1, int arg2, int arg3, int arg4); PARAMETERS
querytype can be one of the following: o AF_QUERYTYPE_FILEFMT o AF_QUERYTYPE_INST o AF_QUERYTYPE_INSTPARAM o AF_QUERYTYPE_COMPRESSION o AF_QUERYTYPE_COMPRESSIONPARAM o AF_QUERYTYPE_MISC o AF_QUERYTYPE_MARK o AF_QUERYTYPE_LOOP arg1, arg2, arg3, and arg4 are integer selectors whose meaning depends upon querytype. RETURN VALUE
Upon success, afQuery will return a non-null AUpvlist value. Upon failure, afQuery will return null while afQueryLong and afQueryDouble will return -1 and afQueryPointer will return null. Pointers representing character strings are owned by the Audio File Library and must not be freed; all other pointer values must be freed by the caller. DESCRIPTION
For AF_QUERYTYPE_FILEFMT, the following selectors are valid values for arg1: AF_QUERY_LABEL Request a short label string for the format (e.g., "aiff"). AF_QUERY_NAME Request a short name for the format (e.g., "MS RIFF WAVE"). AF_QUERY_DESC Request a descriptive name for the format (e.g., "Audio Interchange File Format"). AF_QUERY_IMPLEMENTED Request a boolean value indicating whether the format is implemented for reading and writing in the Audio File Library. AF_QUERY_ID_COUNT Request the total number of formats implemented. AF_QUERY_IDS Request an integer array of the id token values of all implemented file formats. AF_QUERY_COMPRESSION_TYPES Used with the selector AF_QUERY_VALUE_COUNT in arg2, this will return a long integer containing the number of compression schemes available for use within the format specified in arg3. Used with selector AF_QUERY_VALUES, it returns a pointer to an integer array containing the compression id values of the compression schemes supported by the format specified in arg3. AF_QUERY_SAMPLE_FORMATS Used with the selector AF_QUERY_DEFAULT in arg2, this will return the default sample format for the file format specified in arg3. AF_QUERY_SAMPLE_SIZES Used with selector AF_QUERY_DEFAULT in arg2, this will return the default sample width for the file format specified in arg3. For AF_QUERYTYPE_INST, the following selectors are valid for arg1: AF_QUERY_SUPPORTED Request a boolean value indicating whether the file format in arg2 supports instruments. AF_QUERY_MAX_NUMBER Request an integer value indicating the maximum number of instruments supported by the file format in arg2. For AF_QUERYTYPE_INSTPARAM, the following selectors are valid for arg1: AF_QUERY_SUPPORTED Request a boolean value indicating whether the file format in arg2 supports instrument parameters. AF_QUERY_ID_COUNT Request an integer value indicating the number of instrument parameters supported by the file format in arg2. AF_QUERY_IDS Request an integer array containing the instrument parameter values for the file format in arg2. AF_QUERY_TYPE For the file format in arg2, request the type of the instrument parameter in arg3. AF_QUERY_NAME For the file format in arg2, request the name of the instrument parameter in arg3. AF_QUERY_DEFAULT For the file format in arg2, request the default value of the instrument parameter in arg3. ERRORS
afQuery can produce the following errors: AF_BAD_QUERYTYPE The query type is unsupported. AF_BAD_QUERY The arguments to the query are bad. AUTHOR
Michael Pruett <michael@68k.org> Audio File Library 0.3.6 03/06/2013 AFQUERY(3)
All times are GMT -4. The time now is 11:59 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy