PL / SQL修复记录长度文件 [英] PL/SQL Fix Record Length file

查看:64
本文介绍了PL / SQL修复记录长度文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有人知道如何在PL / SQL中将数据写为FIX RECORD LENGTH文件?

Does anyone know how to write data as a FIX RECORD LENGTH file in PL/SQL?

推荐答案


有谁知道如何在PL / SQL中将数据写为FIX RECORD LENGTH文件?
Does anyone know how to write data as a FIX RECORD LENGTH file in PL/SQL?



我用过的一种方法是找出每列的长度,并使用rpad或lpad函数来获得每个字段的正确长度。


选择rpad(my_field,< col_length作为数字>,''''),

rpad(my_next_field,< col_length as number>,'''')

来自my_table


...

One approach i have used is to figure out the length of each column and use the rpad or lpad functions to get each field the correct length.

select rpad(my_field,<col_length as number>,'' ''),
rpad(my_next_field,<col_length as number>,'' '')
from my_table

...



一种方法我使用的是计算每列的长度,并使用rpad或lpad函数使每个字段的长度正确。


选择rpad(my_field,< col_length as number>, ''''),

rpad(my_next_field,< col_length as number>,'''')
来自my_table的


...
One approach i have used is to figure out the length of each column and use the rpad or lpad functions to get each field the correct length.

select rpad(my_field,<col_length as number>,'' ''),
rpad(my_next_field,<col_length as number>,'' '')
from my_table

...



谢谢,这绝对给了我一个起点。基本上我正在从具有Fname,LName,Salary,EmployeeID,Dept的表中读取数据。我需要一个光标来获取所有列的示例,

选择*来自

COLS

其中TABLE_NAME =" my_table"


基本上我需要获得COL_NAME,SIZE,PRECISION,SCALE。



选择rpad(COL,size-length(COL)),

rpad(next_COL,size-length(COL))
来自my_table的




我有正确的想法吗?


Thank you, this diffinitely gives me a starting point. Basically I am reading data from a table which has Fname, LName, Salary, EmployeeID, Dept. I need a cursor to get all the columns example,
Select * from
COLS
where TABLE_NAME = "my_table"

basically I need to get the COL_NAME, SIZE, PRECISION, SCALE.


select rpad(COL,size-length(COL)),
rpad(next_COL, size-length(COL))
from my_table


do I have the right idea?



谢谢,这个绝对给了我一个起点。基本上我正在从具有Fname,LName,Salary,EmployeeID,Dept的表中读取数据。我需要一个光标来获取所有列的示例,

选择*来自

COLS

其中TABLE_NAME =" my_table"


基本上我需要获得COL_NAME,SIZE,PRECISION,SCALE。



选择rpad(COL,size-length(COL)),

rpad(next_COL,size-length(COL))
来自my_table的




我有正确的想法吗?
Thank you, this diffinitely gives me a starting point. Basically I am reading data from a table which has Fname, LName, Salary, EmployeeID, Dept. I need a cursor to get all the columns example,
Select * from
COLS
where TABLE_NAME = "my_table"

basically I need to get the COL_NAME, SIZE, PRECISION, SCALE.


select rpad(COL,size-length(COL)),
rpad(next_COL, size-length(COL))
from my_table


do I have the right idea?



你的初始帖子说你正在创建一个固定的位置字符串,对吗?如果是这样,FP字符串将具有某个规范中每个列的长度。


因此,当您查询表时,您将使用rpad函数添加必要的长度(如果需要)确保表中的每一列都是正确的字符数。


所以如果固定位置字符串中的第一列长度为30个字符,那么应该是Fname然后你会:


选择rpad(Fname,30,'''),

...
来自my_table的



RPAD中的3个参数是要填充的字段或字符串,长度的总空格数(因此,如果表中的字段是行x中的10个字符,它将填充20它的字符,最后一个参数是填充它(大多数情况下它是一个空格''')

Your initial post says that you are creating a fixed position string, correct? if so that FP string will have the lengths for each column in a spec somewhere.

so when you query your table you will use the rpad function to add the necessary length (where needed) to ensure that each column from the table is the correct number of characters long.

so if the first column in the fixed position string is 30 characters long and is supposed to be the Fname then you would :

select rpad(Fname,30,'' ''),
...
from my_table

the 3 parameters in RPAD are the field or string to pad, the number of spaces total for the length(so if the field in the table is 10 characters in row x it will pad 20 characters to it, and the last paramter is what to pad it with (most cases its a space '' '')


这篇关于PL / SQL修复记录长度文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