SQL & PL/SQL :: Writing A Join In Oracle 11g?

May 1, 2013

I have to do a query in oracle 11g

i want to cumpute the percentage of believers of every religion from the world's population

country:name,code,population

example data "Argentina" "ar" "39144753"

religion:country,name,percentage
example data
ar Jewish 2
ar Protestant 2
ar Roman Catholic 92

View 12 Replies


ADVERTISEMENT

Oracle Database Writing Slow?

Dec 31, 2011

We are using one software it is a test tool for verify the data base posting speed from server to client systems. In windows 2008 R2, database posting speed is very slow when compare to windows 2003 server .

Server configuration is same for both servers ( RAID 5 , RAM 4 GB) how we can improve writing performance in Oracle

View 1 Replies View Related

SQL & PL/SQL :: Oracle - Getting Error While Writing Procedure?

May 3, 2012

I am Getting the error when writing the procedure. How to Solve this Error .

Error: PLS-00306: wrong number or types of arguments in call to 'PUT_LINE'

View 5 Replies View Related

JDeveloper, Java & XML :: Writing XML To Oracle Directory

Apr 24, 2013

I have the following tables & data ..

create table identity (IDENTITY_ID varchar2(100));

Insert into identity values ('100');
Insert into identity values ('101');

create table CM_ENCOUNTER (IDENTITY_ID varchar2(100), CSN varchar2(100));

Insert into CM_ENCOUNTER values ('100','3a1');
Insert into CM_ENCOUNTER values ('101','1a2');

create table CM_PATIENT (IDENTITY_ID varchar2(100), GENDER varchar2(100), race varchar2(100));

Insert into CM_PATIENT values ('100','F','AA');
Insert into CM_PATIENT values ('101','M','HA');
Insert into CM_PATIENT values ('101','F','EA');

create table CM_ENCOUNTER_RFV
(IDENTITY_ID varchar2(100), CSN_ID varchar2(100), LINE varchar2(100), ENC_REASON_NAME varchar2(100));
Insert into CM_ENCOUNTER_RFV values ('100','23vx','2', 'phone');
commmit;

The output needed is :

<EvaluatePatient>
<PatientInformation>
<Patient>
<mrn>100</mrn>
<CSN>3a1</CSN>
[code]......

Based on the above, I created a table (which is of xml) ...

