Sponsored Content
Top Forums Shell Programming and Scripting add the output of a query to a variable to be used in another query Post 302300702 by hazno on Tuesday 24th of March 2009 08:52:49 PM
Old 03-24-2009
add the output of a query to a variable to be used in another query

I would like to use the result of a query in another query. How do I redirect/add the output to another variable?

PHP Code:
$result odbc_exec($connect$query);
while (
$row odbc_fetch_array($result)) {
        echo 
$row["host"],"\n";
}
odbc_close($connect);
?> 
This will output hostnames:

host1 host2 host3

I would like to add the output to the variable $hosts something like this:

$hosts = "host1,host2,host3"

I plan to use $host in another query further down in the script.

thanks & regards
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

How to store the sql query's output in a variable

Hi, My requirement is : We are calling an sql statement from a UNIX session, and fetching data into some variables from a table .. now we are unable to access these variables from outside the SQL part. Please let me know how can I achieve this. Can you please share a code snippet which... (4 Replies)
Discussion started by: venkatesh_sasi
4 Replies

2. UNIX for Dummies Questions & Answers

Redirect Query o/p to variable

Hi, I wanted to o/p the number of rows in a table to a variable in linux. How can i achieve this. I wrote the query and its settings like feedback, pagesize line size in a file and using this file as a parameter to the sqlplus command. now can i redirect the o/p of that query to a variable.... (2 Replies)
Discussion started by: Swapna173
2 Replies

3. Solaris

awk output query

Hi Everyone, When i issue command like ls -l | awk '/udtts/ {print $9}' =============================== I am getting output as udttsGEHLNAR.6864 udttsGEHLNAR.7921 udttsNARALAX.15415 udttsNARALAX.18016 But I want output after dot i.e like 6864 7921 15415 18016 (3 Replies)
Discussion started by: gehlnar
3 Replies

4. Shell Programming and Scripting

Query Oracle tables and return values to shell script that calls the query

Hi, I have a requirement as below which needs to be done viz UNIX shell script (1) I have to connect to an Oracle database (2) Exexute "SELECT field_status from table 1" query on one of the tables. (3) Based on the result that I get from point (2), I have to update another table in the... (6 Replies)
Discussion started by: balaeswari
6 Replies

5. Shell Programming and Scripting

How to use a variable in insert query?

My script contains as follows, VALUE=`sqlplus un/pwd <<EOF > OB.txt set pagesize 0 feedback off verify off heading off echo off select max(1) from table1; exit; EOF` insert into table2 values(1, 'The max value is $value',...); i need the value of VALUE to be inserted after 'The max... (2 Replies)
Discussion started by: savithavijay
2 Replies

6. Shell Programming and Scripting

Shell Script to execute Oracle query taking input from a file to form query

Hi, I need to query Oracle database for 100 users. I have these 100 users in a file. I need a shell script which would read this User file (one user at a time) & query database. For instance: USER CITY --------- ---------- A CITY_A B CITY_B C ... (2 Replies)
Discussion started by: DevendraG
2 Replies

7. UNIX for Dummies Questions & Answers

UNIX Query About wc -l output

I was performing the wc -l operation in one data file the result is less when i was giving -nu on the view of the file. while giving wc -l the count is 5023 after setting line numbers in view of file is giving 5024. Can anyone help on this.... (5 Replies)
Discussion started by: abhii
5 Replies

8. Shell Programming and Scripting

Getting variable from a query

Hi, I need to get a variable HMAX_TBL_ID and then use it in second select query. The first select statement returns few leading white spaces for ex : 12345 so when I run the script HMAX_TBL_ID does not return the "12345" , it returns blank. Please let me know what I am missing. ... (1 Reply)
Discussion started by: sandy162
1 Replies

9. Shell Programming and Scripting

How to pass variable to a query?

Hi All, How to pass date variable to a query? I have tried the below one , but it's not working. ost.ksh #!/bin/ksh v_date=$1 var=$(sqlplus -s $ORACON <<ENDOFSQL SELECT TO_DATE('$v_date','DD-MON-YYYY'),-1) FROM DUAL; exit; ENDOFSQL ) #End I have executed as below. (7 Replies)
Discussion started by: ROCK_PLSQL
7 Replies

10. Shell Programming and Scripting

How to Assign the Output of an SQL Query to a Variable?

Hi iam new to shell scripting how to declare variables as redshift query and I have to compare two counts by using if condition . ex:count=select count(*) from prd; select count(*) from prd; select count(*) from tag; can any one help me . Please use CODE tags when displaying... (1 Reply)
Discussion started by: sam526
1 Replies
ethers(4)						     Kernel Interfaces Manual							 ethers(4)

NAME
ethers - Database that maps Ethernet addresses to hostnames DESCRIPTION
The /etc/ethers file is used in conjunction with the reverse address resolution protocol daemon (rarpd) to map Ethernet addresses to host- names. It contains information about the known (48-bit) Ethernet addresses of hosts on the Internet. For each host on an Ethernet, a single line should be present in the file with the following information: Ethernet-address official-host-name Items are separated by one or more spaces or tabs. A number sign (#) indicates the beginning of a comment that extends to the end of line. The standard form for Ethernet addresses is: x:x:x:x:x:x The x is a hexadecimal number between 0 and ff, representing 1 byte. The address bytes are always in network order. Hostnames can contain any printable character other than a space, tab, newline, or number sign (#). Hostnames in the /etc/ethers file should correspond to the hostnames in the /etc/hosts file or to those provided by the name service. EXAMPLES
The following is a sample ethers file: 08:00:20:01:e5:1c host1 # Comments go here 08:00:20:01:d0:4c host2 # Comments go here 08:00:20:01:e0:1d host3 # Comments go here 08:00:20:00:c2:4e host4 # Comments go here RELATED INFORMATION
Commands: rarpd(8) Files: hosts(4), packetfilter(7) Routines: ethers(3) delim off ethers(4)
All times are GMT -4. The time now is 10:12 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy