Lets say someone has sent me a simple text list, and I’d like that to be accessible as SQL.
Advanced Security Administrator's Guide
Application Developer's Guide - Advanced Queuing (AQ)
Application Developer's Guide - Fundamentals
Application Developer's Guide - Large Objects (LOBs)
Application Developer's Guide - Object-Relational Features
Application Developer's Guide - XML
Applications InterConnect User's Guide
Backup and Recovery Guide
Concepts
CORBA Developer's Guide and Reference
Data Cartridge Developer's Guide
Data Warehousing Guide
Designing and Tuning for Performance
Distributed Database Systems
Enterprise JavaBeans Developer's Guide and Reference
Enterprise Manager Administrator's Guide
Enterprise Manager Concepts Guide
Enterprise Manager Configuration Guide
Enterprise Manager Intelligent Agent User's Guide
Enterprise Manager Messages Manual
Enterprise Manager SNMP Support Reference Guide
Error Messages
Getting to Know Oracle8i
Integration Server Overview
interMedia Audio, Image, and Video Java Classes User's Guide and Reference
I’ll save it to a file, but if I want to access it as an external table that means transferring that file to the database server, which can be fiddly.
The other option is I could use the LOAD command in SQLcl to store it in a table, but there’s another option as well.
A quick bit of sed to wrap each line (which you could store as an alias if you don’t want to type it each time).
[oracle@db26 ~]$ sed "s/^/,(q'{/;s/$/}')/" list
,(q'{Advanced Security Administrator's Guide}')
,(q'{Application Developer's Guide - Advanced Queuing (AQ)}')
,(q'{Application Developer's Guide - Fundamentals}')
,(q'{Application Developer's Guide - Large Objects (LOBs)}')
,(q'{Application Developer's Guide - Object-Relational Features}')
,(q'{Application Developer's Guide - XML}')
,(q'{Applications InterConnect User's Guide}')
,(q'{Backup and Recovery Guide}')
,(q'{Concepts}')
,(q'{CORBA Developer's Guide and Reference}')
,(q'{Data Cartridge Developer's Guide}')
,(q'{Data Warehousing Guide}')
,(q'{Designing and Tuning for Performance}')
,(q'{Distributed Database Systems}')
,(q'{Enterprise JavaBeans Developer's Guide and Reference}')
,(q'{Enterprise Manager Administrator's Guide}')
,(q'{Enterprise Manager Concepts Guide}')
,(q'{Enterprise Manager Configuration Guide}')
,(q'{Enterprise Manager Intelligent Agent User's Guide}')
,(q'{Enterprise Manager Messages Manual}')
,(q'{Enterprise Manager SNMP Support Reference Guide}')
,(q'{Error Messages}')
,(q'{Getting to Know Oracle8i}')
,(q'{Integration Server Overview}')
,(q'{interMedia Audio, Image, and Video Java Classes User's Guide and Reference}')
then add a WITH at the top and a SELECT at the bottom and you’re done!
SQL> with t(c) as ( values
2 (q'{Advanced Security Administrator's Guide}')
3 ,(q'{Application Developer's Guide - Advanced Queuing (AQ)}')
4 ,(q'{Application Developer's Guide - Fundamentals}')
5 ,(q'{Application Developer's Guide - Large Objects (LOBs)}')
6 ,(q'{Application Developer's Guide - Object-Relational Features}')
7 ,(q'{Application Developer's Guide - XML}')
8 ,(q'{Applications InterConnect User's Guide}')
9 ,(q'{Backup and Recovery Guide}')
10 ,(q'{Concepts}')
11 ,(q'{CORBA Developer's Guide and Reference}')
12 ,(q'{Data Cartridge Developer's Guide}')
13 ,(q'{Data Warehousing Guide}')
14 ,(q'{Designing and Tuning for Performance}')
15 ,(q'{Distributed Database Systems}')
16 ,(q'{Enterprise JavaBeans Developer's Guide and Reference}')
17 ,(q'{Enterprise Manager Administrator's Guide}')
18 ,(q'{Enterprise Manager Concepts Guide}')
19 ,(q'{Enterprise Manager Configuration Guide}')
20 ,(q'{Enterprise Manager Intelligent Agent User's Guide}')
21 ,(q'{Enterprise Manager Messages Manual}')
22 ,(q'{Enterprise Manager SNMP Support Reference Guide}')
23 ,(q'{Error Messages}')
24 ,(q'{Getting to Know Oracle8i}')
25 ,(q'{Integration Server Overview}')
26 ,(q'{interMedia Audio, Image, and Video Java Classes User's Guide and Reference}')
27 )
28 select * from t;
C
--------------------------------------------------------------------------
Advanced Security Administrator's Guide
Application Developer's Guide - Advanced Queuing (AQ)
Application Developer's Guide - Fundamentals
Application Developer's Guide - Large Objects (LOBs)
Application Developer's Guide - Object-Relational Features
Application Developer's Guide - XML
Applications InterConnect User's Guide
Backup and Recovery Guide
Concepts
CORBA Developer's Guide and Reference
Data Cartridge Developer's Guide
Data Warehousing Guide
Designing and Tuning for Performance
Distributed Database Systems
Enterprise JavaBeans Developer's Guide and Reference
Enterprise Manager Administrator's Guide
Enterprise Manager Concepts Guide
Enterprise Manager Configuration Guide
Enterprise Manager Intelligent Agent User's Guide
Enterprise Manager Messages Manual
Enterprise Manager SNMP Support Reference Guide
Error Messages
Getting to Know Oracle8i
Integration Server Overview
interMedia Audio, Image, and Video Java Classes User's Guide and Reference
25 rows selected.
Enjoy!




Leave a reply to science gecko Cancel reply