Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to read SQL parameters from a text file

2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/01 Report--

This article introduces how to read the SQL parameters from the text file, the content is very detailed, interested friends can refer to, hope to be helpful to you.

Sometimes we want to store the parameter list in a text file, and then spell it into the in function when we execute SQL, so as to query the records that meet the criteria.

However, SQL can not parse the text file, so it is difficult to spell it into the in function directly, so many people import the file into the temporary table of the database first, and then use the join statement to do the association, so as to indirectly realize the function of the in function. But in this way, whenever the file changes, we have to manually delete the table guide library action, the process is still very troublesome.

The way to develop programs once and for all is to develop programs in programming languages such as Python and C #, but these languages have a high technical threshold, and it is a bit difficult to learn, although in theory any function can be achieved.

If you use esProc, implementing this algorithm is much easier, with just a few lines of code:

AB1=file ("params.txt") .import@i () / Open the text file and fetch the parameter list 2=orcl.query ("select * from T where P in (?)", A2) by line / execute SQL,A2 is the parameter value of the in function

The above method cannot be used when the parameter list is too long, because the in function limits the number of members, such as Oracle, which limits the number of members to 1000. Don't worry about this situation. EsProc supports out-of-library general queries and supports long parameter lists. The code only needs to be written like this:

AB1=file ("params.txt") .import@i () .sort (~) / read long parameter list and sort 2=orcl.cursor ("select * from T") / fetch data from the library table 3=A3.select (A1.contain@b (P)) / query records that match the parameter list

EsProc is a scripting language that can be executed and debugged in desktop IDE, connect to any database and execute SQL. EsProc usually has ways to simplify functions that are difficult for SQL to achieve.

On how to read the SQL parameters from the text file to share here, I hope the above content can be of some help to you, can learn more knowledge. If you think the article is good, you can share it for more people to see.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report