Create table temp_xml
as
Select XMLELEMENT("PatientInformation",(XMLELEMENT("Patient",
XMLELEMENT("mrn", s.identity_id),
XMLELEMENT("CSN", m.csn),
XMLELEMENT("Gender", p.gender),
[code]........

Now, I need to write each record into xml file. So, I used the below to write into file..but it gives me an error...wrong number of arguments to utl_file at line 14.

DECLARE
CURSOR c_data IS
SELECT * from temp_xml;
v_file UTL_FILE.FILE_TYPE;
BEGIN
[code]..........

View 4 Replies View Related

PL/SQL :: Writing User Defined Function The Same Way As The Oracle Functions

Sep 26, 2012

In one of the interviews , I have attended the guy asked me to write a user defined function which will take the column name and list all the values .

For example

Table Name:Employees
Column Name: Employee_Name

Employee_name
Scott
Ivgun
Jack
Shane

The query should be in this fromat

SELECT col_agg(Employee_name) emp_name from Employees;

The output should be

Emp_names
scott,ivgun,jack,shane

View 6 Replies View Related

Server Utilities :: Insert Data Without Writing Insert Statement In Oracle?

May 15, 2010

how to insert data in oracle table without writing insert statement in oracle 9i or above. i am not going to write insert all, merge, sqlloder and import data.

View 2 Replies View Related

SQL & PL/SQL :: Oracle Join On Tables

Sep 11, 2013

CREATE TABLE MTCH_TBL
(
S_PAID VARCHAR2(100),
S_SEC NUMBER,
H_PAID VARCHAR2(100),
H_SEC NUMBER
);
[code]....

My requirement is to match the records in MTCH_TBL and HIST_TBL on the basis of joining S_SEC(MTCH_TBL) with SEC_ALIAS(HIST_TBL) and INSTANCE (HIST_TBL) as 100 and choosing the record with max EFF_DATE from HIST_TBL.

I have come up with a query as:

select a.h_sec, a.s_paid, a.h_paid
FROM MTCH_TBL a,
HIST_TBL b
where a.S_SEC=b.sec_alias(+)
and b.instance(+)=100
and b.EFF_DATE =
[code]...

join using the EFF_DATE field also and get the expected results.My results are appearing as BLANK. However I need to produce the results as stated below:

Now, i need the results as:

H_SEC= 526
S_PAID= Q00
H_PAID = Q00

View 39 Replies View Related

Update With Join Syntax In Oracle

Apr 13, 2011

This is my working query in ms access...

UPDATE Caxnode AS A INNER JOIN Caxnode AS B ON A.node_alias = B.node_alias SET A.partition_Type = 'LDOM', A.node_mode = 'LOGICAL', A.host_id = b.host_id, A.num_of_proc = b.num_of_proc WHERE (((A.node_mode)='virtual' Or (A.node_mode)='regular') AND ((B.partition_Type)='LDOM'));

This doesn't work in oracle, I googled and read that update doesnt work with inner join in oracle..translate this query to work on oracle?

View 4 Replies View Related

Forms :: Non-Equi Join In Oracle?

Sep 16, 2010

I want to create Non-Equi relation between EMP and Salgrade Table .I am writing following Query Under Relation Tab, Its giving me error message .

emp.sal between salgrade.losal and salgrade.hisal

View 3 Replies View Related

SELECT With JOIN In Oracle Error ORA-03113?

Aug 23, 2011

When executing a SELECT with JOIN in oracle error as I am having the title. If I change the JOIN to where the procedure works normally. When installing my application, it works normally for a day or two, then it only shows the end of communication error. What I do is select the following:

SELECT /*+ FIRST_ROWS(10) */ TM1.EsqCodigo, TM1.EsqDescricao, TM1.EsqTipo, TM1.EsqConector, T2.ACnDes, TM1.EsqStatus, TM1.EsqVersaoNfeRecepcao, TM1.EsqVersaoArqNfeRecepcao, TM1.EsqVersaoArqNfe, TM1.EsqVersaoProcNfe, TM1.EsqVersaoNfeRetRecepcao, TM1.EsqVersaoArqNfeRetRecepcao, TM1.EsqVersaoNfeCancelamento, TM1.EsqVersaoArqNfeCancelamento, TM1.EsqVersaoNfeInutilizacao,

[code]...

View 2 Replies View Related

SQL & PL/SQL :: Normal Join And Outer Join

Oct 19, 2013

Lets say I have three tables t1 and t2 and t3.

SELECT * FROM T1;

Id
____
1
2
3
4

SELECT * FROM T2;

Id
____
1

SELECT * FROM T3;

Id
____
1

Now when data exists in T2 and T3, I want to return only the records in T1 that match the records in T2 and T3 which is basically a normal join

select t1.id from t1, t2,t3 where t1.id = t2.id and t1.id = t3.id

However when there are no records in T2 or T3, I want to return all records in T1 i.e 1,2,3,4

One way of doing that is using the not exists clause

select * from t1 where not exists ( select null from t2 where t2.Id != t1.id) and not exists ( select null from t3 where t1.Id != t3.id)

Is there a better way of doing this in sql ?

View 5 Replies View Related

Writing IF Statement Using SYSDATE?

Apr 22, 2011

I have an employee table. I Have to get the data of all employees in such a way that. If today I run the Query,then i have to get the data of all employees working between december 1st of previous year(current year-1 i.e., december 1st 2010.) till today(april 21st). If the query run date is in the month of december(example december 15th) then the query should get the data from december 1st of current year(december 1st 2011) to December 15th. I wrote the if statement some how its not working. I want to make use of this If or Case Statement as the start date of the employee_timestamp. Is this possible here or not.

select * from employee
where
employee.employee_timestamp > (select to_date(to_char(concat('12-01-', extract(YEAR FROM sysdate)-1)),'MM/DD/YYYY') as Startdate From DUAL)
and
employee.employee_timestamp < (SELECT SYSDATE FROM DUAL).

[code]....

View 1 Replies View Related

SQL & PL/SQL :: Writing A Code For When Condition

Feb 5, 2013

I have a problem in running a sql query.I have a dataset with the following details. Product name,product status,approval date in table product_details. I have a code as follows

select Product_name,
Product_status,
approval_date,
case
when product_status ='Cancelled' or product_status ='Stopped' then approval_date='N/A'
when product_status='Active' then NVL2(approval_date,cast(appoval_date as nvarchar2(30)),'Null')
when product_status='Completed' then NVL2(approval_date,cast(appoval_date as nvarchar2(30)),'Null1')
when product_status='Planned' then NVL2(approval_date,cast(appoval_date as nvarchar2(30)),'Null2')
end as DER_approval_date

from product_details

but i have a error in running this code saying character mismatch.

View 6 Replies View Related

Join Two Oracle Tables For Fast Fetch Of Data From Table?

Jul 2, 2012

join two oracle tables for fast fetch of data from table.

View 1 Replies View Related

Writing Same Data In Two Database Schema

Aug 3, 2011

I have two same DB schema (same structure, same data) and I need to provide update in one of them when data in the other one is updated. It is singe direction only (we change data in DB Schema A and synchronize data in the DB Schema B; there is not opposite direction). Only small portion of data (compared to the size of DB Schema) might be changed or added this way.

View 1 Replies View Related

Insertion Of Any Character After Writing 2 Words

May 3, 2006

How can i insert any character or symbol automatically after writing 2 words

E.g.

i want to enter date 20-may-06 , in this i mean it that when i enter 20 then automatically - is inserted.

is there any query in Oracle. Or Oracle Hasn't created this type of query.

View 3 Replies View Related

Forms :: 10g Error In Writing To Directory

Apr 12, 2006

I'm trying to install forms 10g on my windows 2000 professional os which is having oracle 9i client. but while installing 10g i'm geting oracle universal installer error. error in writing to directory c:...

My D drive is having 10GB free space and C drive is having 800MB free space (both drive have normal attribute i.e it's not read only ) and oracle have already copied some temp files in C drive (size 13.6 MB) .

View 7 Replies View Related

SQL & PL/SQL :: Writing A Query To Multiply Columns

Nov 26, 2012

I am writing a query and I am trying to multiply some of the columns with *1.50 and 0.75.

The columns I am trying to multiply are coke_rebate.volumecsd and coke_rebate.volumencb. I am getting an error in oracle sql command from web "ORA-00937: not a single-group group function"

Here is the code I am writing:

SELECT CUSTOMERS.CUSTID,
CUSTOMERS.MEMBERID,
CUSTOMERS.BNAME,
COKE_REBATE.COKEID,
SUM(COKE_REBATE.VOLUMECSD*1.50) "TOTALCSD",
[code]........

View 7 Replies View Related

SQL & PL/SQL :: Alternative For Writing Subquery In IF Condition

Sep 4, 2011

I am working in EBS 11i and database 9i. I know that we can not write subquery in IF condition like below.

IF deptno IN (select deptno from dept)
--
END IF;

Is there any alternative to achieve above scenario.

View 1 Replies View Related

Forms :: Writing In User Profile

Jul 14, 2010

The Scenario is that we have to restrict clients to write file on C drive for which we have to grant admin privileges(OS) which we don't wanna give. Rather they can write on their own profile.

In CMD we can find their profile with %userprofile% command,but i am confused of using it in oracle form. so is there any possibilities to redirect O/P to userprofileyour_file.txt

Just for an instance ,code is like this which is currently writing in C: drive

Declare
in_file TEXT_IO.FILE_TYPE;
linebuf VARCHAR2(80);
your_file VARCHAR2(50) := 'C:TEMPyour_file.dat';
text_line VARCHAR2(400);
[code].......

View 3 Replies View Related

SQL & PL/SQL :: Writing Multiple Files Using UTL_FILE

Aug 16, 2012

I'm trying to read the data from flat file and write data into multiple files based on the condition. The value of each line is checked with the Flag Table (Id NUMBER, FlagType VARCHAR(25), Flag CHAR(1)), If the Flag is True then new file has to be created and corresponding line has to be moved into new file otherwise it has to continue with the same file.

CREATE OR REPLACE PROCEDURE rw_demo (File_In VARCHAR2, File_out VARCHAR2) IS
InFile utl_file.file_type;
OutFile utl_file.file_type;
vNewLine VARCHAR2(4000);
i PLS_INTEGER;
j PLS_INTEGER := 0;
SeekFlag BOOLEAN := TRUE;
[code].........

View 24 Replies View Related

SQL & PL/SQL :: Difference Behind Using Of Either IS Or AS When Writing Stored Procedure?

Mar 10, 2011

Is there any difference behind that using of either IS or AS when writing Stored Procedure?

View 1 Replies View Related

Writing A PLSQL Procedure To Housekeep Files?

May 22, 2007

I am trying to implement a Houskeeping program for files generated in 4 different servers. This housekeeping program is run as a batch job and I need to use PLSQL to implement it. The files need to be housekept on the basis of the file creation date.

how I can go about doing this using a PLSQL stored procedure.

View 3 Replies View Related

Prevent Other Sessions From Writing To The Tables In Procedure?

Jun 26, 2013

here' my code.

delimiter //
SELECT CONNECTION_ID()//
LOCK TABLES source.jos_daikin_control_card_fcu_model WRITE//

[Code].....

ERROR 1192 (HY000): Can't execute the given command because you have active lock
ed tables or an active transaction

Is there a way to prevent other session from accessing the tables called in the procedure?

View 3 Replies View Related

Forms :: Fields Not Writing To Database Table

Jul 27, 2010

I have an Oracle Form 6i. There are two blocks. One is a database block called CUSTOMER and the other is a non-database block called CONTROL.

In the PRE-INSERT trigger of the database block, values from the non-database table block are passed to the database table block. When I pass values I use the :BLOCK_NAME.field_name eg. :CUSTOMER.scale_code := :CONTROL.scale.

In this form the values passed to the database block from the non-database block in the PRE-INSERT trigger do not use the block name e.g. :-

:warehouse := :global.default_warehouse;
:capturer :=captured
:scale_code := scale;
:date_captured := sysdate;
insert into dd_audit(cus_id,cap_date) values(:CONTROL.cus_id,SYSDATE);

This application used to work fine for months, last week when writing the values in the PRE-INSERT trigger, just the warehouse field had a value. The remaining fields after the warehouse did not pass any values, although it was verified that values would have been present in the non-database block. The date_captured field should have at least had the system date. The last insert into dd_audit was successful.

I have done numerous tests on our test database and could not replicate the problem. Would passing the values from the non-database block to the database block without the :BLOCK_name preceding the field name cause this problem.

View 4 Replies View Related

SQL & PL/SQL :: Writing Turkey Characters To Text File?

Oct 8, 2013

Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production
PL/SQL Release 11.2.0.3.0 - Production
CORE 11.2.0.3.0 Production
TNS for Linux: Version 11.2.0.3.0 - Production
NLSRTL Version 11.2.0.3.0 - Production

I am trying to write the Turkey character stored in the table in VARCHAR2 to Unix file. But when the text is written to the unix, the characters are coming as junk.

The output of the file it is writing is as below after the execution

Fis Içe Aktarma Olusturuldu Header
Fis Içe Aktarma Olusturuldu
Fiş İçe Aktarma Oluşturuldu

Instead I expect the chararecter to be as "Fiş İçe Aktarma Oluşturuldu Header" which when converted to English will show as "Created Import Plug Header".

DROP TABLE TEST_JUNK_CHAR
/
CREATE TABLE TEST_JUNK_CHAR (primary_description VARCHAR2(400))
/
INSERT INTO TEST_JUNK_CHAR VALUES('Fiş İçe Aktarma Oluşturuldu Header')

[code]....

View 13 Replies View Related

SQL & PL/SQL :: UTL_FILE.PUT_LINE Is Not Writing Data To A File?

Jan 18, 2011

I want to extract data from a table and write into a txt file using UTL_FILE utility.I have written the below query. I am able to see query is returning data.But it is not creating file and writing data into it.

CREATE OR REPLACE DIRECTORY DOC_PATH AS '/apps/orarpt/SJDEV/utl'
CREATE OR REPLACE PROCEDURE xxcfi_outbound_test (errbuf OUT VARCHAR2,
retcode OUT VARCHAR2)
AS
CURSOR emp_cur

[code].....

View 1 Replies View Related

PL/SQL :: Writing A Query To Delete Duplicates From A Table

Aug 16, 2012

I have data some thing like this.

NO NAME LOC SAL
------------------------------------------------------------------
1 A HYD 100
2 B BGL 200
1 A HYD 200
1 A HYD 150

I want to delete duplicate records (group by no,name,loc) but only max(qty) record should be retained. So I need output like this.

NO NAME LOC SAL
------------------------------------------------------------------
1 A HYD 200
2 B BGL 200

View 3 Replies View Related

Server Administration :: Writing Control File

Nov 25, 2011

I was doing some R&D on my test machine trying to understand how controlfile works. I started up my db and then deleted (renamed)the controlfiles at OS level. I was expecting the db to shutdown. But it dint. Moreover when i queried select name from v$controlfile; it was still reflecting the old controlfile names. To check if it was still functioning, i created a new tablespace with one file and it also got created without any error.

What i dint understand is how could the db still be running when the control file was'nt there and new tablespace and datafile get created? As i understand, whenever a new file is created, an entry is made in the control file. But when control file dint exist where was the data about new tablespace and datafile written?

View 5 Replies View Related

Forms :: Reading And Writing Data In A Text File

Mar 8, 2011

I need to read data from text file(located on application or db server or on some other server, however path is known to me.) and then append some data in it.

Data will be read and written on daily basis so i want to clear all data on date change.

View 3 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved