读研的充电器 · mysql日期只比较年月日 ...· 2 周前 · |
大力的松鼠 · Mysql比较日期和时间 - · 2 周前 · |
帅气的牛肉面 · 【SQL】COUNT()函数 ...· 1 周前 · |
微笑的汉堡包 · Sybase·调用存储过程并返回结果· 1 周前 · |
绅士的水煮肉 · Sequence 使用、原理全面解析 · ...· 1 周前 · |
帅气的松鼠 · 《兄嫁 固执的大嫂》免费在线观看-樱花动漫网· 3 天前 · |
茫然的香槟 · 兆豐銀行 特惠專案信貸· 1 月前 · |
魁梧的咖啡豆 · Kindle可以看PDF文件吗?怎么在Kin ...· 2 月前 · |
力能扛鼎的盒饭 · 义采宝义乌小商品批发采购官网· 4 月前 · |
飞奔的机器猫 · 深公司早报|达实智能与深铁签约2820.09 ...· 4 月前 · |
cursor mysql select |
https://www.experts-exchange.com/questions/24030868/Creating-Text-Files-Using-MySQL-Stored-Procedures-SP.html |
聪明的墨镜
4 月前 |
大力的松鼠 · Mysql比较日期和时间 - 2 周前 |
微笑的汉堡包 · Sybase·调用存储过程并返回结果 1 周前 |
帅气的松鼠 · 《兄嫁 固执的大嫂》免费在线观看-樱花动漫网 3 天前 |
茫然的香槟 · 兆豐銀行 特惠專案信貸 1 月前 |
力能扛鼎的盒饭 · 义采宝义乌小商品批发采购官网 4 月前 |
Change the table name from below sp.. I'm creating the text file name unique .. so you may want to change that also if needed
Open in new window
httpp://dev.mysql.com/doc/
Better I suggest you to download MySQL Manual and go thru in details.
ASKER
i.e. 100 records = 100 files and each filename will be named based on the record.seq_id such as 1001.txt, 1002.txt ...etc
Also, I will need to consider the error and performance issues due to currently the table contains about 570000 ++ records. What do you think ?
i.e. 100 records = 100 files and each filename will be named based on the record.seq_id such as 1001.txt, 1002.txt ...etc
Yes possible.. use cursor to navigate each and every record... let me know if you need any help in this regard
>>>>>Also, I will need to consider the error and performance issues due to currently the table contains about 570000 ++ records. What do you think ?
I don't suggest you to create "570000" files..definitely you would see performance heat.
Update the select queries and you are done..
Open in new window
ASKER
Besides, is there any ways to format the output data properly in the output file such as
<seqid<1001</seqid>
<params>column params data</params>
<results>column results data</results>
thanks for your help !!!
<seqid<1001</seqid>
<params>column params data</params>
<results>column results data</results>
Updated the stored procedure.. pls check I have done for single column and you may need to do it for rest of the columns,,
Open in new window
SET @tmp_sql= CONCAT("SELECT CONCAT('<params',l_column1
SET @tmp_sql= CONCAT("SELECT CONCAT('<params>',l_column
ASKER
SET @tmp_sql= CONCAT("SELECT CONCAT('
SET @tmp_sql= CONCAT("SELECT CONCAT('',l_column1,'') INTO OUTFILE '/tmp/",l_id,".txt' FROM dual");
compare above 2 statements, thery're the same, am I right ?
SET @tmp_sql= CONCAT("SELECT CONCAT('<params',l_column1
so changed it to
SET @tmp_sql= CONCAT("SELECT CONCAT('<params>',l_column
ASKER
since we're using cursor and assign respective columns to the variables "FETCH cursor1 INTO l_id,l_column1" why do we need to have the SELECT .. FROM -> "SELECT CONCAT('<params>',l_column
I am confused on the statement and still trying to understand to concat more than 1 columns. Please advice. Thanks
ASKER
When execute, error returned "unknown l_column1 in field list", so I guess we need to put the table.fieldname instead SP variable.
Finally, I worked out the query by adding in more columns and the where clause to output 1 record per file. I know it will going to be a performance beat, I will re-consider.
SET @tmp_sql= CONCAT("SELECT CONCAT('<logid>',log_id,'<
Thanks for your big help !!