Sponsored Content
Full Discussion: Query in CENTOS
Special Forums UNIX and Linux Applications Query in CENTOS Post 302889099 by shobana praveen on Wednesday 19th of February 2014 04:48:29 AM
Old 02-19-2014
Thank you

---------- Post updated at 04:48 AM ---------- Previous update was at 12:12 AM ----------

Thanks for your reply............it was helpful.

But I have another query like how to fetch only particular data from database (MYSQL)(for ex: user and msg) for every 2hrs and convert into an .xls format.

How to write script for the below query?
Code:
$arrAcc="SELECT accountID FROM account";
$Accountid=$DB->Execute($arrAcc);

for($i=0;$i<=length($Accountid);$i++)
{
$arrDevice="SELECT deviceID FROM device";
$Deviceid=$DB->Execute($arrDevice); 
for($j=0;$j<=length($Deviceid);$j++)
{
$arrEvent="SELECT * FROM eventdata WHERE accountID=$i and deviceID=$j";
$EventData=$DB->Execute($arrEvent);  
}
$j++;
}
$i++;

Thanks,
Shobana

Last edited by Franklin52; 02-19-2014 at 06:33 AM.. Reason: Please use code tags
 

6 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

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? $result = odbc_exec($connect, $query); while ($row = odbc_fetch_array($result)) { echo $row,"\n"; } odbc_close($connect); ?> This will output hostnames: host1... (0 Replies)
Discussion started by: hazno
0 Replies

2. 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

3. 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

4. UNIX Benchmarks

2-cpu centos 5.7

BYTE UNIX Benchmarks (Version 3.11) System -- Linux centos1 2.6.18-274.17.1.el5xen #1 SMP Tue Jan 10 18:06:37 EST 2012 x86_64 x86_64 x86_64 GNU/Linux Start Benchmark Run: Fri Mar 2 19:42:41 EST 2012 2 interactive users. Dhrystone 2 without register variables 6929864.9 lps (10 secs,... (0 Replies)
Discussion started by: ppchu99
0 Replies

5. Red Hat

How to Upgrade Centos 5.7 using Centos 5.8 ISO image on Vmware workstation

Dear Linux Experts, On my windows 7 desktop with the help of Vmware workstation (Version 7.1), created virtual machine and installed Centos 5.7 successfully using ISO image. Query : Is this possible to upgrade the Centos 5.7 using Centos 5.8 ISO image to Centos version 5.8?.. if yes kindly... (2 Replies)
Discussion started by: Ananthcn
2 Replies

6. Red Hat

RH V Centos

Hi, I have built out a new virtual production environment (VMWare, HA enabled, VMotion... all the bells & whistles) using RHEL5 VM's. I have got another ESX host that I plan to use as a pre-prod environment. To save some costs on RH subs I was thinking about installing this environment... (5 Replies)
Discussion started by: Duffs22
5 Replies
DECLARE(7)							   SQL Commands 							DECLARE(7)

NAME
DECLARE - define a cursor SYNOPSIS
DECLARE cursorname [ BINARY ] [ INSENSITIVE ] [ SCROLL ] CURSOR FOR query [ FOR { READ ONLY | UPDATE [ OF column [, ...] ] ] INPUTS cursorname The name of the cursor to be used in subsequent FETCH operations. BINARY Causes the cursor to fetch data in binary rather than in text format. INSENSITIVE SQL92 keyword indicating that data retrieved from the cursor should be unaffected by updates from other processes or cursors. Since cursor operations occur within transactions in PostgreSQL this is always the case. This keyword has no effect. SCROLL SQL92 keyword indicating that data may be retrieved in multiple rows per FETCH operation. Since this is allowed at all times by PostgreSQL this keyword has no effect. query An SQL query which will provide the rows to be governed by the cursor. Refer to the SELECT statement for further information about valid arguments. READ ONLY SQL92 keyword indicating that the cursor will be used in a read only mode. Since this is the only cursor access mode available in PostgreSQL this keyword has no effect. UPDATE SQL92 keyword indicating that the cursor will be used to update tables. Since cursor updates are not currently supported in Post- greSQL this keyword provokes an informational error message. column Column(s) to be updated. Since cursor updates are not currently supported in PostgreSQL the UPDATE clause provokes an informational error message. OUTPUTS DECLARE CURSOR The message returned if the SELECT is run successfully. WARNING: Closing pre-existing portal "cursorname" This message is reported if the same cursor name was already declared in the current transaction block. The previous definition is discarded. ERROR: DECLARE CURSOR may only be used in begin/end transaction blocks This error occurs if the cursor is not declared within a transaction block. DESCRIPTION
DECLARE allows a user to create cursors, which can be used to retrieve a small number of rows at a time out of a larger query. Cursors can return data either in text or in binary format using FETCH [fetch(7)]. Normal cursors return data in text format, either ASCII or another encoding scheme depending on how the PostgreSQL backend was built. Since data is stored natively in binary format, the system must do a conversion to produce the text format. In addition, text formats are often larger in size than the corresponding binary format. Once the information comes back in text form, the client application may need to con- vert it to a binary format to manipulate it. BINARY cursors give you back the data in the native binary representation. As an example, if a query returns a value of one from an integer column, you would get a string of 1 with a default cursor whereas with a binary cursor you would get a 4-byte value equal to control-A (^A). BINARY cursors should be used carefully. User applications such as psql are not aware of binary cursors and expect data to come back in a text format. String representation is architecture-neutral whereas binary representation can differ between different machine architectures. PostgreSQL does not resolve byte ordering or representation issues for binary cursors. Therefore, if your client machine and server machine use dif- ferent representations (e.g., ``big-endian'' versus ``little-endian''), you will probably not want your data returned in binary format. However, binary cursors may be a little more efficient since there is less conversion overhead in the server to client data transfer. Tip: If you intend to display the data in ASCII, getting it back in ASCII will save you some effort on the client side. NOTES Cursors are only available in transactions. Use to BEGIN [begin(7)], COMMIT [commit(7)] and ROLLBACK [rollback(7)] to define a transaction block. In SQL92 cursors are only available in embedded SQL (ESQL) applications. The PostgreSQL backend does not implement an explicit OPEN cursor statement; a cursor is considered to be open when it is declared. However, ecpg, the embedded SQL preprocessor for PostgreSQL, supports the SQL92 cursor conventions, including those involving DECLARE and OPEN statements. USAGE
To declare a cursor: DECLARE liahona CURSOR FOR SELECT * FROM films; COMPATIBILITY
SQL92 SQL92 allows cursors only in embedded SQL and in modules. PostgreSQL permits cursors to be used interactively. SQL92 allows embedded or modular cursors to update database information. All PostgreSQL cursors are read only. The BINARY keyword is a PostgreSQL extension. SQL - Language Statements 2002-11-22 DECLARE(7)
All times are GMT -4. The time now is 04:10 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy