SQL & PL/SQL :: Can Call A Function Within Decode Statement

Oct 19, 2011

Can we call a function within decode statement. I am able to do the same for simple example function . But In my actual procedure it's giving the error message . Are there any restrictions to call function with in decode statement?

View 4 Replies


ADVERTISEMENT

SQL & PL/SQL :: Using Select Statement In Decode Function?

May 11, 2010

I am trying to use decode function in sql and inside decode function can I use select statement ?

here is my sql

select we.wf_entity_id, decode(object_type_id,
1, select audit_number from ea_audit_general where sys_audit_id=object_id
2,'test',
object_type_id
) from wf_entity we
where

[code]....

see this

decode(object_type_id,
1, select audit_number from ea_audit_general where sys_audit_id=object_id
2,'test',
object_type_id
)

will this work? Its not working for me?

View 2 Replies View Related

SQL & PL/SQL :: Call Function With Row Type Return In Oracle Select Statement

Jul 3, 2012

How to call a function with a row type return in an Oracle select statement.

For e.g. :

If I had this function with a rowtype return:
------------------------------
create function abc
return xyz%rowtype
is
rec xyz%rowtype;
begin
select * into rec from xyz where col1 = n;
return rec;
end;
--------------------------------
How could I use this in a select clause, as there is a multi column return by the function ?

View 5 Replies View Related

SQL & PL/SQL :: Decode Statement In Query

Aug 12, 2010

I have used a decode statement in my query instead of using select * from <table_name> where value in <>

Instead I have used decode(value,<value1>, <value2>)

Which would be a better performance code?

View 5 Replies View Related

PL/SQL :: Case When Statement In Decode

Dec 14, 2012

Here is one an example with CASE WHEN statement.

SELECT empno,ename,sal,
CASE
WHEN sal BETWEEN 800 AND 1200
THEN 'Lowest Pay'

[Code]...

even DECODE can be a replacement for this scenario, but it cannot have as flexibility as CASE can have.

Now, I want Equivalent code for DECODE..

View 11 Replies View Related

PL/SQL :: Decode Statement Within Inner Join?

Apr 22, 2013

I'm having some trouble writing this query using a decode statement within a join. First, lets say I have two tables. Table A has the fields 'Baseline', 'NAD', 'Null', and 'Harn'. Table B has the fields 'Null', 'NAD', and 'Harn'. I want to join these tables together by these fields to return their ID's. Because table B doesn't have 'Baseline' to even have a match between the two tables, in Table A, we want to treat 'Baseline' as 'Harn', hence a decode statement. My query is below

Select
...
...
...
From
...
inner join oracle_srid_xref B on A.horizontal_datum = B.horizontal_datum and
decode(A.horizontal_epoch, 'BASELINE', 'HARN', loc.horizontal_epoch ) = B.horizontal_epoch

I'm not getting the ID's where the horizontal_epoch was initially 'Baseline'

View 5 Replies View Related

SQL & PL/SQL :: Getting Equivalent DECODE For CASE Statement?

Feb 21, 2013

case when age <= 17 then '<= 17'
when age >= 40 then '>= 40'
else to_char(t.age)
end age

the case statement above doesn't work in my 8.1.7 cursor statement within my pl/sql block so I need an equivalent decode

View 10 Replies View Related

SQL & PL/SQL :: How To Use DECODE For A Column In Update Statement

Apr 9, 2010

I have to conditionally update a set of columns in a table. If the column status_code_stage_3 IS NULL THEN I have to update the column status_code_stage_2. The below query is giving error:-

Test Table create scripts
CREATE TABLE test11( date_stage_3 date, reason_code_stage_3 varchar2(20),
reason_code_stage_2 varchar2(20), opportunity_date date )
INSERT INTO test11 values(sysdate,'reason1',NULL,sysdate)
INSERT INTO test11 values(sysdate,NULL,'reason2',sysdate)

[code]....

how to work out the update statement to use the conditional statement for columns.

View 2 Replies View Related

SQL & PL/SQL :: How To Use Decode Function

Oct 31, 2011

How can i use the decode function?

for example

I have the value of 1000 then the numbers 50-100 will be 'A' and 1-49 = 'B'?

View 9 Replies View Related

SQL & PL/SQL :: Decode Function

Apr 4, 2013

DECODE(:P_PERIOD_TYPE,'PJTD','PROJECT-TO-DATE','PTD','PERIOD-TO-DATE','YTD','YEAR-TO-DATE')

what does it mean..

View 3 Replies View Related

SQL & PL/SQL :: Use Decode Function

Aug 19, 2010

select
DECODE(PAA.C_TYPE_DESC,'TXIS CASUAL LEAVE',NVL(PAA.ABSENCE_DAYS,0)) TCL,
DECODE(PAA.C_TYPE_DESC,'TXIS SICK LEAVE',NVL(PAA.ABSENCE_DAYS,0)) TSL,
DECODE(PAA.C_TYPE_DESC,'TXIS PRIVELEGE LEAVE',NVL(PAA.ABSENCE_DAYS,0)) TPL
from PER_ABSENCE_ATTENDANCES_V PAA

i want to use nvl function within decode function

means if C_TYPE_DESC is 'TXIS CAUSAL LEAVE' it return ABSENCE_DAYS but if ABSENCE_DAYS are null it will be return 0 else it should be return Absence_days

View 12 Replies View Related

Using 2 Tables With Decode Function

Nov 8, 2009

What I have to do is this:

List supplier�s name, id, number of pending orders, number of completed orders and number of all orders from this supplier. (my query doesn't include the last part yet).

My tables are as follows:

Suppliers:
S_ID
NAME
ADDRESS
PROVINCE
PHONE_NUMBER

Orders:
ORD_ID
SUPPLIER_ID
ISSUING_EMP_ID
ORDER_DATE
ORDER_STATUS

and this is what I have so far:
select name, s_id
sum(decode(order_status, 'P',1,0)) pending,
sum(decode(order_status, 'C',1,0)) completed
from suppliers
where s_id in
(select supplier_id from orders);

but I still get an error that says "sum(decode(order_status, 'P',1,0)) pending,
*
ERROR at line 2:
ORA-00923: FROM keyword not found where expected"

I assume this is because I'm not properly referencing the orders table.

View 1 Replies View Related

SQL & PL/SQL :: Use DECODE Function For Getting Result

Aug 28, 2012

I have a table like Create temptbl (Client_status CHAR(1), Rollbak NUMERIC(3), count_org NUMERIC(3), count_member NUMERIC(3))

With Values
Cliet_Status Rollbak count_org count_member
------ ------- --------- ------------
Z 3 7 5
P 39 5 8
R 49 1 6
S 5 6 4

I need to use DECODE function for getting the result like

IF client_status NOT IN('Z', 'P')
THEN rollbak in(7, 39,49,10)and count_org is not null and count_member is not null.
ELSE NULL

View 3 Replies View Related

SQL & PL/SQL :: Write Nested Decode Statement With Multiple Searches

Nov 27, 2010

I was trying to write nested decode statement with multiple searches. For example

Case when seq = 1 and date1 > date2 then Record_Name End

How can i modify this to decode.

View 4 Replies View Related

SQL & PL/SQL :: Assignment In Result In Decode Function

Dec 13, 2011

I have 3 tables.

Table 1 have 3 columns
ID, CUS_NAME, LOC
insert into table1 values (001,ABC,North);
insert into table1 values (002,DEF,South);
insert into table1 values (003,GHI,West);

Table 2 have 3 columns
ID, CUS_NAME, LOC
insert into table2 values (001,ABC,North);
insert into table1 values (002,DEF,East);
insert into table1 values (003,JKL,South);

Table 3 is Result_Tab table having 8 columns
ID, TAB1_CUS_NAME, TAB2_CUS_NAME, Cus_Name_Res, TAB1_CUS_LOC, TAB2_CUS_LOC, Cus_LOC_Res, Comment.

I have written two cursors which fetches data from both the tables and compares each data between each other and inserts the value into the result table.

the code is as follow:

Insert into Result_Tab values
(T1.ID, T1.Cus_Name, T2.Cus_Name, decode(T1.Cus_Name,T2.Cus_Name,'Y','N'),T1.LOC, T2.LOC, decode(T1.LOC,T2.LOC,'Y','N'),Null);

Now I want the resul as follows:
ID T1.N T2.N N_Res T1.L T2.L L_Res Comment
001 ABC ABC Y North North Y Null
002 DEF DEF Y South East N Loc
003 GHI JKL N West South N Name, Loc

Is there a way wherein i could capture the column names in decode function when it doesn't match, so that I can insert the same in the comment column.

View 4 Replies View Related

SQL & PL/SQL :: Using Decode Function With Group By Rollup?

Oct 18, 2010

I am trying to use decode funtion with GROUP BY ROLLUP.

MY query is working fine when i use this two queris individually

SELECT SUM(SAL),DEPTNO,JOB FROM EMP GROUP BY ROLLUP ((DEPTNO),(DEPTNO,JOB));
SELECT SUM(SAL),DEPTNO,JOB FROM EMP GROUP BY ROLLUP((JOB),(DEPTNO,JOB));
But when i use Decode funtion so that i can combine above two scenarios it is not working
SELECT SUM(SAL),DEPTNO,JOB FROM EMP GROUP BY ROLLUP ( DECODE(:A,'S',((DEPTNO),(DEPTNO,JOB) ),((JOB),(DEPTNO,JOB) ) ) )

View 3 Replies View Related

PL/SQL :: Using Function On Decode Or Case In Query

Mar 3, 2013

I am using oracle 11G database,I have to check length of name column value from employee table and if length(name) > 39 then value should be substr(name,0,39) else value should be name only. i tried below code

select CASE when length(name) > 39,substr(name,0,39)
else name
END

from employee but its not working ..can I do this using decode too ? ,,which one would be better or this is not a right way ?

View 3 Replies View Related

Forms :: Two Cursor Record Block - Decode Function

Sep 16, 2010

I have Two cursor record block..which is attached in form..

My TASK IS

In my first Block, When DBCR Column = 'D' Then in backend this column value should be save as a '1'
WHEN DBCR Column = 'C' Then Then in backend this column value should be save as a '2'

My Both Field is on Data Block...

In Property palette of this field can we write any decode condition..so it reflects directly on database.

View 2 Replies View Related

PL/SQL :: How To Store Statement In Varchar And Call EXEC

Jun 11, 2012

So this statement works:

SELECT column_name BULK COLLECT INTO table_column_list FROM all_tab_columns WHERE table_name = conv_tablename AND OWNER IN (SELECT USER FROM DUAL);

However I want to add conditions like " AND column_name <> 'abc' " at the end. So i tried to store this in a varchar and call EXEC on it:

select_column_value_sql_stmt := 'SELECT column_name BULK COLLECT INTO table_column_list FROM user_tab_columns WHERE table_name = '''|| conv_tablename || '''' || inexclude_column;
EXECUTE IMMEDIATE select_column_value_sql_stmt;     

No matter how I concatenate the conv_tablename part, i get an error. either invalid identifier or unimplemented feature.

so is there a way to do this at all?

View 3 Replies View Related

Call A Function In IN Of WHERE Clause

Oct 28, 2010

Can we call a function in IN of "WHERE" clause.I mean to say like:

Select *
FROM table1,table2
WHERE table1.col=table2.col and CONDITION IN FUNCTION1

View 1 Replies View Related

SQL & PL/SQL :: How To Call Outside Function In Procedure

Dec 3, 2011

How to call outside function in procedure

View 11 Replies View Related

SQL & PL/SQL :: Call Java Function?

Jan 3, 2012

I want to have something like this:Run PL/SQL function and in middle of function call JAVA function and when JAVA function is done continue PL/SQL function.

Because I have PL/SQL function who inserts into table information.And the JAVA function is uploading/streaming file to column->blob.And in the end of PL/SQL function goes insert into table with file extension and check for *.edoc validation.I can't do it with PL/SQL only. how to do this right or how to run JAVA function in PL/SQL.

View 3 Replies View Related

SQL & PL/SQL :: Call To Function In SYS Schema

Mar 5, 2010

I am defining a function in a schema as a user with admin role (default). The function is to do a call to another function on a custom package in SYS schema.

something funny happens : when I compile the function (defined with authid as DEFINER)it says that the function SYS.custom_package.myFunction is not defined.

however if I do a select sys.custom_package.my Function from dual it's okay.

why this behaviour and how to work around it? You see, the package in SYS proposes a number of other functions that I don't want to expose. I only intend to create some sort of wrapper function that would Marshall the call to the my Function only on the custom_package in SYS.

my wrapper function looks something like that :

create or replace function myFunction_wrapper authid definer return pls_integer is
begin
return sys.custom_package.myFunction;
end;

View 2 Replies View Related

PL/SQL :: Call Function Without Parameter?

Feb 27, 2013

i am trying to call a function from Sql statement and i am getting this error ORA-06572: Function XX has out arguments.

View 2 Replies View Related

SQL & PL/SQL :: How To Call Function Using String Variable

Aug 6, 2010

I have a package includes 22 functions, each function just returns a sql template (clob type).

I also have a stored procedure called query_builder, query_builder has applicationName and statementName as parameters. I need to call these functions in the package based on the given applicationname and statementname.

CREATE OR REPLACE PROCEDURE Query_builder (ApplicationName varchar2, StatementName varchar2) IS
SQLSkeleton varchar2;
BEGIN
PackageName := ApplicationName||'_SKELETON;
SQLSkeleton := PackageName.StatementName; -- I know this will not work, but how can i call these function dynamically?

View 6 Replies View Related

Call Interface :: Sql Statement Works In SQLPLUS But Will Not Pass Checking In PRO*C

Apr 22, 2013

I am in the process of converting my skill in oracle and this time PRO*C from Windows to Linux. I have oracle 11g R2 installed on a UBUNTU (12.04) server and have installed the instant client as described in

[URL]

This has a query which will run in SQLPLUS but fails with PRO*C

:~/Projects/proc/proctest1$ proc INAME=proctest.pc SQLCHECK=NONE ONAME=proctest.c LNAME=proctest.lis LTYPE=long
Pro*C/C++: Release 11.2.0.3.0 - Production on Mon Apr 22 21:00:18 2013
Copyright (c) 1982, 2011, Oracle and/or its affiliates. All rights reserved.
System default option values taken from: /home/neill.rutherford/instantclient_11_2/precomp/admin/pcscfg.cfg
PCC-W-02109, SQLCHECK=NONE is no longer supported.. using SYNTAX

[code]....

View 0 Replies View Related

Create A Function And Call It In Anonymous Block

Oct 22, 2013

I made this script but I still don't quite understand if the syntax is correct. I just wanted to create a function and call it in an anonymous block. I then wanted it to use a variable as a parameter in an iteration and output the variable every iteration. It's done basically but I know it's not 100% right. The fibonacci function looks like its going to loop an infinite number of times if the parameter is greater than 2.

CREATE OR REPLACE PACKAGE myPACKAGE AS
CREATE OR REPLACE FUNCTION fibonacci
(n BINARY_DOUBLE) RETURN BINARY_DOUBLE IS
BEGIN
IF n <= 2 THEN
RETURN 1;
[code]........

View 5 Replies View Related

Error Call A Function Which Alter Sequence Value

Jun 22, 2011

error call a function which alter sequence value..I created a function to reset a sequence value as below

CREATE OR REPLACE FUNCTION rebuildSequence
return number
As
l_csmsgid1 PLS_INTEGER;
l_csmsgid2 PLS_INTEGER;
l_val PLS_INTEGER;
plsql_block VARCHAR2(500);
[code]....

I verified and executed the pl/sql block without a problem. but when only put into a fuction and call it, got then error.

View 7 Replies View Related

Forms :: Call Function With Parameter In Oracle

Jul 17, 2012

i have this function

create function xxx_sal (p_number in number)
return number is
v_sal number;
begin
select sum(sal)
into v_sal
from emp
where empno = p_number;
return v_sal;
end;

how can called it in oracle forms

View 8 Replies View Related

SQL & PL/SQL :: Procedure To Call User Defined Function?

Apr 12, 2012

I have made a function to add two number create or replace function add_num(a in number, b in number) return number

as
begin
return a+b;
end;
/

i run it via
select add_num(2,5) from dual;

my question is how to call add_num in procedure.

View 9 Replies View Related







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