Checking columns in SQL, comparing user input and sizes.


 
Thread Tools Search this Thread
Top Forums Programming Checking columns in SQL, comparing user input and sizes.
# 1  
Old 11-01-2010
Checking columns in SQL, comparing user input and sizes.

I'm writing a KSH shell script that's using SQL though DB2.

If I have a table defined and populated
Code:
db2 "create table tb(num int,letter char(4))"
db2 "insert into tb values(111,a)
db2 "insert into tb values(112,b)
db2 "insert into tb values(111,c)

How can I check if a letter user input in my shell script matches a particular number?
So
Code:
echo "enter ltr"
read ltr
db2 "select letter from tb where number = 111"
if [ltr =  ...   '* how do i check if the letter the user input is one of those that matches for 111?

Also, how can I figure out the biggest number value in the table and insert it into a variable in the shell script?
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Checking the user input in perl for characters and length

My question is basically as the title says. How can I check a user inputted string is only certain characters long (for example, 3 characters long) and how do I check a user inputted string only contains certain characters (for example, it should only contain the characters 'u', 'a', 'g', and 'c')... (4 Replies)
Discussion started by: Eric1
4 Replies

2. Shell Programming and Scripting

Split a non delimited file into columns depending on user input

I would like some advice on some code. I want to write a small script that will take an input file of this format 111222233334444555666661112222AAAA 2222333445556612323244455445454545 2334556345643534505435345353453453 (and so on) It will be called as : script inputfile X (where X is... (5 Replies)
Discussion started by: onlyforbopi
5 Replies

3. Shell Programming and Scripting

Request: How to Parse dynamic SQL query to pad extra columns to match the fixed number of columns

Hello All, I have a requirement in which i will be given a sql query as input in a file with dynamic number of columns. For example some times i will get 5 columns, some times 8 columns etc up to 20 columns. So my requirement is to generate a output query which will have 20 columns all the... (7 Replies)
Discussion started by: vikas_trl
7 Replies

4. Shell Programming and Scripting

Comparing file sizes

Hello, I need to compare the size of a file to what it's size was 20min ago. So far my outline script is:ls -ls /home > filesizeafter.txt compare filesizeafter.txt filesizebefore.txt > filesizechange.txt if /home filesizechange.txt > 100 { email root; } ls -ls /home >... (2 Replies)
Discussion started by: chyurdan
2 Replies

5. Shell Programming and Scripting

TCSH user input error checking

This was taken down recently because it appeared to be homework, but it isn't. It's for a script I am working on at work. Thanks for the help. How do you check that user inputs (arguments 1 and 2) are both numbers and are at least 5 digits in length? (2 Replies)
Discussion started by: thibodc
2 Replies

6. UNIX for Dummies Questions & Answers

Checking for file Sizes

Hi , I have some 10 files where i need to check the size of each and every file...if the size of the file is 0...I shud send out an email mentioning which file is actually of 0KB size.. Pls help (13 Replies)
Discussion started by: saggiboy10
13 Replies

7. Shell Programming and Scripting

Comparing sizes in percentages of 2 files in bash

Hi guys, I hope you can enlight me with a script I'm doing for Solaris 10. Script goes like this: #!/usr/bin/bash fechahoy=`perl /export/home/info/John/fechamod.pl` fechayer=`perl /export/home/info/John/fecha.pl` echo $fechahoy echo $fechayer DAT1=`ssh ivt@blahblah ls -la... (1 Reply)
Discussion started by: sr00t
1 Replies

8. Shell Programming and Scripting

SQL PLUS Command 'ACCEPT' is not waiting for user input with sh shell script

Dear All, The sqlplus 'Accept' command is not waiting for user input when I include the command within a shell script. Note: The 'Accept' command is working fine if I execute it in a SQLPLUS Prompt. Please fins the below sample script which i tried. SCRIPT: -------- #!... (4 Replies)
Discussion started by: little_wonder
4 Replies

9. UNIX for Dummies Questions & Answers

Checking file sizes in script

Hi, I'm trying to check a filesize within a script and then excute a relevant action. An example is below: if then rm $filename rm $filename2 elif then rm $filename2 fi Basically if $filename2 has a filesize of 0 then I want both files to be removed, but... (6 Replies)
Discussion started by: chris01010
6 Replies

10. Shell Programming and Scripting

Script for checking and reporting file sizes in a directory.

Hi, Need help for a Script for checking and reporting database file sizes in a directory. Request you to please give your valuable inputs. Thanks a lot in advance. Best Regards, Marconi (1 Reply)
Discussion started by: marconi
1 Replies
Login or Register to Ask a Question
DB2_CLIENT_INFO(3)							 1							DB2_CLIENT_INFO(3)

db2_client_info - Returns an object with properties that describe the DB2 database client

SYNOPSIS
object db2_client_info (resource $connection) DESCRIPTION
This function returns an object with read-only properties that return information about the DB2 database client. The following table lists the DB2 client properties: DB2 client properties +---------------------+--------------------------------------+---+ | Property name | | | | | | | | | Return type | | | | | | | | Description | | | | | | +---------------------+--------------------------------------+---+ | APPL_CODEPAGE | | | | | | | | | int | | | | | | | | The application code page. | | | | | | | CONN_CODEPAGE | | | | | | | | | int | | | | | | | | The code page for the current con- | | | | nection. | | | | | | | DATA_SOURCE_NAME | | | | | | | | | string | | | | | | | | The data source name (DSN) used to | | | | create the current connection to the | | | | database. | | | | | | | DRIVER_NAME | | | | | | | | | string | | | | | | | | The name of the library that imple- | | | | ments the DB2 Call Level Interface | | | | (CLI) specification. | | | | | | | DRIVER_ODBC_VER | | | | | | | | | string | | | | | | | | The version of ODBC that the DB2 | | | | client supports. This returns a | | | | string "MM.mm" where $MM is the | | | | major version and $mm is the minor | | | | version. The DB2 client always | | | | returns "03.51". | | | | | | | DRIVER_VER | | | | | | | | | string | | | | | | | | The version of the client, in the | | | | form of a string "MM.mm.uuuu" where | | | | $MM is the major version, $mm is the | | | | minor version, and $uuuu is the | | | | update. For example, "08.02.0001" | | | | represents major version 8, minor | | | | version 2, update 1. | | | | | | |ODBC_SQL_CONFORMANCE | | | | | | | | | string | | | | | | | | The level of ODBC SQL grammar sup- | | | | ported by the client: | | | | | | | | o MINIMUM | | | | - Supports the mini- | | | | mum ODBC SQL gram- | | | | mar. | | | | | | | | o CORE | | | | - Supports the core | | | | ODBC SQL grammar. | | | | | | | | o EXTENDED | | | | - Supports extended | | | | ODBC SQL grammar. | | | | | | | ODBC_VER | | | | | | | | | string | | | | | | | | The version of ODBC that the ODBC | | | | driver manager supports. This | | | | returns a string "MM.mm.rrrr" where | | | | $MM is the major version, $mm is the | | | | minor version, and $rrrr is the | | | | release. The DB2 client always | | | | returns "03.01.0000". | | | | | | +---------------------+--------------------------------------+---+ PARAMETERS
o $connection - Specifies an active DB2 client connection. RETURN VALUES
Returns an object on a successful call. Returns FALSE on failure. EXAMPLES
Example #1 A db2_client_info(3) example To retrieve information about the client, you must pass a valid database connection resource to db2_client_info(3). <?php $conn = db2_connect( 'SAMPLE', 'db2inst1', 'ibmdb2' ); $client = db2_client_info( $conn ); if ($client) { echo "DRIVER_NAME: "; var_dump( $client->DRIVER_NAME ); echo "DRIVER_VER: "; var_dump( $client->DRIVER_VER ); echo "DATA_SOURCE_NAME: "; var_dump( $client->DATA_SOURCE_NAME ); echo "DRIVER_ODBC_VER: "; var_dump( $client->DRIVER_ODBC_VER ); echo "ODBC_VER: "; var_dump( $client->ODBC_VER ); echo "ODBC_SQL_CONFORMANCE: "; var_dump( $client->ODBC_SQL_CONFORMANCE ); echo "APPL_CODEPAGE: "; var_dump( $client->APPL_CODEPAGE ); echo "CONN_CODEPAGE: "; var_dump( $client->CONN_CODEPAGE ); } else { echo "Error retrieving client information. Perhaps your database connection was invalid."; } db2_close($conn); ?> The above example will output: DRIVER_NAME: string(8) "libdb2.a" DRIVER_VER: string(10) "08.02.0001" DATA_SOURCE_NAME: string(6) "SAMPLE" DRIVER_ODBC_VER: string(5) "03.51" ODBC_VER: string(10) "03.01.0000" ODBC_SQL_CONFORMANCE: string(8) "EXTENDED" APPL_CODEPAGE: int(819) CONN_CODEPAGE: int(819) SEE ALSO
db2_server_info(3). PHP Documentation Group DB2_CLIENT_INFO(3)