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
Plucene::Search::BooleanQuery(3pm)			User Contributed Perl Documentation			Plucene::Search::BooleanQuery(3pm)

NAME
Plucene::Search::BooleanQuery - a boolean query SYNOPSIS
# isa Plucene::Search::Query $query->add(Plucene::Search::Query $query, $required, $prohibited); $query->normalize($norm); my @clauses = $query->clauses; my $sum_sq_weights = $query->sum_squared_weights($searcher); my $as_string = $query->to_string($field); DESCRIPTION
A query that matches documents matching boolean combinations of other queries, typically TermQuerys or PhraseQuery A boolean query represents a composite query that may contains subqueries of arbitrary nesting level and with composition rules such as 'and', 'or' or 'not'. Boolean queries are represented in Plucene API by instances of the BooleanQuery class. Each BooleanQuery object contains a list of subqueries that are linked using instances of the adaptor class BooleanClause. The subqueries may be of any Query type such as term query, phrase query and nested boolean queries. Each sub query of a boolean query has two binary qualifiers that controls how its super query is matched. These qualifiers are o prohibited - when this flag is set, the matching status of the subquery is negated such that the query is considered as a match only when the sub query does not match. o required - when this flag is set, the sub query is required to match (or not to match if its 'prohibited' flag is set) for the super query to match. This this is a necessary but not sufficient condition for the super query to match. METHODS
add $query->add(Plucene::Search::Query $query, $required, $prohibited); Adds a clause to a boolean query. Clauses may be: required which means that documents which do not match this sub-query will not match the boolean query; prohibited which means that documents which do match this sub-query will not match the boolean query; or neither, in which case matched documents are neither prohibited from nor required to match the sub-query. It is an error to specify a clause as both required and prohibited. add_clause $self->add_clause(Plucene::Search::BooleanClause $c); Adds an already-formed clause onto the query. clauses my @clauses = $query->clauses; sum_squared_weights my $sum_sq_weights = $query->sum_squared_weights($searcher); normalize $query->normalize($norm); to_string my $as_string = $query->to_string($field); perl v5.12.4 2011-08-14 Plucene::Search::BooleanQuery(3pm)
All times are GMT -4. The time now is 11:56 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy