What I want to do is add is this logic: If Predirection is null, then no space between streetno & streetname. Same for postdirection and unitname. (for example, if both postdirection and unitname are null, there are no spaces between streettype and the comma before propertycity)
Also, when unitname is not null, I want to add the string "Unit " prior to the returned value in unitname.
Am trying to extract data from oracle onto flatfile(.txt), am using UTL_FILE but, NULLs in oracle tables are getting converted into space and if i try loading into table it is getting loaded as space,
I'm on 11.2.0.3. I want to write a query to get calculate a running total of incidents per day - this query will be used for an APEX line chart.Sample table and data:
create table sales ( id number primary key, time_of_sale date, item varchar2(20)); insert into sales values (1, to_date('02-JAN-2013','DD-MON-YYYY'), 'book'); ....
We have data as below in the table. I need the to display the records in the order based on number of NULL values and position for each record.
provide a simple query using case in ORDER BY clause.
ID CLASS NAME DIST_ID DIST_NAME 0 NULL KIRAN 0 AP 0 C1213 NULL 0 AP 0 NULL NULL 0 AP NULL C1234 NULL 0 AP 0 NULL NULL 0 AP NULL NULL NULL NULL NULL 0 C123 RAJESH 0 AP NULL C123 RAVI NULL AP
We have to give the rank based on NULL values and NULL value column position.Let us assume column positions as
1 2 3 4 5 ID CLASS NAME DIST_ID DIST_NAME
for the following three records number of NULL values are same. but positions are different.
0 NULL NULL 0 AP NULL C1234 NULL 0 AP 0 NULL NULL 0 AP NULL C123 RAVI NULL AP
Based on the column positions the ranks as 2*2+3*3=13 1*1+3*3=10 2*2+3*3=13 1*1+4*4=17
Which is having high rank (greatest number) that record should come last . The record which is having all values that should come first. The record which is having all NULL values should come last. The out put I want as
ID CLASS NAME DIST_ID DIST_NAME 0 C123 RAJESH 0 AP 0 NULL KIRAN 0 AP 0 C1213 NULL 0 AP NULL C1234 NULL 0 AP 0 NULL NULL 0 AP 0 NULL NULL 0 AP NULL C123 RAVI NULL AP NULL NULL NULL NULL NULL
What I want to produce is a table in the following format
basket_ref, all_fruit 1, apple banana pear 2, apple lemon
There could theoretically be any amount of fruit in a given basket, so I will need to set up some kind of loop in order to read each record from the original table. I am not sure how it would be best to do this.
If there are even more levels, I also need those childs to be shown right below their parent and with POS as 10.20.10 )(for the first item below POS 10.20.
I'd like to concatenate my 3 columns into one. I have this text item(NAME) and i want my columns lname, fname and mname to be bound into name text item.
this is so far my code to do the concat:
SELECT lname INTO :ADVISEMENT.name FROM students WHERE :ADVISEMENT.name = lname || ',' || fname || ',' || mname;
i m create one function in which i have to concatenate result likeDate is 19/07/2010'. i tried to concatenate in select statement. in this case function is created successfully but it gives error when it run.
CREATE or replace function TEST(FINYEAR VARCHAR2) RETURN VARCHAR2 AS QRY_STRING VARCHAR2(1000); BALANCE VARCHAR2(100);
[code]...
ERROR at line 1: ORA-00923: FROM keyword not found where expected ORA-06512: at "TEST", line 11
I have three database fields on my form , field_1 , field_2 and field_3 , user will enter the data in field_1 , and sometime he may not enter in field_2 ,
I want to bring the value of field_1 as it is into field_3 if he does not enter anything in field_2, if he enters the data in field_2 , then field_1 will get concatenated with field_2 and gets copied into field_3.Is there a way to do this automatically at form level using a trigger when-validate-item.In short this should be done after user presses the enter key on field_2.
create table ot_Sale_code_head ( sale_code varchar2(12),code1 varchar2(6),code2 varchar(6),code3 varchar2(12)); insert into ot_Sale_code_head ('A','01.01',NULL,NULL); --inserted record in form will be 'A','01.01',NULL,'01.01' insert into ot_Sale_code_head ('B','01.01','PS-P',NULL); --inserted record in form will be 'B','01.01','PS-P','01.01.PS-P'
SELECT country_name, substr(SYS_CONNECT_BY_PATH(product_name,','),2) as PRODUCT_NAME, substr(SYS_CONNECT_BY_PATH(SPEED_VALUE,','),2) as SPEED_VALUE, substr(SYS_CONNECT_BY_PATH(i.SUPPLIERNAME_ACCESSPROTYPE,','),2) as SUPPLIERNAME_ACCESSPROTYPE FROM (SELECT b.country_name,b.product_name,b.speed_value,(supplier_name|| supplier_product || access_product_type)as [code].......
In the result , I am getting repeated values for product_name and speed value,something like 'ALL Products,All Products,All Products'in the product_name column and '128Kbps,128Kbps'in Speed_vale.i am not able to remove the repeated values here.
create or replace procedure ab(a in varchar2, b in varchar2) is test varcha2(8); begin if (a is not null) then for i in(select c from t where c between ||'''||a||'''|| and ||'''||b||'''||) loop test:=i.c end loop; end if; end;
I want both parameter input values to be enclosed in quotes so that it considers both parameter values as char.Receiving ora 00936 missing expression error.
I want to load a delimited file that contains many records which contained within the table where I'm going to load a date type field and I need to do this by concatenating three fields
field1 = 1 - this is the day field2 = 11 - this corresponds to the month field3 = 5 - this corresponds to the year
I need is in the field Save as type date 01/11/2005 i don´t know how to do it but I tried as follows but I get error loading.
I am loading data using sqlldr command in UNIX to an oracle table and want to concatenate timestamp to a file name in the "create_file_name" column in the code below.
I have the below code within the control file..
LOAD DATA TRUNCATE INTO TABLE TABLEA TRAILING NULLCOLS ( file_type POSITION(1:5) CHAR, business_date POSITION(16:23) DATE "YYYYMMDD", create_file_name "FILE_NAME" EXPRESSION "SELECT TO_CHAR(CURRENT_TIMESTAMP(3), 'YYYYMMDDHH24MISS') FROM DUAL")
The load fails with SQL Loader error: "Expecting valid column specification, ",", ")", found keyword EXPRESSION found instead of column. How the timestamp to a filename can be appended?
db and dev 10g rel2 ,suppose that i have a table with a lot of duplicate rows ,what i need is to delete the duplicates and retain one row of these duplicates . likecolumn -- with those values...how to delete two (hi's) and retain the third , ?it is all applied to all the duplicate values in the column.
Trying to delete duplicate rows from a table. The problem is, they aren't exactly duplicate rows. Let me explain.
I am migrating data from a Oracle 8.1.7 db to a 10.2.1 db. In the older db, this certain table does not have a PK/Unique Index, but in the new db there is a unique index. The fields that the index is unique on are:
In the old db, when I run this query I get 1229 rows. With a count of 2 each.
select SUBSCR_NO, SUBSCR_NO_RESETS, EXTERNAL_ID, EXTERNAL_ID_TYPE, ACTIVE_DATE, count(*) from customer_id_equip_map group by SUBSCR_NO, SUBSCR_NO_RESETS, EXTERNAL_ID, EXTERNAL_ID_TYPE, ACTIVE_DATE having count(*)>1;
They are duplicates on those fields, but they are not totally duplicate rows because there is a field called is_current that has 0 in one row and has 1 in the other. What I need to do, is delete the 1229 rows with is_current=0.
First one : ----------------- 1)Created a backup table from the Fragmented table (This table is a partitioned one). 2)Analyzed this table. 3)DROP the Fragmented table 4)Inserted the backuped up data from backup table to the Re-created table. 5)Analyze this table.
Second method ------------------- 1) Create a backup table newly, with PCTFREE =0 2) Inserted the data from Fragmented table ( This is a partitioned table) to backup table 3) Analyzed this table. 4) Truncate Fragmented table 4) Did Exchange partition of Fragmented table with Backup table.
The second method is not found to be removing the Fragmentation. Before the fragmentation was 28% after Second method the fragmentation is still the same. While the first method the fragmentation reduced to 16%.
Query used to find Fragmentation. select table_name, round((blocks*8),2) "table size kb", round((num_rows*avg_row_len/1024),2) "actual data in table kb", round((blocks*8),2)- round((num_rows*avg_row_len/1024),2) "wasted space kb",
One of my clients need to remove three(of four) CPU to comply the licensing agreement with Oracle.
To avoid problems and also to list the possible problems that removing the CPU can bring, I wish to make a survey of the possible impacts, especially in performance, that removal can cause.