![]() |
逆袭的饭卡 · @ttk/vue-ui - npm· 1 周前 · |
![]() |
神勇威武的炒饭 · 表单输入绑定 | Vue.js· 4 天前 · |
![]() |
愉快的铁链 · 在select选项上绑定事件 - · 4 天前 · |
![]() |
英姿勃勃的地瓜 · 如何使用grouping ...· 3 天前 · |
![]() |
坚韧的竹笋 · Monitoring Disk Space ...· 12 小时前 · |
![]() |
威武的烤面包 · Solved: Can't get ...· 5 月前 · |
![]() |
失眠的芹菜 · 《古筮真诠》带你穿越古人的易学世界之70 ...· 7 月前 · |
![]() |
买醉的饭盒 · 求《超脱(2011)》百度网盘免费在线观看, ...· 8 月前 · |
![]() |
风流倜傥的大熊猫 · The Origin Forum - ...· 9 月前 · |
![]() |
文武双全的热带鱼 · 贸联荣获美国《机构投资者》评选为「2022亚 ...· 9 月前 · |
cursor mysql select |
https://www.experts-exchange.com/questions/24030868/Creating-Text-Files-Using-MySQL-Stored-Procedures-SP.html |
![]() |
聪明的墨镜
7 月前 |
![]() |
逆袭的饭卡 · @ttk/vue-ui - npm 1 周前 |
![]() |
神勇威武的炒饭 · 表单输入绑定 | Vue.js 4 天前 |
![]() |
愉快的铁链 · 在select选项上绑定事件 - 4 天前 |
![]() |
失眠的芹菜 · 《古筮真诠》带你穿越古人的易学世界之70 - 哔哩哔哩 7 月前 |
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 !!