Tracking Forums, Newsgroups, Maling Lists
Home Scripts Tutorials Tracker Forums
  Advanced Search
  HOME    TRACKER    MYSQL


SuperbHosting.net have generously sponsored dedicated servers to ensure a reliable and scalable dedicated hosting solution for BigResource.com.





Write Text Files


I'm wondering if it's possible to write text files from a trigger/procedure. For instance, if I want to write a log file, for debugging, that could trace my procedure.

I'm a Oracle developer, and in that environment I can use UTL_FILE to write txt files. Is there something similar in MySQL ?




View Complete Forum Thread with Replies

Related Forum Messages:
Re-write Text File
i'm creating a log file regarding database operations. My problem is i want to append a new record into the log file each time i update my database. Previously I've used the following method to create a file:

SELECT * INTO OUTFILE 'c:/"+fileName[i]+" '
FIELDS TERMINATED BY '|'
LINES TERMINATED BY '
'
FROM "+tableName[i]+";

MY problem is I cannot re-use the file created. Is there any way to call the same file for the purpose of re-use. Or maybe the OUTFILE do not allow file created to be re-use.

View Replies !
Text Files
Im doing perl for an online store and wondering if someone knew a way (a
script) to get my text files in to my database?

View Replies !
Importing Text Files
I'm importing our DOS data base (Dataflex) to Mysql I have a table with
174,638 records that I convert into a tab delimetered Text file however,
Mysql only reads 87,035!.

I checked the text file & it apperars fine is there
any limitation?

View Replies !
Importing Text Files.
I have an excel file... The first row in the excel file contains the names of fields in the MySQL database. (There are only four fields in my DB in a single table.) The following rows contain data that should be inserted into those fields. Well...

I can't figure out how to get that data from the excel file imported into the MySQL database. I have saved the excel file as a .csv file for testing purposes... On my web server I have phpMyAdmin installed...

It has a feature that says "import from text file"... However, whenever I try to import the csv file, it only grabs the first row (containg the field names) and part of the second row... When it grabs this data it puts it all into the first field in the DB... I can't figure out how to get it organized and get all of it inserted.

View Replies !
Create Text Files
I was sent set of /frm/myd/myi files and need to extract the data. I downloaded and installed mysql

I need to know how to get the data out of my files

(a) which directory should i put the files in
(b) how do i point mysql to the directory with the files
(b) what sql commands should i enter to extract the data and dump them in a text file

View Replies !
Import CSV, Text Files
how to automate the import of CSV, text files into MySql?

View Replies !
Loading Text Files
Im currently having problems loading a tab seprated file into mysql database.

It loads the data but with each field only loads half the data i.e. txt file contains "hello how are you world" (for a field) SQL table contains "hello how"
Not sure whats causing this as i've opened the same file in excel and it works perfectly (renamed it from .txt to .xls)

View Replies !
Importing Data From Text Files
Can anyone show an example MySQL command to import a text file into a table?
I have a massive qty of data to get into a MySQL database on a server over
the internet. Shouldn't I be able to do this with a bulk operation instead
of a script with many tens of thousands of INSERT statements? I can deliver
each tables data as comma delimited text files.
Do I need to start with an empty MySQL table or can I import the text table
directly?
I am working with a remote Apache server using an ssh telnet jailshell
window. I have to ftp compressed files since the amount of data is large
and the up link speed is slow.

View Replies !
Bulk Insert From Text Files
Is there a way to do a bulk insert (more efficient way) from a text file versus 3.5 million insert statements? This is for taking data from a csv file and loading into mysql 5

View Replies !
Joining Two Text Files Without A JOIN
I've got this little assignment that i cant seem to finish

I have 2 text files with data. The first one has 3 columns (IDnumber (number), school (number), name(number or text), the second one also has 3 columns (school (number), IDnumber (number), grade (number)).

The idea is to create another file that has 4 columns SCHOOL, IDNUMBER, NAME, GRADE. Grade and name may or may not have data, but school and idnumber always have data.

I have been going around in circles and have gotten no where.

Here are the constraints
+an IDNumer can repeat itself, but is in another school,
+a school number can have different students
+a student who appears on the first file may or may not appear on the second one so he may not have a grade
+a student who appears on the second file may or may not appear on the first one, thus he may be in school and have an id but no name.

Some ideas, similar projects of anything will be appreciated
I'm stuck at:
(SELECT school, idnumber, name, grade ---this is simply a blank extra column on that table--- FROM Table1)
UNION
((SELECT school, idnumber, name ---this is simply a blank extra column on that table---, grade FROM Table2)

The problem is that if I get a student who appears on both files, he also appears twice on the final file, once with an empty grade and once with an empty name (4 students on file1, the same 4 students on file 2, turn into 8 different rows, instead of only 4.

View Replies !
Fixed Width Text Files
I need to import multiple fixed-width text files into a database on a daily basis. My thought was to do this with a stored procedure, but I don't see any mysql syntax that would allow me to load a fixed-width file into a table. What am I missing?

View Replies !
Date Conversion Of Text Files
I have various .txt files with dates and times in the format 30/04/2007 23:59:59 but need a way of importing them to MySql (each file is about 70000 rows). How can I convert it to a date format understandable by MySQL, at the moment it just comes up with 00-00-00 00:00:00 for every line. I have tried some perl scripts I found on the net, but they haven't worked.

LOAD DATA LOCAL INFILE 'c:file.txt'
INTO TABLE archive (number, @dateandtime, id)
SET dateandtime = STR_TO_DATE(@dateandtime,'%m/%d/%y');



View Replies !
Loading Multiple Text Or CSV Files
I have a folder of approximately 6000 csv files. I would like to load them all into the same table. (i.e. what code do I use)? I really don't want to load them one at a time using the phpmyadmin import function, and I have been searching online for hours, but have not found the coded solution yet using mysqlimport or load data infile or similar.

View Replies !
Import A Directory Of Text Files Into A Mysql Database With Php?
I have a directory of text files that i'd like to import into a msql
table... I was wondering if there's an easier way to do this with
php/mysql, I'd like to avoid copy/pasting the entire directory
(thousands of files) into the database if i can.

The directory structure of the text files resembles...

somepath/A/Aerosmith/Song Name.txt - (extention varies)

What i'd like to do is use php to scan the directory and input
the file path information and the content from each file into a table
like...

Dir Artist Song Text Type
------------------------------------------------------------------------
A Aerosmith Song Name Fa La La La La (example text) File Ext
B Beatles Song Name Fa La La La La (example text) File Ext

View Replies !
Search And Write, Or Write And Recover?
The problem: I need to generate a 'unique string' for each row in a table. I already use auto_increment for system dependencies between tables.

What is the best approach one of these or another?

After generating a candidate 'unique string' the two strategies that came to mind are:

1. to then search the table's column to see if it is already assigned; locking the table for write while searching and writing the new row, or

2. set the column to UNIQUE when defining the table. Just go ahead and write the new row if you get a "non-unique" exception, generate another 'unique string' and try again.

I've tried both on a small XP laptop and get "lock timeout exceptions" rather quickly using #1. But replace those with lots of re-writes when there starts to get "collisions" of 'unique string's.

View Replies !
Loading Database From Multiple Text Files Each Containing A Partial List Of Columns
I'm kind of new to mysql. I would like to know if there is a way to use load infile or mysql import syntax to load one table with multiple files each containing a partial list of the table's columns:

Table contains : ID, first name, last name, occupation, salary

There are two files one containing the first three columns, the other the first field (ID) and last two fields. Is there a way to load them with just two load statements?

Note: I know that they can be loaded into two tables and later joined where ID is equal, but the actual example is about 30 text files rather than two, which is a bit too much.

View Replies !
Does Mysql Support Referencing Files In *.sql Script Files ?
does mysql support referencing to other files inside a .sql file ? for example to include several files into one file for sak of simplicity ?

View Replies !
Cant Write Or Delete
I cant get my php script to insert or delete records into a mysql
table. I can view them all fine but that's about it. I've checked
the user permissions on mysql and have set them all to 'Y' incase that
was the problem but still no joy. Can anyone suggest what the problem
may be? I'm tried the usual RTFM but cant spot the problem

View Replies !
How To Write A Trigger
we have an invoice table with fields ( invoice_id,date, item_id,item_name, price_per_item,quantity,cust_id)

here (item_id ,item_name and price_per_item) are from table item_details.

now i have to write a trigger to track the users who have changed the price_per_item column before insertion in invoice table.

View Replies !
Write A Mysql Db Onto A Cd
how to write the db of a mysql on one system onto a cd so as to copy that db to the mysql on another system.
The 2 systems are not connected to each other.

View Replies !
Write Data To Row With Via C API
I have an app written in C that sends data to text files. The files receive 8 variables and look like this:

May 19 20:42:09 2002
7
Services
3.23
4.34
0
None
2.31

Rather than writing data to a text file, I need that data to go to a MySQL 5.0.41 database row. I've already got the C API working and connecting to the "localhost" database, but now I need to write data with each transaction. Optimally, I'd like to send the data directly to the database row, but there doesn't seem to be an INSERT statement to do that. What's the best method to write the data to the database directly?

View Replies !
Can't Write To File
Using MySQL 4.1.11-max on OS X 10.3. Using command line.
Can't successfully use "INTO OUTFILE". Getting the following:
mysql> select *
-> into outfile '/users/steves/desktop/test.txt'
-> fields terminated by ','
-> from industry;
ERROR 1 (HY000): Can't create/write to file '/users/steves/desktop/test.txt' (Errcode: 13)
At the shell, I get this:
steves2ndmac:~ steves$ perror 13
OS error code 13: Permission denied

Newbie in both Unix shell and MySQL. Can anyone tell me how to set permissions for Unix User mysql?

View Replies !
How To Write Trigger
want to copy the table data from one host to another host

why because its live data . i want to update one host to another host.

ie i have one host 192.168.1.1 (db name is EXample table is live)

i want to copy the live table values into another table which is located in
different host ie(192.168.5.5 db name is Datadummy and table is livedummy).

in triggers is it possible or not?

View Replies !
Cannot Write To Database
The result I am getting is:

request "Could not execute SQL query" SELECT dt FROM webcalendar_events WHERE dt in ('2009-03-13') AND calendar_id=cum_wetheralhalls FOR UPDATE Unknown column 'cum_wetheralhalls' in 'where clause'

The strange thing is that when the calendar_id is a numeric value, it works perfectly. Is there anything that I can do in MySQL to get this to work with text-characters also, or do I have to use numeric values for this?

Is this something in the PHP script that is preventing it from saving to the database?

In case you need to know the table row calendar_id is varchar(30).

View Replies !
Best Way To Write This Query
Query 1: obtains results in boolean mode from products table based on keywords

Query 2: Would like to grab all manufacturers names from manufacturers table based on mf_id in products table to then create a brand filter.

What is the best way to do this in the most efficient query possible.

I was thinking of building a php array from query 1 of mf id's and the putting them in query 2 and separating them using OR operators.

any ideas?

here is the query fyi:

PHP

$sql =  "SELECT products_id as prodid,
                    products_name as name,
                    manufacturers_id as manufacturers_id,
                    products_price as price,
                    products_msrp as msrp,
                    products_date_added as pda,
                    products_status as status,
                    products_sku as sku,
                    products_weight as weight,
                    categories_id as cat_id,
"
        .boolean_sql_select(
            boolean_inclusive_atoms($search_string),
            $fulltext_key)." as relevance
"
        ."FROM $table_name
"
        ."WHERE
"
        .boolean_sql_where($search_string,$fulltext_key)."
"
        ."HAVING relevance>0
";
        
        
        
        if (isset($HTTP_GET_VARS['sort'])) {
            if ($_GET['sort']=="brand") {
            $sql.="ORDER BY products_name ";
            } elseif ($_GET['sort']=="size") {
            $sql.="ORDER BY products_weight ";
            } elseif ($_GET['sort']=="price_low") {
            $sql.="ORDER BY products_price ASC ";
            } elseif ($_GET['sort']=="price_high") {
            $sql.="ORDER BY products_price DESC ";
            } elseif ($_GET['sort']=="fav") {
            $sql.="ORDER BY products_name ";
            }
            
        } else {
            $sql.="ORDER BY relevance DESC
";
        }

View Replies !
Help Me Write This Join?
Hi there, been ages since I wrote any sql, and I'm a little stuck but I figure this is easy for you folks. I have this original query:

$posts = $wpdb->get_results("SELECT ID, post_title FROM " . $wpdb->posts . " WHERE post_status='publish' ORDER BY post_date DESC");

And this gives a lists of all posts. However, I want to only grab posts by a certain category now, say category #9. This information is kept in an intersection table called wp_post2cat. The columns in that table are:

rel_id
post_id
category_id

category_id is what I want, and post_id is the key pointing back to the original post. Posts can have multiple categories, but I just want the one listing where it's category 9, which is audio.

So pseudocode would be something like:

SELECT all posts WHERE post_status equals "publish" and the category is equal to audio (9).

View Replies !
How To Write This In MySQL?
I Want to check if a certain value doesnt exist in a ceratain field in
my table as a condition.

"select id from employees inner join
translog on employees.emp_id=translog.empid
inner join outofofficedays on
employees.emp_id=outofofficedays.emp_id inner join holidays
where (here is my question: ��-04-02'
doesnt exist in the column translog.vtransdate)
and (��-04-02' not between holidays.H_START and H_END)
order by translog.vTransDate,employees.emp_id limit 1"

View Replies !
How To Write This Select?
I'm having some troubles writing a select. I have the following tables:

theater
-------
- id
- name

movie
-----
- id
- name

showtime
---------
- id
- theater
- movie
- from
- to
- schedule

I would like to list all the theaters with all the available showtimes and movies. I tried to, but i didn't get the result i was expecting. Can somebody help?


View Replies !
How Do I Write This Trigger?
I’ve been searching all over for the answer to this one. If you have the answer, it would help me out a lot!

Using MySQL triggers, I want to sync content between two tables; I have table “user” and table “users”, each have similar columns “last_name” “first_name” “user_id” …etc, and when a row gets written to table “users”, I wanted that record to be replicated and inserted to “user” (with all the same field info).

How do I write this trigger? I know, it’s anti-normalization, but it will really help me out with testing one of our site's authentication.

View Replies !
C- Program To Write To Myi , Myd File
is it possible to create a myi, myd file for mysql using a C program. I
am using Stata that is written in C API, and I want to write the data
out to MYSQL database. Using ODBC and loading the data in MYSQL from
STATA takes forever. Can anyone please tell me if I can create the myd
files by using the data in memory thru C programming.

View Replies !
Using INSERT To Write To A Directory
I have a problem that I'm not sure if it can be done. I'm trying to
use the MySQL C API to be able to use a normal sql insert statement
that will send the data or file to a directory and NOT the database.
I'm not sure if there is anything out there that will allow this, but
I've searched everywhere, and I have found no solution.

View Replies !
Write Conflict Error
I have a database with access as front end and Mysql as back end. I am
gettting the following 'Write Conflict' Error. when i am on my order
form, This form does has a subform where i enter all the products that
are ordered.

Could any one let me know what could cause this problem. I am the only
one using the database as its still in the build stage Code:

View Replies !
Cant Write Or Delete To Table
I cant get my php script to insert or delete records into a mysql
table. I can view them all fine but that's about it. I've checked
the user permissions on mysql and have set them all to 'Y' incase that
was the problem but still no joy. Can anyone suggest what the problem
may be? I'm tried the usual RTFM but cant spot the problem

View Replies !
MySql Write Vs Read
Essentially I am faced with a design choice;

have an oft run (modifiable) query run every time any user wants to
run it, comparing criteria againt each and every user in the table and
delviering list OR saving that list (user/user/) so the next time all
that needs to be queried is the existence of a record in the table.

The basic tradeoff; version 1 there are many simultaneous queries of
the user db on complex search criteria; version 2 there are fewer but
their are as many far more simple queries to a much larger table, not
to mention many writes to same to keep the table current.

I know this is pretty vague, but I was wondering if in general there
is an area that mysql excels in vis a vis complex query smaller tables
simple query larger tables.

Question 2 is there anyway to guestiate the search/write times of a
user log in to both query and update? #Records, fields, etc? I'd like
to keep log in to < 10 seconds max.

View Replies !
How To Write Stored Procedures?
1. i want to write a stored procedure using mysql 5.0.45 version.

2. when i tried with the following code ,i am unable to write ...

View Replies !
How To Write Group By Query
i create table item-info. i want to view my data in the following way. i write query use group by but i want name show only one time no repeatation name next line.

item-info table:

id name item price

1 A XX 15

2 B XX 16

3 A YY 17

4 C YY 20

5 B ZZ 50

6 A ZZ 40

View my data in the following way:

name item price

A XX 15

YY 17

ZZ 40

B XX 16

ZZ 50

C ZZ 20

View Replies !
Select .. Into Outfile Write
global scope:
trying to execute on a schedule a .sql file which writes out
a .csv file.

windows(dont ask)/mysql

in the batch file i have

mysql -u myUser --password=somePass < myFile.sql

the sql query in the file

Code:

use mydb;
select field1,field2,field3
union
select `actField1`,`actField2`,`actField3` into outfile 'F:folder est.csv'
FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '"' FROM `detailsTable`;

View Replies !
Create/write To The File
I am working on Solaris and seem to get the following error
Cant create/write to the file '/home/dslab456/temp/tempoutput.lst'
As in windows i cannot specify which drive it is or so ? could anyone help me out with this ?

SELECT * INTO OUTFILE '/home/dslab456/temp/tempoutput.lst'
FROM stocklist_vokus s,p_tmpr p
WHERE s.STOCKLIST =p.stocklist_value
ORDER BY p.rid



Edited 1 time(s). Last edit at 02/12/2007 05:38AM by summer queen.

View Replies !
Read & Write Locks
I need to lock some of my tables for a while with lock tables. However I find how the READ and WRITE locks is implemented in the MyISAM storage engine a little odd. When obtaining a READ lock all updates are prevented, including writes from the thread obtaining it. WRITE locks gives exclusive access to the issuing thread.
However what I want is to give read and write priveleges to one thread and read priveleges to all other threads, and I can't figure out how to obtain this effect with lock tables... Is it even possibel?

View Replies !
Vita And Write In MySQL
My web site use a odbc to a MySQL database. I create it on XP and it's worked but I'm now on vita and the data base on a 2003 server. All the reading access on the database are ok but all the writing access are denied. I haven't error message just error 500 on ie7.

View Replies !
Write Once Read Many Field
I am designing a database and one of the requirements my client has is that once data is entered into certain fields it cannot, under any circumstances, be changed. Is it possible to create a write once read many (WORM) field in MySQL directly?

View Replies !
Can't Create/Write To File
#1 - Can't create/write to file 'AC Web Ultimate RepackServer mp#sql_dac_0.MYI' (Errcode: 2)

I am using Wampserver and I am creating the database using myphpadmin.

I installed the AC Web Ultimate Repack for World of Warcraft, but since then it has been uninstalled.

View Replies !
Slow Write Speeds
Here is what i have

IBM x226 - 8GB ram - 2x 3.4 Ghz Xeon (single core) processors - RAID 5E (6x300GB disks)

Suse Linux 9.0; MySQL 5.0.13

So, I am migrating from SQL server 2000 on a much smaller Dell PowerEdge (2gb ram, 2 Xeon 3.0 Ghz, Raid 5 over 5x74GB). I am exeriencing very slow write times.

For instance, there is one table on both servers that has approx 9mil rows...here is a basic test:

Update loan
set test_col = 1;

Platform Time
IBM/Linux/MySQL 5 9:45
Dell/Win/SQL server 1:37

The tests were run during very light server activity and I tried them multiple times.

Our IT department is fairly insistant that the IBM server is running per spec...obviously something is not right. I have changed some of the server variables with no improvement.

View Replies !
How To Write Like Comparison In Procedures?
this sample procedure takes in an username, searches for number of entries matching the pattern of the username.

delimiter $$
create procedure sampleDB.sampleProcedure( IN m_username varchar(30), OUT m_username_matched_count int )
deterministic
begin
if length(m_username) = 0 then
set m_username = 'jason' #set temporary name if empty
end if

set m_username_matched = 0; #finds number of matches for the given username

select
count(*) into m_username_matched #store into the variable to be returned
from
sampleDB.sampleTable
where
userName like '%m_username%' #this is the statement that does not work#

end$$

View Replies !
Write Vs. Read Performance
I'm guessing this is just as much a file system question as a MySQL question, but I haven't been able to find any information touching this particular subject.
Not considering data sent through network, what would be faster, fetching a row from a database, updating those columns that have been changed, let's say one of five, or simply don't fetch and update all the columns in the row (not including the id of course)?

View Replies !
Backup :: .sql Files OR .myd .myi And .frm Files?
my host went down and so I got backups. Well, what I received is the raw data and stuff, not .sql files. For what should be simple .sql files instead I have craploads of .myd, .myi, and .frm files. How do I put all this stuff together to get a single sql file so I can upload it into mysql and get my sites working again?

View Replies !
No Read Or Write Between INSERT And UPDATE
I am using mysql with the InnoDB engine. I wrote a perl script that
first selects something from a table, and then updates a second table
based on the select from the first table. I need to make sure that
there is no read or write to the tables while my script performs the
insert and update.

I looked at

http://dev.mysql.com/doc/refman/4.1/en/lock-tables.html

and it says this:

---------------------------------------------------------
If you are using a storage engine in MySQL that does not support
transactions, you must use LOCK TABLES if you want to ensure that no
other thread comes between a SELECT and an UPDATE. The example shown
here requires LOCK TABLES to execute safely:

LOCK TABLES trans READ, customer WRITE;
SELECT SUM(value) FROM trans WHERE customer_id=some_id;
UPDATE customer
SET total_value=sum_from_previous_statement
WHERE customer_id=some_id;
UNLOCK TABLES;

Without LOCK TABLES, it is possible that another thread might insert a
new row in the trans table between execution of the SELECT and UPDATE
statements.
---------------------------------------------------------

However, I am using InnoDB and it DOES support transaction. So, does
that mean that even if I don't lock my tables, it will still work? If
not, what do I need to do?

View Replies !
To Re-write Complex Query With JOINS
I have a problem with one of the JOIN query here.
Below is a brief description of the problem.

tablename : test

RecordId EffectiveDateothertableidvalue
-------- ------------- ------------ -----
12004-01-10110
22004-01-20120
32004-01-20270
42004-01-10280
52004-01-15110
62004-01-25310

Output :
RecordId EffectiveDateothertableidvalue
-------- ------------- ------------ -----
22004-01-20120
32004-01-20270
62004-01-25310

Now I want to use a single SQL query to find a result
where there exist one record for each unique
"othertableid" where the record selected for the
"othertableid" should be the recent one with regard to
"EffectiveDate".

That is from the above records, I want to select
Records with "RecordId" = 2 and 3 because they are the
recent one for "othertableid" = 1 and 2 respectively.
Please be sure that I want to retrive all fields
including "RecordId". The result should not depend on
any other fields but "EffectiveDate" only.

I am using MySQL 4.0.12 and it does not support
"SUBQUERIES" which is now given support in latest
MySQL edition. But I have read in the manual of MySQL
that any "SUBQUERY" SQL statement can be written with
proper "JOINS".

View Replies !
Read/write Table Efficiency
I've got a bit of an efficiency question, and just trying to figure out how best to manage this.

For my site HearWhere.com, I have a table which holds artists shows.

When i am refreshing the collection of shows and geocoding the locations, the database response for user queries slows significantly - which is understandable.

One option I'm considering is to have one database which the users connect to for queries, and a second separate database for writing the updates, and then I can just move the updated database to become the live database on a daily basis.

The other option I think is just to have a separate table which I write the updates to, and then just replace the table the users interact with from the table which was updated

Either way I go, at the moment everything would be done on the same sql server - I don't currently have enough traffic to justify multiple servers.

View Replies !

Copyright © 2005-08 www.BigResource.com, All rights reserved