SQL & PL/SQL :: PLS-00402 - Alias Required In SELECT List Of Cursor To Avoid Duplicate Column
Oct 25, 2013
I am getting [Error] PLS-00402 (182: 1): PLS-00402: alias required in SELECT list of cursor to avoid duplicate column names error in my SP.I have created alias for each column and still i am getting the error.
for my_rec_lot in
(SELECT LLP.BOOK_VALUE LLP_BOOK_VALUE,LLP.COMMISSION LLP_COMMISSION,LLP.CURRENCY LLP_CURRENCY,LLP.EXCHANGE_RATE LLP_EXCHANGE_RATE,LLP.EXPENSES LLP_EXPENSES,
I created a "Select List" in the Shared Components area as follows:
My goal is to create a shared select list that can be used on any form for a particular Field.
IF :P10_FK_RSTA_CODE is NULL THEN RETURN 'select col_description, col_code_pk from CODE_TABLE where col_active_ind = ''Y'''; [code].....
Which works great, but how can I make the select list work for the same column on a different form? Because :P10_FK_RSTA_CODE is hard-coded in the function, I can't reuse this Function from a different form. (I could rename the Field on every form to the same name, but I'm hoping there is a better way.)
Is there a way I can pass in a variable from the Field Item to make this dynamic where I can use it on any form?
I have one table in which I want to restrict some records from being inserted. I don't want to put any checked constraints. e.g. consider following table
transaction( id number primary key, txn_date timestamp(7), payee varchar2(40), amount number, memo varchar2(40), ref_num number )
I want to write SQL which should not inset duplicate record.
e.g.
I have written one as bellow:
insert into transaction select 1, to_date('2009-12-12','YYYY-MM-DD'), 'Payee1', 12, 'Test', 212 from dual where (select count(*) from transaction where txn_date=to_date('2009-12-12','YYYY-MM-DD') and payee='Payee1' and amount=12)=0;
Can I use exists/not exists, which query will be more appropriate. (Please consider that fields which I am using to filter out the duplicate transactions does not contain primary key.)
Can I write such SQL. Or do i check for duplicate rows one by one and then filter the duplicate records.
I have a need to use the Alias name of a column within the same select statement( because I can't have another select statement using the first select as table - BO tool limitation).
Ex:
Select dept_id, agency, sum(quantity) as "sum_qty" where sum_qty > 500;
Currently oracle won't allow using alias name Sum_qty in the same select statement. Is there a way to use alias within the same select statement?
i have created form. one field is there "Payment_terms" at line level. for that i created LOV containing 3 fixed Payment terms. my requirement is that Avoid the user to select twice the same value from LOV.
i have a good query but I thought i know the solution but actually I didn't it's very simple and straight forward but i didn't catch the rope terminal to follow now I have the following code
NOW I NEED A QUERY which will select the only translator who knows the languages written in where clause like if i specify two languages like 'italy' and 'english' the query should retrieve to me GH and SE also if i passed languages 'spainsh' and 'persia' it should return JH only
but if i passed languages like 'Italy' and 'Dutch' it should not return any thing (just : no rows selected)
i like to display a Table data like the below format,
Output:
EMPNO JAN FEB MAR APR MAY JUN JUL AUG SEP OCT NOV DEC 00094 122 153 145 224 245 545 114 544 444 111 555 222 00095 233 123 145 224 205 545 114 444 444 111 555 222 00096 163 123 145 224 215 545 114 551 444 111 555 222 00097 163 0 145 224 215 545 114 551 444 111 555 222 conditions:
where condition: where year = 2007
Table Structure:
create table HR_PAYSLIP ( EMP_NO VARCHAR2(6) not null, YEAR NUMBER(4) not null, MONTH NUMBER(2) not null, BASIC_PAY NUMBER(9,2), )
Insert Command;
INSERT INTO PAYSLIP (EMP_NO, YEAR,MONTH,BASIC_PAY) VALUES(00046, 2007, 1, 2314);
Pls Note: The above table data i have mentioned is an example with employee numbers and the basic_pay for all months in the particular year 2007, the employee no may be more and that must be displayed only one time like above for year 2007, and if the basic salary is zero for a month then it should be displayed as zero for a particular month
I M USING APEX 4.1 AND CREATED SELECT LIST ON PAGE, I WANT TO SHOW MIN VALUE OF THE SELECT LIST FOR THAT I WROTE IN THAT SELECT LIST PROPERTIES UNDER DEFAULT TAG MIN; AND CHOOSE PL/SQL EXPRESSION BUT ITS GIVING ERROR "Error computing item default value for page item P1_PRODUCT."
BUT IF I HARDCORE THE VALUE CONTAINING IN MY DATA LIKE PRODUCT ID = 1, I HARDCODED IN DEFAULT VALUE 1 AND SELECT PL/SQL EXPRESSION IT WORKS.
BUT ITS NOT DONE LIKE THIS I WANT TO SELECT BY DEFAULT MIN VALUE OF THE SELECT LIST, SO THAT THE DATA SHOULD BE DISPLAYED ACCORDING TO THAT.
THE EXACT REQUIREMENT IS TO ENTER THE SELECT LIST DEFAULT VALUE IN SESSION SO THAT DATA IS TO BE DISPLAYED.
we use oracle 11g. 11.2. I have a situation where in a pl-sql package, there is a modification needs to be done . Every User is associated with destination codes. For eg, user1==>0101,0104 There is a destination_number and country field in the table1.Each of the destination number is associated with a country code and this combination is unique. for eg:
dest_code country_code 0101 CHINA 0202 UK 0101 Mexico 0104 Mexico
For example, if user1 logs in to the system, then pl sql logic will look if that dest_code is in a table1,If the dest_code is present in the table1, then that dest_code number wont be added to the dest_code list formed for that user. For example,if user1 got dest_codes 0101,0104 associated with him.IF 0101 is in exception table then 0101 and 0104wont be used to form dest_code list. If NOT, a dest_code list will formed like 0101||0104. I am able to form the logic like I have a cursor that loops for each dest_code.For each dest_code , it will get that dest_code into v_dest_code_no number type variable. open cursor fetch dest_code no into v_dest_code v_dummy number:=0;v_dest_code_list number:=0; LOOP v_dest_code_list:=v_dest_code ||v_dest_code ; v_dest_code :=0; END LOOP: How to make sure that for each dest_code set, if one of them is in table1, then the next number also will not be added to the list.
In my environment found maximum open cursor exceeds error. So how can I found the open cursor list and how can I close that cursor without restarting. Any SQL commands to close the open cursor.
how to select 1st record from duplicate vales in a table.
If we created one table with out primary key column In form in search block have uwi value and top_depth value when i enter uwi and top_depth value then when i click search button then it will display all values in master block.
but here duplicate values r there.
SQL> select rownum,uwi,top_depth,base_depth,test_start_date from well_pre_header;
I have a cursor in a procedure that selects columns from a table on a remote Oracle database using a database link. It all works fine when the table name and database link name is 'hard coded' into the procedure but what I would like to achieve is have the select statement lookup the table name and database link name from a column in another table. See example below
CURSOR c_total_bookings IS SELECT personnel_id, surname, forenames, birth_date,
[code]...
What I would like to do is replacecompany_bookings@remote.linkwith a variable that takes its value from another table.
I am not an Oracle programmer but I have been given a task to produce a number of Text files from an Oracle table based on a selection from the table itself.The table consists of many records with a currency code and I need to extract the data into named files based on the currency code.My first idea was to use Cursors and try a select statement matching on the returned value of the cursor but no Joy I can't make it work - perhaps I need to take a new approach.
Current / latest attempt below
DECLARE CURSOR tmp_splitter_cur IS SELECT DISTINCT end_consumer_country FROM tmp_splitter WHERE 1 = 1; currency_rec tmp_splitter_cur%ROWTYPE; [code]....
below are the create and insert statement, making duplicate row, i mean In table emp_detail, we have row like
ENAMEJOBDEPTNODETAIL RAJ CS 10 RAJ IS IN CARE OF ROHIT
We need to insert the same record but divide the last column value on the basis of "IN CARE OF" any word after this should come in next new row with the same value for all other column, like
ENAMEJOBDEPTNODETAIL RAJCS10RAJ IS IN CARE OF RAJCS10ROHIT CREATE TABLE "EMP_DETAIL" ("ENAME" VARCHAR2(10), "JOB" VARCHAR2(9), "DEPTNO" NUMBER(2,0), "DETAIL" VARCHAR2(100) [code]...
The closest I got was with the below, but this also returns duplicates within the same NAME_ID.
select phone_number, name_id from name_phone where (phone_number) in (select phone_number from name_phone group by phone_number having count(*) > 1) group by phone_number, name_id order by phone_number
Is there a way to loop through a list of literal values.
For instance create table car( name varchar2(11), passengers int, price int );
insert into car values ('fiat',1,1000); insert into car values ('bmw',2,2500) insert into car values ('ford',2,1500) insert into car values ('ferrari',4,5000)
select max(price) from car where passengers=1
How can i in a single query do this for where passengers = 1 then passengers = 2 then passengers = 3 etc where i have a list of possible values for passengers.
Just to update I realise this can be done with
select name, max(price) from car where passengers in (1,2,3) group by name
but in just wanted to know if there is a way of iterating through a literal list in tsql
column sid format 'a5' column serial# format 'a10' column mins_running format 'a15' column sql_text format 'a100' set linesize 200 set pagesize 30
[Code]..
I am running this code, and the output shows multiple lines.
TRIM(S.SID) TRIM(S.SERIAL#) MINS_RUNNING SUBSTR(Q.SQL_TEXT,1,70) ---------------------------------------- ---------------------------------------- --------------- ---------------------------------------------------------------- 700 46592 242.08 Select count(*) as count, case when count(*)>0 then 'FAIL' else 700 46592 242.08 'PASS' end as result from (SELECT cv.code_value FROM code_valu
[Code]...
Is there a way to wrap up the column for SQL_TEXT VARCHAR2(64) so that I can 1 row for the output?