oracle10g

Can you help me write a procedure in Oracle to spool data from a table to a CSV file?

爱⌒轻易说出口 提交于 2019-12-01 13:19:52
问题 I am writing a procedure to create a CSV file with the data in an Oracle table. I used "spool filename;" but an error is coming. Can I use spool in PL/SQL? 回答1: I think that there are better ways to implement this on Oracle 10g/11g, but this should work fine on Oracle 9i or higher: CREATE OR REPLACE PROCEDURE prc_file_mult_column_generate( p_file_dir VARCHAR2, -- mandatory (Oracle directory name) p_file_name VARCHAR2, -- mandatory p_sql_query VARCHAR2, -- Multiple column SQL SELECT statement

Storing Files in Oracle DB's CLOB field

痴心易碎 提交于 2019-12-01 13:15:20
I have a column in my oracle table with CLOB datatype. How do I store .txt file in this column and how can I retrieve the same file? Below is the table definition fileID Number logFile CLOB Thanks in advance Loading a file into a CLOB in PL/SQL is pretty easy-- you just need to use the DBMS_LOB.LoadCLOBFromFile procedure CREATE DIRECTORY file_dir AS <<path on database server file system>>; GRANT read, write ON file_dir TO your_user_name; DECLARE l_src_file bfile := BFileName( 'FILE_DIR', <<name of file>> ); l_dest_lob clob; l_dest_offset integer := 1; l_src_offset integer := 1; l_lang_context

System.Data.OracleClient requires Oracle client software version 8.1.7 or greater

此生再无相见时 提交于 2019-12-01 12:51:06
I have installed Oracle client version 10g on my PC(Registry ORACLE_BASE-D:\oracle\product\10.2.0). I have added below references. System.Data.OracleClient. I am getting above mentioned error. Below is the Code Snippet . public static OracleConnection getConnection() { try { dataSource = new SqlDataSource(); dataSource.ConnectionString = System.Configuration.ConfigurationManager.AppSettings.Get("conn"); OracleConnection connection = new OracleConnection(); if (dataSource == null) { // Error during initialization of InitialContext or Datasource throw new Exception("###### Fatal Exception ######

Extract code or script of database objects

。_饼干妹妹 提交于 2019-12-01 12:48:13
问题 I need to extract code(script) from all my functions, procedures, packages, views and tables, so that when I move to production I could run the script to create all the objects. While developing I did not take script backup of all database objects. What is the best way to extract code or script? Any suggestion or help is highly appreciable. Thanks 回答1: You do use a version control system don't you? Please do. Failing that you can use the system function dbms_metadata.get_ddl, which will

How to schedule a job in pl/sql?

做~自己de王妃 提交于 2019-12-01 11:53:51
I have created one stored procedure with name traffic_details_temp_send_mail; How to make this procedure to run everyday at 10AM? Please help with block of code. Thanks in advance. you can create a scheduler job: begin dbms_scheduler.create_job(job_name => 'TRAFFIC_DETAILS_JOB', job_type => 'STORED_PROCEDURE', job_action => 'traffic_details_temp_send_mail', start_date => systimestamp, end_date => null, repeat_interval => 'freq=daily; byhour=10; byminute=0; bysecond=0;', enabled => true, auto_drop => false, comments => 'your description here.'); end; / then you can see the details in the

System.Data.OracleClient requires Oracle client software version 8.1.7 or greater

試著忘記壹切 提交于 2019-12-01 11:10:36
问题 I have installed Oracle client version 10g on my PC(Registry ORACLE_BASE-D:\oracle\product\10.2.0). I have added below references. System.Data.OracleClient. I am getting above mentioned error. Below is the Code Snippet . public static OracleConnection getConnection() { try { dataSource = new SqlDataSource(); dataSource.ConnectionString = System.Configuration.ConfigurationManager.AppSettings.Get("conn"); OracleConnection connection = new OracleConnection(); if (dataSource == null) { // Error

Storing Files in Oracle DB's CLOB field

冷暖自知 提交于 2019-12-01 10:52:06
问题 I have a column in my oracle table with CLOB datatype. How do I store .txt file in this column and how can I retrieve the same file? Below is the table definition fileID Number logFile CLOB Thanks in advance 回答1: Loading a file into a CLOB in PL/SQL is pretty easy-- you just need to use the DBMS_LOB.LoadCLOBFromFile procedure CREATE DIRECTORY file_dir AS <<path on database server file system>>; GRANT read, write ON file_dir TO your_user_name; DECLARE l_src_file bfile := BFileName( 'FILE_DIR',

a Rollup query with some logical netting using Oracle SQL

佐手、 提交于 2019-12-01 10:32:26
问题 I have a table "AuctionResults" like below Auction Action Shares ProfitperShare ------------------------------------------- Round1 BUY 6 200 Round2 BUY 5 100 Round2 SELL -2 50 Round3 SELL -5 80 Now I need to aggregate results by every auction with BUYS after netting out SELLS in subsequent rounds on a "First Come First Net basis" so in Round1 I bought 6 Shares and then sold 2 in Round2 and rest "4" in Round3 with a total NET profit of 6 * 200-2 * 50-4 * 80 = 780 and in Round2 I bought 5

SQL to delete the duplicates in a table

余生颓废 提交于 2019-12-01 09:41:31
I have a table transaction which has duplicates. i want to keep the record that had minimum id and delete all the duplicates based on four fields DATE, AMOUNT, REFNUMBER, PARENTFOLDERID. I wrote this query but i am not sure if this can be written in an efficient way. Do you think there is a better way? I am asking because i am worried about the run time. DELETE FROM TRANSACTION WHERE ID IN (SELECT FIT2.ID FROM (SELECT MIN(ID) AS ID, FIT.DATE, FIT.AMOUNT, FIT.REFNUMBER, FIT.PARENTFOLDERID FROM EWORK.TRANSACTION FIT GROUP BY FIT.DATE, FIT.AMOUNT , FIT.REFNUMBER, FIT.PARENTFOLDERID HAVING COUNT(1

How to include the column USER_VIEWS.TEXT in a where clause

笑着哭i 提交于 2019-12-01 09:40:33
This seems like it should have been an easy thing to figure out but I am struggling to find any answers. I want to be able to query against the USER_VIEWS table in Oracle to find other views that are using a particular table. Something like: SELECT view_name, text FROM user_views WHERE text LIKE'%MY_TABLE%' I get the error: ORA-00932: inconsistent datatypes: expected NUMBER got LONG The datatype for TEXT is LONG and in TOAD it shows WIDEMEMO. I have tried casting it, to_char and concatenating. I tried creating another table with just the TEXT data and I get ORA-00997: illegal use of LONG