多个进程访问同一个文件(Multiple processes accessing the same file)
多个进程是否可以同时访问(写入)同一个文件? 使用下面的代码,它似乎工作,但我有我的怀疑。
实例中的用例是每次收到电子邮件时都会调用的可执行文件,并将其输出记录到中央文件中。
if (freopen(console_logfile, "a+", stdout) == NULL || freopen(error_logfile, "a+", stderr) == NULL) { perror("freopen"); } printf("Hello World!");
这是在CentOS上运行并编译为C.
Is it alright for multiple processes to access (write) to the same file at the same time? Using the following code, it seems to work, but I have my doubts.
Use case in the instance is an executable that gets called every time an email is received and logs it's output to a central file.
if (freopen(console_logfile, "a+", stdout) == NULL || freopen(error_logfile, "a+", stderr) == NULL) { perror("freopen"); } printf("Hello World!");
This is running on CentOS and compiled as C.
原文:https://stackoverflow.com/questions/9880771
满意答案
你只需连接字符
SELECT 'EN' + Cast(id as varchar(10)) FROM yourTable
然后,如果您想进行更新:
UPDATE yourTable SET yourfield = 'EN' + Cast(id as varchar(10))
如果您有表格中的国家/地区列表:
SELECT left(country, 2) + cast(id as varchar(10)) FROM yourTable
要么
UPDATE yourTable SET yourfield = left(country, 2) + Cast(id as varchar(10))
You would just concatenate the characters
SELECT 'EN' + Cast(id as varchar(10)) FROM yourTable
Then if you want to do an update:
UPDATE yourTable SET yourfield = 'EN' + Cast(id as varchar(10))
If you have the list of countries in the table:
SELECT left(country, 2) + cast(id as varchar(10)) FROM yourTable
or
UPDATE yourTable SET yourfield = left(country, 2) + Cast(id as varchar(10))
相关问答
更多将字母前缀到整数字段(Prefixing Letters to an Integer Field)
捕获包含字母+数字的字段中的字母(Capture letters in field containing letters+numbers)
过滤带范围的整数字段(Filtering integer field with a range)
包含数字和字母的排序字段(Sort field that contains numbers and letters)
Visual Basic修剪来自整数的字母(Visual Basic Trimming Letters From Integer)
按包含数字和字母的字段排序(Order by a field containing Numbers and Letters)
如何比较整数字段和json字段?(How to compare integer field with json field?)
可以Long Integer存储字母吗?(Can Long Integer store letters?)
sql注入整数字段(sql injection in integer field)
整数字段前缀零不显示(Integer field prefix zero not displaying)
相关文章
更多用‘button’跟‘text’组合代替‘file’,选择文件后点‘submit’,‘file’的值被清空
《虚拟机系统与进程的通用平台》(Virtual Machines: Versatile Platforms for Systems and Processes)扫描版[PDF]
Java 流(Stream)、文件(File)和IO
PHP 中dirname(_file_)
xxx is not in the sudoers file解决方法
【HDFS】HADOOP DISTRIBUTED FILE SYSTEM
shell 脚本执行,出现错误bad interpreter: No such file or directory
file_get_contents 无法读取https的问题解决!
Hadoop HDFS Wrong FS: hdfs:/ expected file:///
HDFS patch前后Ganglia看到running processes变化的分析
最新问答
更多获取MVC 4使用的DisplayMode后缀(Get the DisplayMode Suffix being used by MVC 4)
如何通过引用返回对象?(How is returning an object by reference possible?)
矩阵如何存储在内存中?(How are matrices stored in memory?)
每个请求的Java新会话?(Java New Session For Each Request?)
css:浮动div中重叠的标题h1(css: overlapping headlines h1 in floated divs)
无论图像如何,Caffe预测同一类(Caffe predicts same class regardless of image)
xcode语法颜色编码解释?(xcode syntax color coding explained?)
在Access 2010 Runtime中使用Office 2000校对工具(Use Office 2000 proofing tools in Access 2010 Runtime)
从单独的Web主机将图像传输到服务器上(Getting images onto server from separate web host)
从旧版本复制文件并保留它们(旧/新版本)(Copy a file from old revision and keep both of them (old / new revision))
Copyright ©2023 peixunduo.com All Rights Reserved.粤ICP备14003112号
本站部分内容来源于互联网,仅供学习和参考使用,请莫用于商业用途。如有侵犯你的版权,请联系我们(neng862121861#163.com),本站将尽快处理。谢谢合作!