Sponsored Content
Top Forums Shell Programming and Scripting Foreach loop with two variables Post 302950658 by vgersh99 on Monday 27th of July 2015 05:45:56 PM
Old 07-27-2015
does it have to be csh/tcsh?
Code:
#!/bin/ksh
awk '
   FNR==NR {f1[$0];next} 
  {f2[$0]}
END {
   for (f1I in f1)
     for (f2I in f2)
       print "sql " f1I " -u" f2I " <script.sql>> script.log"
}' /local/hd3/dba/tools/build_db_scripts/dbs /local/hd3/dba/tools/build_db_scripts/dbas > /local/hd3/dba/tools/build_db_scripts/run_this

chmod 777 /local/hd3/dba/tools/build_db_scripts/run_this

This User Gave Thanks to vgersh99 For This Post:
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

foreach loop question

Hello, I am new at this forum so please bare with me on this. Within a given directory, I have a list of files in which in each file, I would like to do a substitution. I would like to substitute the string mlcl to mll in each file using the foreach command. I dont quite get how to do that. If... (7 Replies)
Discussion started by: clipski
7 Replies

2. Shell Programming and Scripting

Foreach loop

What am I doing wrong with this foreach loop? foreach var ($argv) @sum = $sum + $var (4 Replies)
Discussion started by: haze21
4 Replies

3. Shell Programming and Scripting

foreach loop

Hi Guys, I have a loop which uses a wildcard i.e. foreach f (*) but when I execute the tcsh file in unix then it gives me an error ->>>>>>>foreach: words not parenthesized<<<<<<<<<<- Any help. (1 Reply)
Discussion started by: abch624
1 Replies

4. Shell Programming and Scripting

foreach loop + 2 variables

In a foreach loop, is it possible for the loop to go through 2 arguments instead of one i.e. instead of foreach i (do stuff for i), we have foreach i j(do stuff for i; do stuff for j) I am working under BASH and TCSH shell environments cheers (3 Replies)
Discussion started by: JamesGoh
3 Replies

5. Shell Programming and Scripting

foreach loop

