Sponsored Content
Top Forums Shell Programming and Scripting How to trim space in output variable ? Post 74498 by RishiPahuja on Friday 10th of June 2005 06:35:35 AM
Old 06-10-2005
MySQL

V_RUNID=`echo $V_RUNID | tr -d ' '`
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

how to merge two variable in one variable with space between them?

Dear all I had two separate variable. Now i want to make them merge into one new variable with space between them. Kindly suggest me. var1=dec 15 var2=10 i want var3=dec 15 10 My main aim is as below: op of date command: >date >Sat Dec 15 10:17:35 IST 2007 i want only Dec... (2 Replies)
Discussion started by: jaydeep_sadaria
2 Replies

2. Programming

How to trim the white space around a string in C program

I am coding a C program to read a plain text file. There are a lot of blank fields or a string with white spaces. I want to know is there such a function called trim() in C to clean the white space around a string? Or some other way can do this efficiently? Thanks. (18 Replies)
Discussion started by: hxm1303
18 Replies

3. Shell Programming and Scripting

Using Variable With Space In It?

Hey , I'm new to Bash and am having trouble with writing a script. I have a variable and want to use it to create a tar file, but, I am having problems. Can anyone tell me what I'm doing wrong? filestr=`date "+%y-%m-%d %H.%M.%S"`.tar tar -cvf $filestr test.txt So, basically,... (3 Replies)
Discussion started by: beefeater267
3 Replies

4. Shell Programming and Scripting

How to trim variable in linux?

Hi guys , I m developing a script in linux.but getting confused about how would i trim my variable if there is any space. for example. I m storing value in a variable named MACHINE_NAME if MACHINE_NAME=<space><space><space>ABCDF<space><space> How would i trim it to have my MACHINE_NAME=ABCDF... (5 Replies)
Discussion started by: pinga123
5 Replies

5. Shell Programming and Scripting

trim spaces in unix for variable

HI Guys I have written a script using awk to split a file based on some identifier and renaming the file based on two values from specific length. ts a fixed width file. When I am trying to fetch the values a = substr($0,11,10) b = substr($0,21,5); i am getting spaces in a and b values .... (6 Replies)
Discussion started by: manish8484
6 Replies

6. Shell Programming and Scripting

awk - trim white space from a field / variable

Hi, Consider the data (FS = |): 1| England |end 2| New Zealand |end 3|Australia|end 4| Some Made Up Country |end 5| West Indies|end I want the output to be (i.e. without the leading and trailing white space from $2) England New Zealand Australia Some Made Up Country West... (4 Replies)
Discussion started by: Storms
4 Replies

7. Shell Programming and Scripting

Trim sed output & assign to variable

Hi, I have the following command that parses an xml file to read a node <port>'s value. Hoever the output comes with spaces. My requirement is to trim the spaces around the value and assign to a variable. sed -n 's|<port>\(.*\)</port>|\1|p' ../cfg.xml How do I go about it? (6 Replies)
Discussion started by: sai2013
6 Replies

8. UNIX for Advanced & Expert Users

Passing variable as input & storing output in other variable

I have a below syntax its working fine... var12=$(ps -ef | grep apache | awk '{print $2,$4}') Im getting expected output as below: printf "%b\n" "${VAR12}" dell 123 dell 456 dell 457 Now I wrote a while loop.. the output of VAR12 should be passed as input parameters to while loop and results... (5 Replies)
Discussion started by: sam@sam
5 Replies

9. Shell Programming and Scripting

Trim Space

In Shell, I have output of a unix command as test1 test2015 but I want it as test1 test2015 can anyone help me out. Use code tags, thanks. (3 Replies)
Discussion started by: OscarS
3 Replies

10. Shell Programming and Scripting

Gawk --- produce the output in pattern space instead of END space

hi, I'm trying to calculate IP addresses and their respective calls to our apache Server. The standard format of the input is HOST IP DATE/TIME - - "GET/POST reuest" "User Agent" HOST IP DATE/TIME - - "GET/POST reuest" "User Agent" HOST IP DATE/TIME - - "GET/POST reuest" "User Agent" HOST... (2 Replies)
Discussion started by: busyboy
2 Replies
DB2_BIND_PARAM(3)							 1							 DB2_BIND_PARAM(3)

db2_bind_param - Binds a PHP variable to an SQL statement parameter

