Sponsored Content
Full Discussion: File Handling in C
Top Forums Programming File Handling in C Post 95251 by trinath on Monday 9th of January 2006 01:16:00 PM
Old 01-09-2006
File Handling in C

Hi all,

I have a problem in handling files through C.

here is the problem im having:

i will query the database (for instance consider employees table )
for empno,ename,job,salary fields.The query returns me some 100 of rows. now i need to place them in a file in row wise pattern as they exist in the database.

now , if any row is updated in the database i need to update the same row in the file . also if any row is deleted i need to remove the same row in the file , and if any new row is inserted into the data base i need to insert the row in the file.

can any one suggest me any method to do this .
The performance is and main criteria(i mean time to do file operations. )

please help me in this regard,

thanks in advance,


Trinath Somanchi,
Hyderabad.
 

10 More Discussions You Might Find Interesting

1. Programming

file handling

Hi all, I got a little issue here. Imagine that I have more than one process accessing one file. Is it possible to know which process(es) are accessing that file when I open the file?? Thanks for the help. Best regards, Ernesto (2 Replies)
Discussion started by: ninjanesto
2 Replies

2. UNIX for Advanced & Expert Users

File Handling

Hi, I have a log file which runs into 3 to 5 GB. We store this typically for 6 months. When a new month starts we move the previous month into a 9 month back up log (file.9m) and delete the last month of the 9 month back up. Iam using awk to find the data and cat to join the files like... (3 Replies)
Discussion started by: baanprog
3 Replies

3. UNIX for Advanced & Expert Users

please help me in file handling

sir i have to get first line from a file for example >cat file1 abc zxc asd adsf from that file1 i need only first line expected result >abc please help me ! (1 Reply)
Discussion started by: ponmuthu
1 Replies

4. UNIX for Advanced & Expert Users

File handling

my input for a script is another csv file but in that file say 7 lines are there ... how can i get line by line to that input for example : >cat link.csv www.yahoo.com,yahoo www.google.com,google www.unix.com,unix another file in that file i need to ping the above links ... (2 Replies)
Discussion started by: ponmuthu
2 Replies

5. Shell Programming and Scripting

UNIX File handling -Issue in reading a file

I have been doing automation of daily check activity for a server, i have been using sqls to retrive the data and while loop for reading the data from the file for several activities. BUT i got a show stopper the below one.. where the data is getting store in $temp_file, but not being read by while... (1 Reply)
Discussion started by: KuldeepSinghTCS
1 Replies

6. Programming

Perl help for file handling

$# some text $$ some text $@ some text $$. some text Mg1 some text Mg2 some text . . . Mg10 some text The above 10 lines are to be extracted except the lines starting from $#,$$.,... (4 Replies)
Discussion started by: baig.abdul
4 Replies

7. Shell Programming and Scripting

ksh file handling

Specifically on RHEL 5.7. When does the underlying ksh process open and close files? Every time they're accessed, or as little as possible? Say you have some script like: CreateFiles() { grep "<VALUE1>" ${infile} >> ${outfile} grep "<VALUE2>" ${infile} >> ${outfile} ...... (4 Replies)
Discussion started by: CarloM
4 Replies

8. UNIX for Dummies Questions & Answers

File Handling

Hi Team, I am trying to cut a large file into multiple files. It has Header 50,050 records Trailer ------------------------------------------- I need to cut the files into multiple files of 1000 records and should have the same header and trailer as the original files. ... (4 Replies)
Discussion started by: Gurkamal83
4 Replies

9. UNIX for Dummies Questions & Answers

File handling

I have a file 1 298167 298168 1093209 1093210 1422663 I want to write a code where in I want to read contents of above file like first read is 1 second read is 298167 Substract second read from first and if this is greater than or less than 99,999. Similarly I want to traverse thru... (3 Replies)
Discussion started by: Guru148
3 Replies

10. Shell Programming and Scripting

File handling

Hi All, I need to extract the data from the text file. The data of the text file is shown below #L 0.000017 4.329939 0.000017 4.716267 r7.9 P 1 1;Net=IN32 The extracted data should be IN32. Could anyone help to script in c shell.? (4 Replies)
Discussion started by: gopishrine
4 Replies
Alzabo::Runtime::Row(3pm)				User Contributed Perl Documentation				 Alzabo::Runtime::Row(3pm)