Hi everyone Does anyone know what is wrong with this script. i keep getting errors foreach filename (`cat testing1`) set string=$filename set depth=`echo "$string" echo $depth end the error is the following testing: line 1: syntax error near unexpected token `(' testing: line 1:... (3 Replies)
Discussion started by: ROOZ
3 Replies

6. UNIX for Advanced & Expert Users

Problem with foreach loop

Hi All, Is there any problem with the below 'foreach' loop? foreach risk_factor ($(cat "$rf_list")) where "rf_list=$SCRIPT/Utility/rflist.txt " I'm wondering, it is throwing below error message: syntax error at line 34: `(' unexpected Any idea/suggestions ? Thanks in advance /... (7 Replies)
Discussion started by: ganapati
7 Replies

7. Shell Programming and Scripting

Using sed with a foreach loop

So I am back again beating my head against the wall with a shell script and getting a headache! I want to change each year in a file (1980, 1981, 1982, 1983, etc.) to the same year followed by a tab. The input is "blah blah (1980) blah blah". I want to get "blah blah (1980 ) blah blah".... (2 Replies)
Discussion started by: Peggy White
2 Replies

8. UNIX for Dummies Questions & Answers

Using the Foreach loop, Needing help

I am trying to make a script for my Counter-Strike: Source servers. What i am wanting it to do is for it to restart each server, the only way i can think of doing this in through for each. Years what i have at the moment. server_start() { START=`ps x | grep SCREEN | grep $SRV | cut -d '?' -f... (5 Replies)
Discussion started by: grahamn95
5 Replies

9. Shell Programming and Scripting

foreach loop problem

Dear all, I wrote a script to download files and move files in directories according to their name. Now here is the problem: Both p101 and p360 data download successfully, but when I move them according to the year and month, only p101 data can be placed at the right location, p360,... (1 Reply)
Discussion started by: handsonzhao
1 Replies

10. UNIX for Dummies Questions & Answers

foreach loop in csh

Hi everyone I'm new to unix and encountered a small problem i couldnt find out a reason why it doesn't work..please help.. in my csh script when i tried to use the foreach loop like this: foreach x ( ls ) echo $x end when i tried to run it, it printed out 'ls' to the std out instead of... (3 Replies)
Discussion started by: ymc1g11
3 Replies
CUBRID_BIND(3)								 1							    CUBRID_BIND(3)

cubrid_bind - Bind variables to a prepared statement as parameters

SYNOPSIS
bool cubrid_bind (resource $req_identifier, int $bind_index, mixed $bind_value, [string $bind_value_type]) DESCRIPTION
The cubrid_bind(3) function is used to bind values to a corresponding named or question mark placeholder in the SQL statement that was passed to cubrid_prepare(3). If $bind_value_type is not given, string will be the default. Note If the type of data to be bound is BLOB/CLOB, CUBRID will try to map the data as a PHP stream. If the actually bind value type is not stream, CUBRID will convert it to string, and use it as the full path and file name of a file on the client filesystem. If the type of data to be bound explicitly is ENUM, the $bind_value argument should be the enum element which is in string format. In CUBRID shard envrioment, the $bind_value_type must be included in the cubrid_bind function. The following table shows the types of substitute values. CUBRID Bind Date Types +----------------------+------------------------+---+ | Support | | | | | | | | | Bind Type | | | | | | | | Corresponding SQL Type | | | | | | +----------------------+------------------------+---+ | Supported | | | | | | | | | STRING | | | | | | | | CHAR, VARCHAR | | | | | | | | | | | |T{ NCHAR | | | | | | | | | NCHAR, NVARCHAR | | | | | | | | | | | |T{ BIT | | | | | | | | | BIT, VARBIT | | | | | | | | | | ||T{ NUMERIC or NUMBER | | | | | | | | | SHORT, INT, NUMERIC | | | | | | | | | | | |T{ FLOAT | | | | | | | | | FLOAT | | | | | | | | | | | |T{ DOUBLE | | | | | | | | | DOUBLE | | | | | | | | | | | |T{ TIME | | | | | | | | | TIME | | | | | | | | | | | |T{ DATE | | | | | | | | | DATE | | | | | | | | | | | |T{ TIMESTAMP | | | | | | | | | TIMESTAMP | | | | | | | | | | | |T{ OBJECT | | | | | | | | | OBJECT | | | | | | | | | | | |T{ ENUM | | | | | | | | | ENUM | | | | | | | | | | | |T{ BLOB | | | | | | | | | BLOB | | | | | | | | | | | |T{ CLOB | | | | | | | | | CLOB | | | | | | | | | | | |T{ NULL | | | | | | | | | NULL | | | | | | | Not supported | | | | | | | | | SET | | | | | | | | SET | | | | | | | | | | | |T{ MULTISET | | | | | | | | | MULTISET | | | | | | | | | | | |T{ SEQUENCE | | | | | | | | | SEQUENCE | | | | | | +----------------------+------------------------+---+ PARAMETERS
o $req_identifier -Request identifier as a result of cubrid_prepare(3). o $bind_index -Location of binding parameters. It starts with 1. o $bind_value -Actual value for binding. o $bind_value_type -A type of the value to bind. (It is omitted by default. Thus, the system internally uses string by default. However, you need to specify the exact type of the value as an argument when they are NCHAR, BIT, or BLOB/CLOB). RETURN VALUES
TRUE, when process is successful. FALSE, when process is unsuccessful. CHANGELOG
+--------+--------------------------------------+ |Version | | | | | | | Description | | | | +--------+--------------------------------------+ | 8.3.1 | | | | | | | Added BLOB/CLOB data types support. | | | | +--------+--------------------------------------+ EXAMPLES
Example #1 cubrid_bind(3) example <?php $conn = cubrid_connect("localhost", 33000, "demodb", "dba"); $result = cubrid_execute($conn, "SELECT code FROM event WHERE sports='Basketball' and gender='M'"); $row = cubrid_fetch_array($result, CUBRID_ASSOC); $event_code = $row["code"]; cubrid_close_request($result); $game_req = cubrid_prepare($conn, "SELECT athlete_code FROM game WHERE host_year=1992 and event_code=? and nation_code='USA'"); cubrid_bind($game_req, 1, $event_code, "number"); cubrid_execute($game_req); printf("--- Dream Team (1992 United States men's Olympic basketball team) --- "); while ($athlete_code = cubrid_fetch_array($game_req, CUBRID_NUM)) { $athlete_req = cubrid_prepare($conn, "SELECT name FROM athlete WHERE code=? AND nation_code='USA' AND event='Basketball' AND gender='M'"); cubrid_bind($athlete_req, 1, $athlete_code[0], "number"); cubrid_execute($athlete_req); $row = cubrid_fetch_assoc($athlete_req); printf("%s ", $row["name"]); } cubrid_close_request($game_req); cubrid_close_request($athlete_req); cubrid_disconnect($conn); ?> The above example will output: --- Dream Team (1992 United States men's Olympic basketball team) --- Stockton John Robinson David Pippen Scottie Mullin C. Malone Karl Laettner C. Jordan Michael Johnson Earvin Ewing Patrick Drexler Clyde Bird Larry Barkley Charles Example #2 cubrid_bind(3) BLOB/CLOB example <?php $con = cubrid_connect("localhost", 33000, "demodb", "dba", ""); if ($con) { cubrid_execute($con,"DROP TABLE if exists php_cubrid_lob_test"); cubrid_execute($con,"CREATE TABLE php_cubrid_lob_test (doc_content CLOB)"); $sql = "INSERT INTO php_cubrid_lob_test(doc_content) VALUES(?)"; $req = cubrid_prepare($con, $sql); $fp = fopen("book.txt", "rb"); cubrid_bind($req, 1, $fp, "clob"); cubrid_execute($req); } ?> Example #3 cubrid_bind(3) BLOB/CLOB example <?php $con = cubrid_connect("localhost", 33000, "demodb", "dba", ""); if ($con) { cubrid_execute($con,"DROP TABLE if exists php_cubrid_lob_test"); cubrid_execute($con,"CREATE TABLE php_cubrid_lob_test (image BLOB)"); $sql = "INSERT INTO php_cubrid_lob_test(image) VALUES(?)"; $req = cubrid_prepare($con, $sql); cubrid_bind($req, 1, "cubrid_logo.png", "blob"); cubrid_execute($req); } ?> SEE ALSO
cubrid_execute(3), cubrid_prepare(3). PHP Documentation Group CUBRID_BIND(3)
All times are GMT -4. The time now is 05:31 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy