Oracle:文件和表之间的内部联接(Oracle:inner join between file and table)
我是oracle和plsql的新手,所以只需要忍受一下。 我有一个文件
TYPES.txt
,id,name,values 1,aaa,32 2,bbb,23 3,cvv,12 4,fff,54
我的数据库中还有一个表,
PARTS.ATTRIBUTES
id,name,props,crops 1,aaa,100,zzzz 2,bbb,200,yyyy 3,cvv,300,xxxx 4,fff,400,wwww 5,sasa,343,gfgg 6,uyuy,897,hhdf
我想根据列
name
对文件TYPES
和ATTRIBUTES
进行INNER JOIN
。 现在,我通过最初将文件TYPES
加载到临时表中,然后在临时表和ATTRIBUTES
表之间进行INNER JOIN
来完成此操作。但我想知道是否有可能在
TYPES
文件和ATTRIBUTES
表之间进行INNER JOIN而不使用临时表。我知道我可以使用以下脚本加载文件并获取相应的行:
declare file utl_file.file_type; line varchar2(500); begin file :=utl_file.fopen('USER_DIR','TYPES.txt','r'); loop utl_file.get_line(file ,line); dbms_output.put_line(line); end loop; exception when others then utl_file.fclose(file); end;
有人可以向我解释如何在文件内容和数据库表之间进行连接吗?
PS
TYPES.txt
文件是动态生成的,并且在不同的时间可以有不同的列数。I'm new to oracle and plsql, so just bear with me. I have a file
TYPES.txt
,id,name,values 1,aaa,32 2,bbb,23 3,cvv,12 4,fff,54
I also have a table in my db,
PARTS.ATTRIBUTES
id,name,props,crops 1,aaa,100,zzzz 2,bbb,200,yyyy 3,cvv,300,xxxx 4,fff,400,wwww 5,sasa,343,gfgg 6,uyuy,897,hhdf
I'd like to do an
INNER JOIN
on the fileTYPES
andATTRIBUTES
based on the columnname
. Now, i have done this by initially loading fileTYPES
into a temp table and then doingINNER JOIN
between the temp table andATTRIBUTES
table.But i'd like to know whether it is possible to do INNER JOIN between
TYPES
file andATTRIBUTES
table without making use of a temp table.I understand that i can load the file using and get respective rows using following script:
declare file utl_file.file_type; line varchar2(500); begin file :=utl_file.fopen('USER_DIR','TYPES.txt','r'); loop utl_file.get_line(file ,line); dbms_output.put_line(line); end loop; exception when others then utl_file.fclose(file); end;
Could someone be kind enough to explain to me how i can do the join between file contents and the db table?
P.S. The file
TYPES.txt
is dynamically generated and can have different number of columns at different times.
原文:https://stackoverflow.com/questions/47391236
最满意答案
您可以使用json2csharp.com来获取JSON的类型。
JSON:
{"status":"error","messages":[{"level":"error","key":"InvalidTokenError","dsc":"Invalid token"}]}
以下是为JSON生成的类:
public class Message { public string level { get; set; } public string key { get; set; } public string dsc { get; set; } } public class RootObject { public string status { get; set; } public List<Message> messages { get; set; } }
对于JSON:
[{"level":"error","key":"InvalidTokenError","dsc":"Invalid token"}]
类型:
public class Message { public string level { get; set; } public string key { get; set; } public string dsc { get; set; } }
You can use json2csharp.com to get the types of the JSON.
JSON:
{"status":"error","messages":[{"level":"error","key":"InvalidTokenError","dsc":"Invalid token"}]}
Here is the classes generated for your JSON:
public class Message { public string level { get; set; } public string key { get; set; } public string dsc { get; set; } } public class RootObject { public string status { get; set; } public List<Message> messages { get; set; } }
for JSON:
[{"level":"error","key":"InvalidTokenError","dsc":"Invalid token"}]
Type:
public class Message { public string level { get; set; } public string key { get; set; } public string dsc { get; set; } }
相关问答
更多-
你需要一个根对象 public class UnitDetail { public int Id { get; set; } public int UnitId { get; set; } public bool Active { get; set; } public string Name { get; set; } public string ContactNumber { get; set; } } public class RootObject { ...
-
将JSON反序列化为c#类(Deserializing JSON into c# class)[2023-05-10]
您可以为此创建自定义JsonConverter : [JsonConverter(typeof(ClickConverter))] public class Click { public DateTime Date { get; set; } public string Code { get; set; } public string Url { get; set; } public int Count { get; set; } } public class ClickC ... -
您正在尝试反序列化为List List
newDoc = JsonConvert.DeserializeObject - >(response.Content.ReadAsStringAsync().Result);
但是您的JSON字符串仅包含一个对象{} 。 将您的JSON输入更改为[{...}]或将您的反序列化调用更改为仅一个对象。 You are trying to deserialize into a List Li ...
-
将Json反序列化为C#列表(Deserializing Json to C# list)[2021-12-08]
你能粘贴更多代码吗? 有限的源代码很难找到任何问题。 您可以使用ajax请求将str发送到服务器: $.get('your url', {str: str}) 顺便说一句,似乎str不是一个有效的JSON字符串。 str = JSON.strigify(x)将对象字符串str = JSON.strigify(x) JSON字符串。 试试这个:``` $(document).ready(function () { $("#btn_check").click(function () { ... -
从快速查看你遇到的错误,它发生在这一行: string paymentID = items.entry.FirstorDefault().id; //should be .FirstOrDefault().id; ...枚举items.entry每个Entry项,这是一个List
: if (items.entry != null && items.entry.Count > 0) { foreach(Entry entryItem in items.entry) { ... -
将JSON字符串反序列化为C#(Deserializing JSON string to C#)[2022-03-19]
我不是一个特别熟练的Json用户,但是,使用Newtonsoft的东西,我会尝试这样的东西(从LINQPad剪切并粘贴): void Main() { string json = "[{ \"personnelId\": 201, \"occupationIds\": [4,5]}, {\"personnelId\": 202,\"occupationIds\": [5]}]"; var js = Newtonsoft.Json.JsonConvert.DeserializeObject< ... -
使用JSON.NET,您可以编写自定义JSON转换器。 例如,您可以拥有以下对象: public class Root { public string Status { get; set; } public Result Result { get; set; } } public class Result { public bool? Value { get; set; } public Item[] Items { get; set; } } public class ...
-
我想你应该用 List
places = JsonConvert.DeserializeObject - >(responseFromServer);
代替 places = JsonConvert.DeserializeObject
(responseFromServer); 并且不要忘记删除以下行 Places places = new Places(); 编辑:完整答案 static void Main(string[] args) ... -
JSON反序列化为C#类型(JSON deserializing to C# types)[2023-01-19]
您可以使用json2csharp.com来获取JSON的类型。 JSON: {"status":"error","messages":[{"level":"error","key":"InvalidTokenError","dsc":"Invalid token"}]} 以下是为JSON生成的类: public class Message { public string level { get; set; } public string key { get; set; } publ ... -
试试这种方式: var ul = JSON.stringify({ 'userlist': users}); $.ajax({ type: "POST", url: "/myurl/addusers", data: ul , content-Type: 'application/json; charset=utf-8', dataType: "json", success: function (resp ...