Variable Size Problem


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Variable Size Problem
# 1  
Old 09-17-2007
Variable Size Problem

Hello Everyone,

I am currently working with a DB2 (ver 8.1) table (Newly Created) and I am running a basic DB2 Select query into a variable. The field and it's size are VARCHAR(20). Since I need to pass the variable through some java I have noticed that when the results come back from the query there are extra spaces. Even if I use the RTRIM or LTRIM I still receive the spaces.

Is there a way to set a variable lenght before the results of a query are passed to it?

I would like to do the following,

Code:
variable1=`db2 -xn "length(rtrim(field1)) from Database"`
if (( variable1 == 16 ))
then
set $variable2 lenght to 16
fi
variable2=`db2 -xn "select LTRIM(RTRIM(field1)) from Database"`

Then I can pass $variable2 through the java.

I know it doesn't make much sense but it's what I need, hopefully.

thanks in advance...........Smilie

Last edited by Bob_Loblaw; 09-17-2007 at 04:36 PM..
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Large Variable content size caveats?

Hi, I wrote a shell script, which let me manage dns records through an api. The raw core-command looks like about this: output="$(curl -X GET https://mgt.myserver.de:8081/api/v1/servers/localhost/zones)"The output contains a list of all zones with all records and is about 800 Kilobytes... (9 Replies)
Discussion started by: stomp
9 Replies

2. Shell Programming and Scripting

Getting size of a variable

if i do the following: echo "hello, mr. sunshine" > /tmp/text.txt du -s /tmp/text.txt The text.txt file now contains "hello, mr. sunshine". So i did a du -s on the file to see how much space the text i inserted took. now, instead of writing "hello, mr. sunshine" to a text file on the... (5 Replies)
Discussion started by: SkySmart
5 Replies

3. UNIX for Advanced & Expert Users

size for sum variable limitation on awk

Hello first, truth been told, I'm not even close to be advanced user. I'm posting here because maybe my question is complicated enough to need your expert help I need to use awk (or nawk - I don't have gawk) to validate some files by computing the total sum for a large numeric variable. It... (1 Reply)
Discussion started by: cwitarsa
1 Replies

4. Shell Programming and Scripting

file size problem

Hi everyone can you people please help me in the problem below -bash-3.00$ ls -ltr abc abc.tar -rw-r--r-- 1 1hinaa2 17 Jan 17 14:09 abc -rw-r--r-- 1 1hinaa2 2048 Feb 17 07:03 abc.tar -rw-r--r-- 1 1hinaa2 135 Feb 17 07:03 abc.tar.gz why this strange... (2 Replies)
Discussion started by: aishsimplesweet
2 Replies

5. UNIX for Dummies Questions & Answers

File size problem

I'm working on a IBM PC Serveur 325. I have a sequential file with more than 800000 records. The size of that file is 136755200. I wrote a cobol program (RM cobol) to delete records. Now the file has 180000 records and the size still the same 136755200. What I need to do to decrease the size.... (3 Replies)
Discussion started by: royinfo
3 Replies

6. SCO

File size problem

I'm working on a IBM PC Serveur 325. I have a sequential file with more than 800000 records. The size of that file is 136755200. I wrote a cobol program (RM cobol) to delete records. Now the file has 180000 records and the size still the same 136755200. What I need to do to decrease the size.... (1 Reply)
Discussion started by: royinfo
1 Replies

7. UNIX for Dummies Questions & Answers

size of number variable in unix (awk)

Hi All, M writing a shell scripting n making use of awk. I am using a integer variable named size. When printing it's value, it is giving result as 4.34534e+10. Is there any way to declare variable of type LONG in awk or in shell scripting in general ? Regards, Abhishek Gera (3 Replies)
Discussion started by: AbhishekG
3 Replies

8. AIX

dev/rmt 0.1 block size is 0; variable; must be 1024 fixed.

Hi. After the shutdown for SWIFT Alliance Server, tape backup process will be done. Unfortunately, I encountered this error message when I performed the database tape backup. The error was "/dev/rmt 0.1 block size is 0; variable; must be 1024 fixed. Consider reconfiguration through 'chdev'... (2 Replies)
Discussion started by: MariaLuisa
2 Replies

9. AIX

Variable Testing for size

How do you test a variable size to know if it is empty or not? Thanks (4 Replies)
Discussion started by: jango
4 Replies

10. Shell Programming and Scripting

Max size of variable

What is the maximum amount of characters that you can have in a varible name in the ksh shell? (1 Reply)
Discussion started by: lesstjm
1 Replies
Login or Register to Ask a Question
DB2_FOREIGN_KEYS(3)							 1						       DB2_FOREIGN_KEYS(3)

db2_foreign_keys - Returns a result set listing the foreign keys for a table

SYNOPSIS
resource db2_foreign_keys (resource $connection, string $qualifier, string $schema, string $table-name) DESCRIPTION
Returns a result set listing the foreign keys for a table. PARAMETERS
o $connection - A valid connection to an IBM DB2, Cloudscape, or Apache Derby database. o $qualifier - A qualifier for DB2 databases running on OS/390 or z/OS servers. For other databases, pass NULL or an empty string. o $schema - The schema which contains the tables. If $schema is NULL, db2_foreign_keys(3) matches the schema for the current connection. o $table-name - The name of the table. RETURN VALUES
Returns a statement resource with a result set containing rows describing the foreign keys for the specified table. The result set is com- posed of the following columns: +--------------+---------------------------------------------------+ | Column name | | | | | | | Description | | | | +--------------+---------------------------------------------------+ | PKTABLE_CAT | | | | | | | Name of the catalog for the table containing the | | | primary key. The value is NULL if this table does | | | not have catalogs. | | | | |PKTABLE_SCHEM | | | | | | | Name of the schema for the table containing the | | | primary key. | | | | |PKTABLE_NAME | | | | | | | Name of the table containing the primary key. | | | | |PKCOLUMN_NAME | | | | | | | Name of the column containing the primary key. | | | | | FKTABLE_CAT | | | | | | | Name of the catalog for the table containing the | | | foreign key. The value is NULL if this table does | | | not have catalogs. | | | | |FKTABLE_SCHEM | | | | | | | Name of the schema for the table containing the | | | foreign key. | | | | |FKTABLE_NAME | | | | | | | Name of the table containing the foreign key. | | | | |FKCOLUMN_NAME | | | | | | | Name of the column containing the foreign key. | | | | | KEY_SEQ | | | | | | | 1-indexed position of the column in the key. | | | | | UPDATE_RULE | | | | | | | Integer value representing the action applied to | | | the foreign key when the SQL operation is UPDATE. | | | | | DELETE_RULE | | | | | | | Integer value representing the action applied to | | | the foreign key when the SQL operation is DELETE. | | | | | FK_NAME | | | | | | | The name of the foreign key. | | | | | PK_NAME | | | | | | | The name of the primary key. | | | | |DEFERRABILITY | | | | | | | An integer value representing whether the for- | | | eign key deferrability is SQL_INITIALLY_DEFERRED, | | | SQL_INITIALLY_IMMEDIATE, or SQL_NOT_DEFERRABLE. | | | | +--------------+---------------------------------------------------+ SEE ALSO
db2_column_privileges(3), db2_columns(3), db2_primary_keys(3), db2_procedure_columns(3), db2_procedures(3), db2_special_columns(3), db2_statistics(3), db2_table_privileges(3), db2_tables(3). PHP Documentation Group DB2_FOREIGN_KEYS(3)