NAME
Alzabo::Runtime::Row - Row objects SYNOPSIS
use Alzabo::Runtime::Row; my $row = $table->row_by_pk( pk => 1 ); $row->select('foo'); $row->update( bar => 5 ); $row->delete; DESCRIPTION
These objects represent actual rows from the database containing actual data. In general, you will want to use the "Alzabo::Runtime::Ta- ble" object to retrieve rows. The "Alzabo::Runtime::Table" object can return either single rows or row cursors. ROW STATES
Row objects can have a variety of states. Most row objects are "live", which means they represent an actual row object. A row can be changed to the "deleted" state by calling its "delete()" method. This is a row that no longer exists in the database. Most method calls on rows in this state cause an exception. There is also a "potential" state, for objects which do not represent actual database rows. You can call "make_live()" on these rows in order to change their state to "live". Finally, there is an "in cache" state, which is identical to the "live" state, except that it is used for object's that are cached via the "Alzabo::Runtime::UniqueRowCache" class. METHODS
Row objects offer the following methods: select (@list_of_column_names) Returns a list of values matching the specified columns in a list context. In scalar context it returns only a single value (the first column specified). If no columns are specified, it will return the values for all of the columns in the table, in the order that are returned by "Alzabo::Run- time::Table->columns". This method throws an "Alzabo::Runtime::NoSuchRowException" if called on a deleted row. select_hash (@list_of_column_names) Returns a hash of column names to values matching the specified columns. If no columns are specified, it will return the values for all of the columns in the table. This method throws an "Alzabo::Runtime::NoSuchRowException" if called on a deleted row. update (%hash_of_columns_and_values) Given a hash of columns and values, attempts to update the database to and the object to represent these new values. It returns a boolean value indicating whether or not any data was actually modified. This method throws an "Alzabo::Runtime::NoSuchRowException" if called on a deleted row. refresh Refreshes the object against the database. This can be used when you want to ensure that a row object is up to date in regards to the database state. This method throws an "Alzabo::Runtime::NoSuchRowException" if called on a deleted row. delete Deletes the row from the RDBMS and changes the object's state to deleted. For potential rows, this method simply changes the object's state. This method throws an "Alzabo::Runtime::NoSuchRowException" if called on a deleted row. id_as_string Returns the row's id value as a string. This can be passed to the "Alzabo::Runtime::Table->row_by_id" method to recreate the row later. For potential rows, this method always return an empty string. This method throws an "Alzabo::Runtime::NoSuchRowException" if called on a deleted row. is_live Indicates whether or not the given row represents an actual row in the database. is_potential Indicates whether or not the given row represents an actual row in the datatbase. is_deleted Indicates whether or not the given row has been deleted table Returns the "Alzabo::Runtime::Table" object that this row belongs to. schema Returns the "Alzabo::Runtime::Schema" object that this row's table belongs to. This is a shortcut for "$row->table->schema". rows_by_foreign_key This method is used to retrieve row objects from other tables by "following" a relationship between two tables. It takes the following parameters: * foreign_key => "Alzabo::Runtime::ForeignKey" object Given a foreign key object, this method returns either a row object or a row cursor object the row(s) in the table to which the relation- ship exist. The type of object returned is based on the cardinality of the relationship. If the relationship says that there could only be one match- ing row, then a row object is returned, otherwise it returns a cursor. POTENTIAL ROWS
The "potential" row state is used for rows which do not yet exist in the database. These are created via the "Alzabo::Runtime::Ta- ble->potential_row" method. They are useful when you need a placeholder object which you can update and select from, but you don't actually want to commit the data to the database. These objects are not cached. Once "make_live()" is called, the object's state becomes "live". Potential rows have looser constraints for column values than regular rows. When creating a new potential row, it is ok if none of the columns are defined. If a column has a default, and a value for that column is not given, then the default will be used. However, you cannot update a column in a potential row to undef (NULL) if the column is not nullable. No attempt is made to enforce referential integrity constraints on these objects. You cannot set a column's value to a database function like "NOW()", because this requires interaction with the database. make_live This method inserts the row into the database and changes the object's state to "live". This means that all references to the potential row object will now be references to the real object (which is a good thing). This method can take any parameters that can be passed to the "Alzabo::Runtime::Table->insert" method. Any columns already set will be passed to the "insert" method, including primary key values. However, these will be overridden, on a col- umn by column basis, by a "pk" or "values" parameters given to the "(make_live()" method. Calling this method on a row object that is not in the "potential" state will cause an "Alzabo::Runtime::LogicException" AUTHOR
Dave Rolsky, <autarch@urth.org> perl v5.8.8 2007-12-23 Alzabo::Runtime::Row(3pm)
All times are GMT -4. The time now is 11:46 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy