Restrict the records in the CSV, based on condition
Greetings. I searched the forum for my problem and have not found an answer or the right search terms. I'm under APEX 4.1.1I have a report on a page. I show all the records to a SQL query given in my table, but in the 'export to CSV' I need limit the output based on one of the fields. Thus, for example, if I had a report such as:
SELECT x, y, Z
FROM Table1
I would like to export to CSV format for this table to limit the output such as:
SELECT x, y, Z
FROM Table1
WHERE Z = 1
Is this possible?
Thank you!
John
Hi John,.
I tested the connection now and works above for interactive report only and for the classic report, you need to do something like that because the demand is set to a different value
SELECT x, y, Z
FROM Table1
WHERE ((Z = 1 and nvl(:REQUEST,'X') like 'FLOW_EXCEL_OUTPUT%') OR nvl(:REQUEST,'X') not like 'FLOW_EXCEL_OUTPUT%')
See this example of work http://apex.oracle.com/pls/apex/f?p=46417:25
When you export to CSV you'll get 10 dept records
Tags: Database
Similar Questions
-
He had to find the way of the table based on conditions...
Hello
Please look at the specimen below...
I need to know the average of (AMOUNT) of the last three months, based on the given ID no..AMOUNT ID NO Date 588 0000053125 07/01/09 612 0000053125 06/01/09 528 0000053125 05/01/09 635 0000053125 04/01/09 700 0000053125 04/02/09 588 0000053126 07/01/09 612 0000053126 06/01/09 528 0000053126 05/01/09 635 0000053126 04/01/09 700 0000053126 04/02/09 588 0000053127 07/01/09 612 0000053127 06/01/09 528 0000053127 05/01/09 635 0000053127 04/01/09 700 0000053127 04/02/09 588 0000053128 07/01/09 612 0000053128 06/01/09
Please note that for the registration of the sample, there are only 3 ID no.... but in real time will come more ID no..
Note:
ID no. 0000053128 is to have only two recordings... here, the average should be calculated accordingly.Hello!
It should provide AVG ol 3 last records (assuming that you have in your data in a record for a month)
SELECT id_no, AVG(amount) FROM (SELECT amount, id_no, date1, row_number() over(PARTITION BY id_no ORDER BY date1 DESC) rn FROM Your_table ORDER BY id_no, date1 DESC ) WHERE rn <= 3 GROUP BY id_no
T
-
Please help me its urgent - restrict the update against a condition field
Dear friends,
I'm new to the oracle forms... I want to limit an update filed against a condition in my form.
I use multi record block. I want to disable some fields in a row for example there are 10 records in the block record I want to disable the three elements of the 2nd file based on a condition. How can I do?Hello
You can use the built form in SET_ITEM_INSTANCE_PROPERTY procedure and the appropriate property... (UPDATE_ALLOWED = PROPERTY_FALSE).For example:
begin ................ if
then set_item_instance_property(' ', ,UPDATE_ALLOWED ,PROPERTY_FALSE); set_item_instance_property(' ', ,UPDATE_ALLOWED ,PROPERTY_FALSE); else set_item_instance_property(' ', ,UPDATE_ALLOWED ,PROPERTY_TRUE); set_item_instance_property(' ', ,UPDATE_ALLOWED ,PROPERTY_TRUE); end if; end; For more information, take a look at the online help...
Greetings,
SIM -
Retrieve the value based on Condition
I recently posted a problem, I've been experiencing and the answer seemed correct was really different from what I was looking for so I start a new discussion.
I have 2 tables: TEST_BACKUP_SCHEDULES & TEST_BACKUP_STATUS on Oracle 11.2.0.3.
Here are the scripts of CREATION and insertion of the two tables:
CREATE TABLE TEST_BACKUP_SCHEDULES
(
DBNAME VARCHAR2 (30 BYTE) NOT NULL,
BACKUP_PROGRAM VARCHAR2 (20 BYTE) NOT NULL,
MY VARCHAR2 (4 BYTE)
MAR VARCHAR2 (4 BYTE),
SEA VARCHAR2 (4 BYTE),
GAME VARCHAR2 (4 BYTE),
FRI VARCHAR2 (4 BYTE),
SAM VARCHAR2 (4 BYTE),
SUN VARCHAR2 (4 BYTE),
BACKUP_HOT_COLD VARCHAR2 (4 BYTE),
INSTANCE_NAME VARCHAR2 (30 BYTE)
)
CREATE TABLE TEST_BACKUP_STATUS
(
DBNAME VARCHAR2 (30 BYTE),
RETURN_CODE VARCHAR2 (10 BYTE),
STATUS VARCHAR2 (1 BYTE),
BACKUP VARCHAR2 (1 BYTE),
DATE OF BACKUP_DATE,
DATE OF LAST_UPDATE_DATE,
LAST_UPDATE_BY VARCHAR2 (10 BYTE)
);
Insert into TEST_BACKUP_SCHEDULES
(DBNAME, BACKUP_PROGRAM, MON, MAR, SEA,
GAME, FRI, SAT, SUN, BACKUP_HOT_COLD,
INSTANCE_NAME)
Values
('orcltest', 'rman', '1', '0', 1',
'1', '1', '1', '0', 'hot ',.
"orcltest");
Insert into TEST_BACKUP_SCHEDULES
(DBNAME, BACKUP_PROGRAM, MON, MAR, SEA,
GAME, FRI, SAT, SUN, BACKUP_HOT_COLD,
INSTANCE_NAME)
Values
('orclprd', 'rman', '1', '0', 1',
'1', '1', '1', '0', 'hot ',.
"orclprd");
Insert into TEST_BACKUP_SCHEDULES
(DBNAME, BACKUP_PROGRAM, MON, MAR, SEA,
GAME, FRI, SAT, SUN, BACKUP_HOT_COLD,
INSTANCE_NAME)
Values
('orclqa', 'none', NULL, NULL, NULL,
NULL, NULL, NULL, NULL, NULL,
"orclqa");
COMMIT;
Insert into TEST_BACKUP_STATUS
(DBNAME, RETURN_CODE, STATUS, BACKUP, BACKUP_DATE,
LAST_UPDATE_DATE, LAST_UPDATE_BY)
Values
('ORCLTEST', '0', OF ', HAS ', TO_DATE (JANUARY 31, 2014 11:08:30 ',' MM/DD/YYYY HH24:MI:SS'),)
TO_DATE('01/31/2014 11:08:30', 'MM/DD/YYYY HH24:MI:SS'), 'ORACLE');
Insert into TEST_BACKUP_STATUS
(DBNAME, RETURN_CODE, STATUS, BACKUP, BACKUP_DATE,
LAST_UPDATE_DATE, LAST_UPDATE_BY)
Values
('ORCLPRD', '0', THE OF ', 'R', TO_DATE (JANUARY 31, 2014 04:52:59 ',' DD/MM/YYYY HH24:MI:SS'),)
TO_DATE('01/31/2014 04:52:59', 'MM/DD/YYYY HH24:MI:SS'), 'ORACLE');
COMMIT;
I run the following query:
SELECT DISTINCT LOWER (dbname) dbname, TO_CHAR TO_DATE, (NULL) (NULL) backup_date, TO_CHAR (NULL) "DOW".
OF test_backup_schedules
WHERE dbname NOT IN (SELECT LOWER (s.dbname) FROM backup_status s WHERE TO_DATE (backup_date, 'MON-DD-YYYY') = TO_DATE (SYSDATE, ' DD-MON-YYYY ""))
UNION ALL
SELECT LOWER (dbname) dbname, status, backup_date, TO_CHAR (backup_date, 'Day') 'DOW '.
OF test_backup_status
WHERE TO_DATE (backup_date, 'MON-DD-YYYY') = TO_DATE (SYSDATE, ' MON-DD-YYYY "")
ORDER BY ASC dbname;
I get the following results:
DBNAME STATUS BACKUP_DATE DOW
------------------------------ ------ ----------- ---------
orclprd
orclprd S 31 January 14 Friday
orclqa
orcltest S 31 January 14 Friday
orcltest
5 selected lines.
I need to add a column called PLANNED which shows if a backup was meant to operate or not the day of the week.
Sorry about the formatting. I'm new on display. Let me know if anything else is needed.
Thank you
Frank
Can you please try the below and let me know
SELECT DISTINCT LOWER (dbname) dbname.
To_char (null) status,
To_date (null) backup_date,
TO_CHAR (NULL) "DOW,"
CASE WHEN TO_CHAR (SYSDATE, 'DY') = 'MY' AND MY IN (0,1) AND THEN "YES".
WHERE TO_CHAR (SYSDATE, 'DY') = 'MAR' AND KILLS IN (0,1), THEN 'YES '.
WHERE TO_CHAR (SYSDATE, 'DY') = 'SEA' AND THE SEA IN (0,1) AND THEN "YES".
WHERE TO_CHAR (SYSDATE, 'DY') = 'GAME' AND PLAY IN (0,1) AND THEN "YES".
WHERE TO_CHAR (SYSDATE, 'DY') = 'FRI' AND SAT IN (0,1) AND THEN "YES".
WHERE TO_CHAR (SYSDATE, 'DY') = 'SAT' AND SAT IN (0,1), THEN "YES".
WHERE TO_CHAR (SYSDATE, 'DY') = "SUN" AND THE SUN IN (0,1) AND THEN "YES".
ANOTHER 'NO '.
END AS PLANNED
OF backup_schedules
WHERE dbname NOT IN (SELECT LOWER (s.dbname)
OF s backup_status
WHERE TO_DATE (backup_date, 'MON-DD-YYYY') = TO_DATE (SYSDATE, ' DD-MON-YYYY ""))
UNION ALL
SELECT LOWER (dbname) dbname,
status,
backup_date,
To_char (backup_date, 'Day') "DOW,"
'YES' ON DEMAND
OF backup_status
WHERE TO_DATE (backup_date, 'MON-DD-YYYY') = TO_DATE (SYSDATE, ' MON-DD-YYYY "")
-
restrict the application of hierarchy based on a given value at the leaf node level
Is it possible to restrict a query of the hierarchy based on a test given at the leaf node level?
For example, in the data presented below, I like to shoot the entire hierarchy for terminal nodes that have 'John' in the criteria:
Parent value criteria
Z
A Z
B HAS
C B John
D B Smith
E Z
F E
John F G
H F Neal
I have F John
Filertering on John I want to return together to resemble the following prints:
A
B
C
F
G
I have
I tried the following, but it only gives me the nodes:
SELECT
LPAD (' ', (LEVEL) * 3,'.) ') || t.Valeur
OF tbl_test t
WHERE t.criteria = "John".
START WITH t.valeur = "Z".
CONNECT BY PRIOR t.valeur = t.parent;
Rule return form the above query:
C
G
I have
Any help is greatly appreciated.It is possible, but not conventional =)
Sys_connect_by_path allows you to concatenate the path and another request of the hierarchy of dividing a value generated in the rows.
with t as ( select 'Z' as Val , null as Par, null as Criteria from dual union all select 'A' as Val , 'Z' as Par, null as Criteria from dual union all select 'B' as Val , 'A' as Par, null as Criteria from dual union all select 'C' as Val , 'B' as Par, 'John' as Criteria from dual union all select 'D' as Val , 'B' as Par, 'Smith' as Criteria from dual union all select 'E' as Val , 'Z' as Par, null as Criteria from dual union all select 'F' as Val , 'E' as Par, null as Criteria from dual union all select 'G' as Val , 'F' as Par, 'John' as Criteria from dual union all select 'H' as Val , 'F' as Par, 'Neal' as Criteria from dual union all select 'I' as Val , 'F' as Par, 'John' as Criteria from dual ) select distinct regexp_substr(path, '[^,]+', 1, level) as val from ( SELECT sys_connect_by_path(val,',') as path , rownum as row_id FROM t WHERE t.criteria = 'John' START WITH t.val = 'Z' CONNECT BY t.par = PRIOR t.val ) connect by nocycle regexp_substr(path, '[^,]+', 1, level) is not null and prior row_id= row_id and prior dbms_random.value is not null
-
The button toggle based on condition for a data block
I have a data block with elements like student, student, DOB name card (all are text elements) and view (push button).
I'm getting 100 records and it generates 100 lines and push button for each line that matches. Now, I want to turn the push button, based on the DOB. If a student < 10 DOB I won't allow them to view their profile. How to limit the age of the student?
Thank you.Hello Chris,
There are two ways to do this. A way to toggle the button (which I don't like)
1 way.
1 create a trigger on called a TIME-NEW-RECORD-INSTANCE at the block level and use the code like this...IF MONTHS_BETWEEN(SYSDATE,:DATE_OF_BIRTH)/12 < 10 THEN SET_ITEM_PROPERTY('BUTTON_NAME',ENABLED,PROPERTY_FALSE); ELSE SET_ITEM_PROPERTY('BUTTON_NAME',ENABLED,PROPERTY_TRUE); END IF;
2nd way
I prefer to use to restrict the button itself. I mean, that's when the user will press the button then show him the message otherwise call form etc. as...
1. the trigger WHEN BUTTON PRESSED, use code like this...IF MONTHS_BETWEEN(SYSDATE,:DATE_OF_BIRTH)/12 < 10 THEN MESSAGE('Not allowed to view profile.'); MESSAGE('Not allowed to view profile.'); RAISE FORM_TRIGGER_FAILURE; ELSE -- Do something here / call form... END IF;
-Clément
-
Versistand version is 2013 sp1.
I use stimulus CSV expressions in my sequence in real time and want a channel to keep its value current (last) until a certain time. Is there a way to do this?
Stimulation CSV file example:
timestamp, chan1, chan2
0,0,
10, 1,
20,1,5
30,2,10
In this example, chan2 would retain its current value until the timestamp 20.
Is it possible to implement this feature?
Kind regards
Rick Howard
Thank you! It is a valuable feedback. I can't think of a way to do natively with the functionality of reading CSV for sequences in real time. Some thoughts on how this can be done:
1. create your own utility to sequences of script based on a CSV file in real-time. Extend the functionality of having a special marker in a cell which designates not only to change the value for the channel as timestep. Do not start from scratch. This tool open source and this one the two script of sequences in real time and stimulation of reading profiles based on data sets (although in different ways).
2. with the help of software without insertion to the fault of the string value that you want to keep the initial value for the first X seconds of reading the CSV file. For example, you could play another sequence with your CSV file at fault the channel at its current value so that reading CSV does not replace the value.
-
list box given to the .csv file using write on the worksheet File.vi
Hi, I use the write on the worksheet File.vi to write data multicolumn ListBox to the .csv file. If I do record from Excel, the pop-up window shows as an attachment. And data listbox are too different. I want the data displayed in the first line not the second row (third photo).
Thank you for your help.
Before making your Save As in Excel, change the cell formatting of number. This should avoid the scientific notation conversion before you re-register.
Or just use Notepad to display the file instead of Excel.
-
I need a way to export contacts from 5 M to the CSV format. Any ideas?
If I try to use the wizard to export (from results of filter) it just turns and turns and never makes a save window. He does this for hoarding last night.
My brain was not fire any wood when I wrote this. I tried to export after that display of the filter results page (one that shows the first 2,000 records). Do from there with a million database will not work. For a later use of those who read this thread, you must click the filter of the hierarchy via the small black arrow and click on "export". It will also speed things to make a touch display that is unqiue only the details you need. This will allow the system to generate the csv files on the backend and e-mail of the user running when the charge is complete. It will be available for download at the bottom of the window today Eloqua.
-
How to select the csv data stored in a BLOB column as if it were an external table?
Hi all
(Happy to be back after a while! )
Currently I am working on a site where users should be able to load the data of csv (comma is the separator) of their client machines (APEX 3.2 application) in the Oracle 11.2.0.4.0 EE database.
My problem is:
I can't use an external table (for the first time in my life ) so I'm a little clueless what to do as the csv data is stored by the application of the APEX in a BLOB column, and I'm looking for an elegant way (at least SQL PL/SQL/maximization) to insert the data into the destination table (run validations by a MERGER would be the most effective way to do the job).
I found a few examples, but I think they are too heavy and there could be a more elegant way in Oracle DB 11.2.
Simple unit test:
drop table CBC purge;
drop table dst serving;
create table src
(myblob blob
);
create table dst
(num number
, varchar2 (6) str
);
Insert in src
Select utl_raw.cast_to_raw (1; AAAAAA ;'|| Chr (10) |
2; BATH; »
)
Double;
Desired (of course) output based on the data in table SRC:
SQL > select * DST;
NUM STR
---------- ------
1 ABDELKRIM
2 BATH
Does anybody know a solution for this?
Any ideas/pointers/links/examples are welcome!
/ * WARNING: I was 'off' for about 3 months, then the Oracle - the part of my brain has become a bit "rusty and I feel it should not be so complicated as the examples I've found sofar ' * /"
Haha, wonder about regexp is like the blind leading the blind!
However, it's my mistake: I forgot to put the starting position setting (so 1, 2, 3,... was in fact the starting position, not the nth occurrence. duh!)
So, it should actually be:
select x.* , regexp_substr(x.col1, '[^;]+', 1, 1) , regexp_substr(x.col1, '[^;]+', 1, 2) , regexp_substr(x.col1, '[^;]+', 1, 3) , regexp_substr(x.col1, '[^;]+', 1, 4) , regexp_substr(x.col1, '[^;]+', 1, 5) , regexp_substr(x.col1, '[^;]+', 1, 6) from src , xmltable('/a/b' passing xmltype(''||replace(conv_to_clob(src.myblob), chr(10), '')||'') columns col1 varchar2(100) path '.') x;
Note: that's assuming that all the "columns" passed in the string won't be lame.
If one of them might be null, then:
select x.* , regexp_substr(ltrim(x.col1, ';'), '[^;]+', 1, 1) , regexp_substr(ltrim(x.col1, ';'), '[^;]+', 1, 2) , regexp_substr(ltrim(x.col1, ';'), '[^;]+', 1, 3) , regexp_substr(ltrim(x.col1, ';'), '[^;]+', 1, 4) , regexp_substr(ltrim(x.col1, ';'), '[^;]+', 1, 5) , regexp_substr(ltrim(x.col1, ';'), '[^;]+', 1, 6) from src , xmltable('/a/b' passing xmltype(replace(';'||replace(conv_to_clob(src.myblob), chr(10), ';')||'', ';;', '; ;')) columns col1 varchar2(100) path '.') x;
-
Possible way is to restrict the user to the planning an application
Hello Experts,
I have a requirement as I want to restrict bit user related to the demand for labour in the planning depends on business unit and product.
that is... The test user could not access of the user to the company as an employee depends on some operational units and related products. So is it possible to do outside the [Chronicle] manual process.
Thanks in advance...
Are you just wanting to restrict access to specific members to enter data to or it also includes being able to 'see' only the data based on some examples. For example, in the type of financing plan, I have write access to the Dept 123 for all accounts of actual Net profit, I want they have read access to this Department? In this case, I would make sure that specific effective accounts, that I make sure that the user/group has only read access.
Thank you
Mark
-
Merge the queries based on the conditional
Apex 4.2
I have a pretty complex question. I have a page that will have a selection list on the data entry form. The selection list contains a list of both 1) Active only or 2) active and inactive areas. We show the active areas when we create a new record (P101_ID IS NULL), we appear active and inactive sectors when you edit a record (P101_ID IS NOT NULL). I have therefore two separate queries to account for each case. Simple so far.
Problem I am seeing that create two lists of selection on the page and put a separate condition on each one (hiding one of selection lists depending on the case the ID IS NULL or the ID IS NOT NULL) does not work. So I was wondering if there was a way to combine queries for that to work based on a conditional statement. I did experiment with the instructions box and unions, etc., but my questions are a bit complicated. They are as follows:
LIST OF ASSETS SECTORS (P101_ID is NULL)
Select unique ISEC.inspection_sector_name, ISEC.inspection_sector_id From INSPECTION_SECTORS ISEC left join HWE_INSPECTION_SCHEDULING SCH on ISEC.inspection_sector_id = SCH.inspection_sector_id Where (ISEC.hurricane_protection_flag = :P157_IS_HURR and ISEC.river_protection_flag = :P157_IS_RIV) AND ISEC.superseded_date is null AND ISEC.commenced_date is not null AND ISEC.inspection_sector_id not in ( Select ISEC.inspection_sectors_id From INSPECTION_SECTORS ISEC left join HWE_INSPECTION_SCHEDULING SCH on ISEC.inspection_sector_id = SCH.inspection_sector_id Where SCH.high_water_event_id = :P157_high_water_event_id AND SCH.inspection_date = :P157_inspection_date) OR ISEC.inspection_sector_id = :P157_inspection_sector_id AND ISEC.superseded_date is null Order by inspection_sector_name
LIST ACTIVE AND INACTIVE SECTORS (P101_IS is NOT NULL)
Select inspection_sector_name, inspection_sector_id From ( Select ISEC.inspection_sector_name, ISEC.inspection_sector_id, '0' as this From dual, INSPECTION_SECTORS ISEC left join HWE_INSPECTION_SCHEDULING SCH on ISEC.inspection_sector_id = SCH.inspection_sector_id Where (ISEC.hurricane_protection_flag = :p157_IS_HURR and ISEC.river_protection_flag = :P157_IS_RIV) AND ISEC.superseded_date is null AND ISEC.commenced_date is not null AND ISEC.inspection_sector_id not in ( Select ISEC.inspection_sector_id From inspection_sectors ISEC left join HWE_INSPECTION_SCHEDULING SCH on ISEC.inspection_sector_id = SCH.inspection_sector_id Where SCH.high_water_event_id = :P157_high_water_event_id AND SCH.inspection_date = :P157_inspection_date) OR ISEC.inspection_sector_id = :P157_inspection_sector_id AND ISEC.superseded_date is null UNION Select unique ISEC.inspection_sector_name|| ' [CLOSED]', ISEC.inspection_sector_id, '1' as this From dual, INSPECTION_SECTORS ISEC left join HWE_INSPECTION_SCHEDULING SCH on ISEC.inspection_sector_id = SCH.inspection_sector_id Where ISEC.superseded_date is not null and ISEC.commenced_date is not null AND ISEC.river_protection_flag =:P157_IS_RIV and ISEC.hurricane_protection_flag = :P157_IS_HURR AND ISEC.inspection_sector_id not in ( Select ISEC.inspection_sector_id From INSPECTION SECTORS ISEC left join HWE_INSPECTION_SCHEDULING SCH on ISEC.inspection_sector_id = SCH.inspection_sector_id Where SCH.high_water_event_id = :P157_high_water_event_id AND SCH.inspection_date = :P157_inspection_date) OR ISEC.inspection_sector_id = :P157_inspection_sector_id NAD ISEC.superseded_date is not null Order by this, inspection_sector_name asc
If the requests are quite complex. I tested the times and they work in APex, separately from the course. Forgive me if I have mispeled anything. But any help on this would be greatly appreciated. Thanks in advance.
Thank you for taking to your friend Frank. You are a bird-guy (my attempt at sarcasm). Nobody has questioned whether its knowledge base; more so in the way he responded to my original post did not «do» Like the people who come on this forum looking for help to those who have greater knowledge, it would be nice to be greeted a little more friendly, lol. Just my thoughts. But, feel free to correct my spelling test, grammar and syntax in my sentences so (the effort once again to emphasize that I misspelled 'AND', and that the request would not be performed--> of course... smh... you are funny)
Apparently I failed to explain the issue in its entirety. I should start by saying... "I have two separate petitions that I tested and already working and am looking to put on a list of selection (at the top) with a conditional execution statement one or the other, through the conditional statement, but again, I was looking for more so for syntax and structure." I'm sorry, I forgot to mention that.
Anyway, enough of this. I found a solution to my problem:
Within the Apex 4.2, you can have a list of selection as a page element. I want to display different results depending on whether Yes or no P101_ID is set to Null or NOT NULL
P101_ID is a primary key for a table.
P101_ID is not the exact name I use in my application / request however.
In addition, you don't need to include double; It's not make or break the query. Something that I forgot to omit them.
In addition, something along the lines of
Select inspection_sector_name, inspection_sector_id From ( .....all the stuff in query 1.......) Where P101_ID is null UNION Select inspection_sector_name, inspection_sector_id From ( ....all the stuff in query 2.....) Where P101_ID is not null
will work on a selection list in the APex. So problem solved. Thank you for all your wonderful insight, of words and thoughts. Thank you.
-
How to manage the pause embedded inside the CSV column line
Hello
I'm under pressure to make it work. I've already put this question on the forum of the APEX, but on reflection, I think that it relates more to PL/SQL rather than APEX APEX 4.1 having already utility to manage the Upload of CSV.
If you already read in the forum of the APEX, please ignore.
I'm sorry for that. Thanks for reading.
I need to develop an application that allows the user to upload a CSV file to a table of interface.
The APEX version on my workplace is 4.0.2.
I used the code of
http://dbswh.webhop.NET/HTMLDB/f?p=blog:read:0:article:11000346061523
It all works fine until recently I find
If a column in a CSV file cotain a break line (or line spacing) for example (the tester copy and paste this text which has a line break on a column in a spreadsheet)
It is the first sentence.
It is the second sentence.
It will break the 'it's the second sentence In a new column.
The contents of the CSV read next to Notepad as below
Date of assessment, Date, assessment provider, name of the assessor, Court, first name, middle name, last name, PRN person record, NHI number, assisted defendant Y/N number, is dependent on O/N, Notes, primary of ethnicity, "the ethnic origin other, please specify", gender, currently in treatment O/N, another Substance, Substance of concern 5 specified
22/09/2012, Co name of the provider, Warren Edgley, Wellington, sale, 2545554, dgsdf,, 'is the first sentence.
It's the second sentence. ', Japanese, woman, b.
This is the CSV UTIL code, please help me how can I replace the line break to a space so that the download process is correct.
In my applications, I save these lines in a table rather than a collection of APEX because the number of columns can contain greater than 50.CREATE OR REPLACE PACKAGE BODY "CSV_UTIL" AS --strip the beginning and the end quotes, then replace double quotation with single FUNCTION de_quote (p_str IN VARCHAR2, p_enc_by IN VARCHAR2) RETURN VARCHAR2 IS v_str VARCHAR2(32767) := p_str; BEGIN IF (p_enc_by IS NULL) THEN RETURN p_str; ELSE IF SUBSTR(p_str,-1) = p_enc_by THEN v_str := SUBSTR(p_str,1,LENGTH(p_str)-1); END IF; IF SUBSTR(p_str,1,1) = p_enc_by THEN v_str := SUBSTR(v_str,2); END IF; RETURN REPLACE (v_str, p_enc_by || p_enc_by, p_enc_by ); END IF; END de_quote; PROCEDURE parse (p_str IN VARCHAR2, p_enc_by IN VARCHAR2, p_sep IN VARCHAR2) IS l_n NUMBER DEFAULT 1; l_in_quote BOOLEAN DEFAULT FALSE; l_ch NCHAR (1); l_len NUMBER DEFAULT NVL (LENGTH (p_str), 0); BEGIN IF (l_len = 0) THEN RETURN; END IF; g_words := g_empty; g_words (1) := NULL; FOR i IN 1 .. l_len LOOP l_ch := SUBSTR (p_str, i, 1); IF (l_ch = p_enc_by) THEN l_in_quote := NOT l_in_quote; END IF; IF (l_ch = p_sep AND NOT l_in_quote) THEN l_n := l_n + 1; g_words (l_n) := NULL; ELSE g_words (l_n) := g_words (l_n) || l_ch; END IF; END LOOP; g_words (l_n) := de_quote (g_words (l_n), CHR(10)); g_words (l_n) := de_quote (g_words (l_n), CHR(13)); FOR i IN 1 .. l_n LOOP g_words (i) := de_quote (g_words (i), p_enc_by); END LOOP; END parse; /* Author: Oleg Lihvoinen Company: DbSWH Changes: 10.02.2011, There was a miscalculation of the file line last position in case it is the end of file */ PROCEDURE upload (p_file_name VARCHAR2, p_collection_name VARCHAR2, p_enc_by IN VARCHAR2, p_sep_by IN VARCHAR2, p_rows NUMBER) IS v_blob_data BLOB; v_clob_data CLOB; v_clob_len NUMBER; v_position NUMBER; v_char NCHAR (1); c_chunk_len NUMBER := 1; v_line VARCHAR2 (32767) := NULL; v_data_array vcarray; v_rows NUMBER := 0; n_seq NUMBER := 1; dest_offset NUMBER := 1; src_offset NUMBER := 1; amount INTEGER := DBMS_LOB.lobmaxsize; blob_csid NUMBER := DBMS_LOB.default_csid; lang_ctx INTEGER := DBMS_LOB.default_lang_ctx; warning INTEGER; l_sep VARCHAR2(100) := CASE WHEN p_sep_by = '\t' THEN chr(9) ELSE p_sep_by END; BEGIN htmldb_collection.create_or_truncate_collection (p_collection_name => p_collection_name); -- Read blob from wwv_flow_files SELECT blob_content INTO v_blob_data FROM wwv_flow_files WHERE NAME = p_file_name; v_position := 1; DBMS_LOB.createtemporary (lob_loc => v_clob_data, CACHE => TRUE, dur => DBMS_LOB.SESSION ); DBMS_LOB.converttoclob (v_clob_data, v_blob_data, amount, dest_offset, src_offset, blob_csid, lang_ctx, warning ); v_clob_len := DBMS_LOB.getlength (v_clob_data); IF v_clob_len = 0 THEN RETURN; END IF; WHILE (v_position <= v_clob_len + 1) LOOP v_char := DBMS_LOB.SUBSTR (v_clob_data, c_chunk_len, v_position); v_line := v_line || v_char; v_position := v_position + c_chunk_len; -- When the whole line is retrieved and not end of file or end of file IF v_char = CHR (10) AND v_position < v_clob_len OR v_position = v_clob_len + 1 THEN parse (p_str => v_line, p_enc_by => p_enc_by, p_sep => l_sep); v_data_array := g_words; FOR i IN 1..g_words.count LOOP IF i <= 50 THEN v_data_array(i) := g_words(i); ELSE exit; END IF; END LOOP; FOR i IN g_words.count + 1..50 LOOP v_data_array(i) := null; END LOOP; v_rows := v_rows + 1; -- exit if uploaded specified number of rows IF p_rows IS NOT NULL AND v_rows > p_rows THEN EXIT; END IF; -- Store data to collection n_seq := htmldb_collection.add_member (p_collection_name => p_collection_name, p_c001 => v_data_array (1), p_c002 => v_data_array (2), p_c003 => v_data_array (3), p_c004 => v_data_array (4), p_c005 => v_data_array (5), p_c006 => v_data_array (6), p_c007 => v_data_array (7), p_c008 => v_data_array (8), p_c009 => v_data_array (9), p_c010 => v_data_array (10), p_c011 => v_data_array (11), p_c012 => v_data_array (12), p_c013 => v_data_array (13), p_c014 => v_data_array (14), p_c015 => v_data_array (15), p_c016 => v_data_array (16), p_c017 => v_data_array (17), p_c018 => v_data_array (18), p_c019 => v_data_array (19), p_c020 => v_data_array (20), p_c021 => v_data_array (21), p_c022 => v_data_array (22), p_c023 => v_data_array (23), p_c024 => v_data_array (24), p_c025 => v_data_array (25), p_c026 => v_data_array (26), p_c027 => v_data_array (27), p_c028 => v_data_array (28), p_c029 => v_data_array (29), p_c030 => v_data_array (30), p_c031 => v_data_array (31), p_c032 => v_data_array (32), p_c033 => v_data_array (33), p_c034 => v_data_array (34), p_c035 => v_data_array (35), p_c036 => v_data_array (36), p_c037 => v_data_array (37), p_c038 => v_data_array (38), p_c039 => v_data_array (39), p_c040 => v_data_array (40), p_c041 => v_data_array (41), p_c042 => v_data_array (42), p_c043 => v_data_array (43), p_c044 => v_data_array (44), p_c045 => v_data_array (45), p_c046 => v_data_array (46), p_c047 => v_data_array (47), p_c048 => v_data_array (48), p_c049 => v_data_array (49), p_c050 => v_data_array (50) ); -- Clear the line v_line := NULL; END IF; END LOOP; END; END;
I want to know how can replace these newline within a column to a space.
If anyone has any ideas, please let me know.
Thank you very much in advance.
Ann
-
How to error if the Date is not expected for the CSV Format
Hi Experts,
I have a situation where I expect to format DATE as "LUN-DD-YYYY", but there are issues when the CSV file is created with a DATE as "MON-DD-YY" (example November 15, 12 '). The date is inserted in the DB as November 15, 12 ', so I'm looking for a way to not load these files and these folders with incorrect dates added .bad and .log files. Here is my SQL:
DROP TABLE PER_ALL_ASSIGNMENTS_M_XTERN;
create table PER_ALL_ASSIGNMENTS_M_XTERN)
PERSON_NUMBER VARCHAR2 (30 CHAR),
ASSIGNMENT_NUMBER VARCHAR2 (30 CHAR),
DATE OF EFFECTIVE_START_DATE,
DATE OF EFFECTIVE_END_DATE,
EFFECTIVE_SEQUENCE NUMBER 4,
ATTRIBUTE VARCHAR2 (30 CHAR) CATEGORY,
_ATTRIBUTE1 VARCHAR2 (150 CHAR),
...
ATTRIBUTE Numero20 NUMBER,
ATTRIBUTE DATE1 DATE,
ATTRIBUTE DATE2 DATE,
ATTRIBUTE DATE3 DATE,
ATTRIBUTE DATE4 DATE,
ATTRIBUTE DATE.5 DATE,
ATTRIBUTE DATE6 DATE,
ATTRIBUTE DATE7 DAY,
ATTRIBUTE DATE8 DAY,
ATTRIBUTE DATE9 DATE,
ATTRIBUTE DATE10 DAY,
ATTRIBUTE DATE11 DAY,
ATTRIBUTE DATE12 DATE,
ATTRIBUTE SMOKERS13 DAY,
ATTRIBUTE DATE14 DAY,
ATTRIBUTE DATE15 DAY,
ASG_INFORMATION_CATEGORY VARCHAR2 (30 CHAR),
ASG_INFORMATION1 VARCHAR2 (150 CHAR),
...
ASG_INFORMATION_NUMBER20 NUMBER,
ASG_INFORMATION_DATE1 DAY,
ASG_INFORMATION_DATE2 DAY,
ASG_INFORMATION_DATE3 DAY,
ASG_INFORMATION_DATE4 DAY,
ASG_INFORMATION_DATE5 DAY,
ASG_INFORMATION_DATE6 DAY,
ASG_INFORMATION_DATE7 DAY,
ASG_INFORMATION_DATE8 DAY,
ASG_INFORMATION_DATE9 DAY,
ASG_INFORMATION_DATE10 DAY,
ASG_INFORMATION_DATE11 DAY,
ASG_INFORMATION_DATE12 DAY,
ASG_INFORMATION_DATE13 DAY,
ASG_INFORMATION_DATE14 DAY,
DATE OF ASG_INFORMATION_DATE15
)
external organization
(the default APPLCP_FILE_DIR directory
access settings
(records delimited by newline jump 1
BadFile APPLCP_FILE_DIR: 'PER_ALL_ASSIGNMENTS_M_XTERN.bad'
APPLCP_FILE_DIR log file: 'PER_ALL_ASSIGNMENTS_M_XTERN.log'
' fields completed by ',' EVENTUALLY ENCLOSED BY ' "'
(PERSON_NUMBER,
ASSIGNMENT_NUMBER,
DATE MASK EFFECTIVE_START_DATE CHAR(20) DATE_FORMAT 'DD-MON-YYYY. "
DATE MASK EFFECTIVE_END_DATE CHAR(20) DATE_FORMAT 'DD-MON-YYYY. "
EFFECTIVE_SEQUENCE,
_ATTRIBUTE_CATEGORY,
_ATTRIBUTE1,
...
_ATTRIBUTE_NUMBER20,
DATE MASK _ATTRIBUTE_DATE1 CHAR(20) DATE_FORMAT 'DD-MON-YYYY. "
DATE MASK _ATTRIBUTE_DATE2 CHAR(20) DATE_FORMAT 'DD-MON-YYYY. "
DATE MASK _ATTRIBUTE_DATE3 CHAR(20) DATE_FORMAT 'DD-MON-YYYY. "
DATE MASK _ATTRIBUTE_DATE4 CHAR(20) DATE_FORMAT 'DD-MON-YYYY. "
DATE MASK _ATTRIBUTE_DATE5 CHAR(20) DATE_FORMAT 'DD-MON-YYYY. "
DATE MASK _ATTRIBUTE_DATE6 CHAR(20) DATE_FORMAT 'DD-MON-YYYY. "
DATE MASK _ATTRIBUTE_DATE7 CHAR(20) DATE_FORMAT 'DD-MON-YYYY. "
DATE MASK _ATTRIBUTE_DATE8 CHAR(20) DATE_FORMAT 'DD-MON-YYYY. "
DATE MASK _ATTRIBUTE_DATE9 CHAR(20) DATE_FORMAT 'DD-MON-YYYY. "
DATE MASK _ATTRIBUTE_DATE10 CHAR(20) DATE_FORMAT 'DD-MON-YYYY. "
DATE MASK _ATTRIBUTE_DATE11 CHAR(20) DATE_FORMAT 'DD-MON-YYYY. "
DATE MASK _ATTRIBUTE_DATE12 CHAR(20) DATE_FORMAT 'DD-MON-YYYY. "
DATE MASK _ATTRIBUTE_DATE13 CHAR(20) DATE_FORMAT 'DD-MON-YYYY. "
DATE MASK _ATTRIBUTE_DATE14 CHAR(20) DATE_FORMAT 'DD-MON-YYYY. "
DATE MASK _ATTRIBUTE_DATE15 CHAR(20) DATE_FORMAT 'DD-MON-YYYY. "
ASG_INFORMATION_CATEGORY,
ASG_INFORMATION1,
...
ASG_INFORMATION_NUMBER20,
DATE MASK ASG_INFORMATION_DATE1 CHAR(20) DATE_FORMAT 'DD-MON-YYYY. "
DATE MASK ASG_INFORMATION_DATE2 CHAR(20) DATE_FORMAT 'DD-MON-YYYY. "
DATE MASK ASG_INFORMATION_DATE3 CHAR(20) DATE_FORMAT 'DD-MON-YYYY. "
DATE MASK ASG_INFORMATION_DATE4 CHAR(20) DATE_FORMAT 'DD-MON-YYYY. "
DATE MASK ASG_INFORMATION_DATE5 CHAR(20) DATE_FORMAT 'DD-MON-YYYY. "
DATE MASK ASG_INFORMATION_DATE6 CHAR(20) DATE_FORMAT 'DD-MON-YYYY. "
DATE MASK ASG_INFORMATION_DATE7 CHAR(20) DATE_FORMAT 'DD-MON-YYYY. "
DATE MASK ASG_INFORMATION_DATE8 CHAR(20) DATE_FORMAT 'DD-MON-YYYY. "
DATE MASK ASG_INFORMATION_DATE9 CHAR(20) DATE_FORMAT 'DD-MON-YYYY. "
DATE MASK ASG_INFORMATION_DATE10 CHAR(20) DATE_FORMAT 'DD-MON-YYYY. "
DATE MASK ASG_INFORMATION_DATE11 CHAR(20) DATE_FORMAT 'DD-MON-YYYY. "
DATE MASK ASG_INFORMATION_DATE12 CHAR(20) DATE_FORMAT 'DD-MON-YYYY. "
DATE MASK ASG_INFORMATION_DATE13 CHAR(20) DATE_FORMAT 'DD-MON-YYYY. "
DATE MASK ASG_INFORMATION_DATE14 CHAR(20) DATE_FORMAT 'DD-MON-YYYY. "
DATE MASK DATE_FORMAT ASG_INFORMATION_DATE15 CHAR (20) 'MON-DD-YYYY ".
)
)
location ("PER_ALL_ASSIGNMENTS_M.csv")
)
REJECT LIMIT UNLIMITED;
.. example report CSV:
E040101, EE040101, 1-Aug-00: 31-Dec-12, 1, NDVC, YES, SFC, N, STIP Plan - pressure, E040101, 2080, 5, 31113, 31113, 31113, 31113, 31113, 31113, 1-Jan-12, 31-Dec-12.
Thank you
ThaiMessage details pl of the OS and database versions
Use the RRRR instead of AAAA - http://docs.oracle.com/cd/E11882_01/server.112/e26088/sql_elements004.htm#SQLRF00215
HTH
Srini -
Change the Image based on the line of dashboard
Hello
IM using OBIEE 11 G 11.1.1.5
I need to show a dashboard (Image) the company logo on a line of dashboard. I have 5 companies and each has its own logo. That a company can be selected.
Is there a way to building that?
Thank you
Published by: Andres on 16-ene-2012 12:52Hi Andres,
We can make use of the "conditional display of sections within the dashboard based on the results of the analysis. One option is certainly write different analyses (static text or narrative mode) with your company newspapers and their incorporation in the various sections of their reports in the dashboard. These sections should be displayed conditionally based on the fast one of dashboard. You can create analysis, each read the variable of presentation (associated with the command prompt) and display a record only if you choose a particular company. (Ex: create a business with a single column as @{variables.CompanyPrompt}.) Create a filter on it as "equals 'Oracle'. If this analysis, would post a record only if the presentation variable is set to 'Oracle').
I would keep you updated if I hit many effective otherwise.
I hope this helps.
Thank you
Diakité
Maybe you are looking for
-
attempt to load of autocad lt 97. He is 16-bit. Vista premium edition indicates an incompatible state to contact the vendor for an upgrade. Autodesk does not support one resolution other than buying their latest software. you think the answers ar
-
Download software and install it on the desktop.
Recently when I try to install the software from the net or my USB, it will not appear on the desktop once thethe installation is complete. What I'm doing.
-
HOW TO INSTALL A LANGUAGE BAR IN MY COMPUTER
-
yellow triangle on the lan icon
Hello I need assistance with my LAN connection I have 1 ms with the dhcp server role I get random yellow triangle on my computers and laptops the only way to fix it is to restart my VM to dc need advice Yossi.
-
Does anyone know how to fix a CODE PURPLE error? My other three Hp / Compaq machines are ALL affected by this disorder. \ I need HELP, HP told me to run out and BUY retail any OS I want AND my pc are unter warranty hp!