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
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
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
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
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
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
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
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
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
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
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
LEARN ABOUT PHP
cubrid_unbuffered_query
CUBRID_UNBUFFERED_QUERY(3) 1 CUBRID_UNBUFFERED_QUERY(3)
cubrid_unbuffered_query - Perform a query without fetching the results into memory
SYNOPSIS
resource cubrid_unbuffered_query (string $query, [resource $conn_identifier])
DESCRIPTION
This function performs a query without waiting for that all query results have been complete. It will return when the results are being
generated.
PARAMETERS
o $query
-A SQL query.
o $conn_identifier
-The CUBRID connection. If the connection identifier is not specified, the last connection opened by cubrid_connect(3) is assumed.
RETURN VALUES
For SELECT, SHOW, DESCRIBE or EXPLAIN statements returns a request identifier resource on success.
For other type of SQL statements, UPDATE, DELETE, DROP, etc, returns TRUE on success.
FALSE on failure.
NOTES
Note
The benefits of cubrid_unbuffered_query(3) come at a cost: you cannot use cubrid_num_rows(3) and cubrid_data_seek(3) on a result
set returned from cubrid_unbuffered_query(3).
EXAMPLES
Example #1
cubrid_unbuffered_query(3) example
<?php
$link = cubrid_connect("localhost", 30000, "demodb", "dba", "");
if (!$link)
{
die('Could not connect.');
}
$query = "select * from code";
$result = cubrid_unbuffered_query($query, $link);
while ($row = cubrid_fetch($result))
{
var_dump($row);
}
cubrid_close_request($result);
cubrid_disconnect($link);
?>
PHP Documentation Group CUBRID_UNBUFFERED_QUERY(3)