SYNOPSIS
bool db2_bind_param (resource $stmt, int $parameter-number, string $variable-name, [int $parameter-type], [int $data-type], [int $precision = -1], [int $scale]) DESCRIPTION
Binds a PHP variable to an SQL statement parameter in a statement resource returned by db2_prepare(3). This function gives you more con- trol over the parameter type, data type, precision, and scale for the parameter than simply passing the variable as part of the optional input array to db2_execute(3). PARAMETERS
o $stmt - A prepared statement returned from db2_prepare(3). o $parameter-number - Specifies the 1-indexed position of the parameter in the prepared statement. o $variable-name - A string specifying the name of the PHP variable to bind to the parameter specified by $parameter-number. o $parameter-type - A constant specifying whether the PHP variable should be bound to the SQL parameter as an input parameter ( DB2_PARAM_IN), an output parameter ( DB2_PARAM_OUT), or as a parameter that accepts input and returns output ( DB2_PARAM_INOUT). To avoid memory overhead, you can also specify DB2_PARAM_FILE to bind the PHP variable to the name of a file that contains large object (BLOB, CLOB, or DBCLOB) data. o $data-type - A constant specifying the SQL data type that the PHP variable should be bound as: one of DB2_BINARY, DB2_CHAR, DB2_DOUBLE, or DB2_LONG . o $precision - Specifies the precision with which the variable should be bound to the database. This parameter can also be used for retrieving XML output values from stored procedures. A non-negative value specifies the maximum size of the XML data that will be retrieved from the database. If this parameter is not used, a default of 1MB will be assumed for retrieving the XML output value from the stored procedure. o $scale - Specifies the scale with which the variable should be bound to the database. RETURN VALUES
Returns TRUE on success or FALSE on failure. EXAMPLES
Example #1 Binding PHP variables to a prepared statement The SQL statement in the following example uses two input parameters in the WHERE clause. We call db2_bind_param(3) to bind two PHP variables to the corresponding SQL parameters. Notice that the PHP variables do not have to be declared or assigned before the call to db2_bind_param(3); in the example, $lower_limit is assigned a value before the call to db2_bind_param(3), but $upper_limit is assigned a value after the call to db2_bind_param(3). The variables must be bound and, for parameters that accept input, must have any value assigned, before calling db2_execute(3). <?php $sql = 'SELECT name, breed, weight FROM animals WHERE weight > ? AND weight < ?'; $conn = db2_connect($database, $user, $password); $stmt = db2_prepare($conn, $sql); // We can declare the variable before calling db2_bind_param() $lower_limit = 1; db2_bind_param($stmt, 1, "lower_limit", DB2_PARAM_IN); db2_bind_param($stmt, 2, "upper_limit", DB2_PARAM_IN); // We can also declare the variable after calling db2_bind_param() $upper_limit = 15.0; if (db2_execute($stmt)) { while ($row = db2_fetch_array($stmt)) { print "{$row[0]}, {$row[1]}, {$row[2]} "; } } ?> The above example will output: Pook, cat, 3.2 Rickety Ride, goat, 9.7 Peaches, dog, 12.3 Example #2 Calling stored procedures with IN and OUT parameters The stored procedure match_animal in the following example accepts three different parameters: o an input (IN) parameter that accepts the name of the first animal as input o an input-output (INOUT) parameter that accepts the name of the second animal as input and returns the string TRUE if an animal in the database matches that name o an output (OUT) parameter that returns the sum of the weight of the two identified animals In addition, the stored procedure returns a result set consisting of the animals listed in alphabetic order starting at the animal corresponding to the input value of the first parameter and ending at the animal corresponding to the input value of the second parameter. <?php $sql = 'CALL match_animal(?, ?, ?)'; $conn = db2_connect($database, $user, $password); $stmt = db2_prepare($conn, $sql); $name = "Peaches"; $second_name = "Rickety Ride"; $weight = 0; db2_bind_param($stmt, 1, "name", DB2_PARAM_IN); db2_bind_param($stmt, 2, "second_name", DB2_PARAM_INOUT); db2_bind_param($stmt, 3, "weight", DB2_PARAM_OUT); print "Values of bound parameters _before_ CALL: "; print " 1: {$name} 2: {$second_name} 3: {$weight} "; if (db2_execute($stmt)) { print "Values of bound parameters _after_ CALL: "; print " 1: {$name} 2: {$second_name} 3: {$weight} "; print "Results: "; while ($row = db2_fetch_array($stmt)) { print " {$row[0]}, {$row[1]}, {$row[2]} "; } } ?> The above example will output: Values of bound parameters _before_ CALL: 1: Peaches 2: Rickety Ride 3: 0 Values of bound parameters _after_ CALL: 1: Peaches 2: TRUE 3: 22 Results: Peaches, dog, 12.3 Pook, cat, 3.2 Rickety Ride, goat, 9.7 Example #3 Inserting a binary large object (BLOB) directly from a file The data for large objects are typically stored in files, such as XML documents or audio files. Rather than reading an entire file into a PHP variable, and then binding that PHP variable into an SQL statement, you can avoid some memory overhead by binding the file directly to the input parameter of your SQL statement. The following example demonstrates how to bind a file directly into a BLOB column. <?php $stmt = db2_prepare($conn, "INSERT INTO animal_pictures(picture) VALUES (?)"); $picture = "/opt/albums/spook/grooming.jpg"; $rc = db2_bind_param($stmt, 1, "picture", DB2_PARAM_FILE); $rc = db2_execute($stmt); ?> SEE ALSO
db2_execute(3), db2_prepare(3). PHP Documentation Group DB2_BIND_PARAM(3)
All times are GMT -4. The time now is 05:54 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy