SQL & PL/SQL :: Can Use User Define Value In Nested Function Of A Query

Oct 14, 2010

can we use user define value (how to use '&') in nested function of a query ?

View 7 Replies


ADVERTISEMENT

SQL & PL/SQL :: Declare A User Define Exception Name As Per Defined Name?

Jan 25, 2011

Can we able to declare a user define exception name as per defined exception name?Ex: we have predefined exception called :"NO_DATA_FOUND "

Now in my PL/SQL block can i able to declare "NO_DATA_FOUND" like

Begin
no_data_found exception;
//statements
raise no_data_found;
end

View 6 Replies View Related

SQL & PL/SQL :: Define A Cursor Using Dynamic Query?

Aug 29, 2010

Is it possible to define a cursor using dynamic sql. Reason being is, I want to fetch data from 4 diffrent tables but dont want 4 diffrent cursors for this purpose.

I have a procedure that takes an in parameter . Cursor is declared in this procedure. Again is there a way to use dynamic sql so that this cursor declared in procedure uses all 4 table one at a time i.e cursor c1 is select * from table_name(I want this table name to be updated every time with new table name).

View 5 Replies View Related

Application Express :: Decode - Define Query Condition For The Value

Jan 24, 2013

how can i define the following condition in query definitions tab to define query condition for the value which is linked from previous tab/report ,:P2_SR_ BUSINESS_UNIT is the Item which are getting value from another report Value.

BUSINESS_UNIT=DECODE(:P2_SR_BUSINESS_UNIT,'BS&I','Business Sales And Information','WS','Whole Sale')

I am new in apex and havent had any chance to create a simple report.Version Application Express 4.1.1.00.23

View 6 Replies View Related

SQL & PL/SQL :: Describe Results / Define Output And Fetch Rows Of A Query

Jun 2, 2010

There are several stages for sql processing in 10g2 database concept document.The following stages are necessary for each type of statement processing:

■ Stage 1: Create a Cursor
■ Stage 2: Parse the Statement
■ Stage 5: Bind Any Variables
■ Stage 7: Run the Statement
■ Stage 9: Close the Cursor
Optionally, you can include another stage:
■ Stage 6: Parallelize the Statement

Queries (SELECTs) require several additional stages, as shown in Figure 241:

■ Stage 3: Describe Results of a Query
■ Stage 4: Define Output of a Query
■ Stage 8: Fetch Rows of a Query

Stage 3: Describe Results of a Query The describe stage is necessary only if the characteristics of a query's result are not known; for example, when a query is entered interactively by a user. In this case, the describe stage determines the characteristics (datatypes, lengths, and names) of a query's result.

Stage 4: Define Output of a Query In the define stage for queries, you specify the location, size, and datatype of variables defined to receive each fetched value. These variables are called define variables. Oracle performs datatype conversion if necessary.

I still don't understand what's Stage 3: Describe Results of a Query and Stage 4: Define Output of a Query.

View 2 Replies View Related

SQL & PL/SQL :: Grants On Nested Table To Other User

Jul 16, 2011

I have an issue on selecting data from a nested table owned by other user.

I have given select access on stc_irb_usr.stc_loy_settlebillpay_map_main to anthr user adminofs.

But when I try to query, it says insufficient privileges. adminofs is able to select other columns which are not nested.

I have given "grant execute on STC_IRB_USR.STC_BILLPAY_MAP_TAB_TYPE to adminofs;" but it did not

select * from stc_irb_usr.stc_loy_settlebillpay_map_main where rownum<3;

ERROR: OCI-21700: object does not exist or is marked for delete

SQL> desc stc_irb_usr.stc_loy_settlebillpay_map_main
Name Null? Type
----------------------------------------- -------- ----------------------------
BATCH_NUM NOT NULL NUMBER
ACCOUNT_NUM NOT NULL VARCHAR2(40)
PAY_BILL_SEQ_MAP STC_IRB_USR.STC_BILLPAY_MAP_

[Code]....

Name Null? Type
----------------------------------------- -------- ----------------------------
ALLOCATING_CREDIT_SEQ NUMBER
ALLOCATION_ENTITY_SEQ NUMBER
ALLOCATING_CREDIT_DATE DATE
ALLOCATING_CREDIT_TYPE VARCHAR2(20)
ALLOCATION_ENTITY_DATE DATE

[Code]...

View 2 Replies View Related

Replication :: Can Nested Materialized View Use Pivot Function

May 17, 2012

I have a question about nested materialized view.

Firstly, I have created 3 mv log on 3 table(target,target extension,brand). Secondly, I created the first mv and its log.
Lastly, I created the second mv from the first mv. This time I used the pivot function, but it cannot work now.

--1 create mv log

drop MATERIALIZED VIEW LOG ON target;
drop MATERIALIZED VIEW LOG ON targetextension;
drop MATERIALIZED VIEW LOG ON brand;
CREATE MATERIALIZED VIEW LOG ON target with rowid, sequence(id);
CREATE MATERIALIZED VIEW LOG ON targetextension with rowid, sequence(targetid,brandid,EmailPermission,NumberOfAllOrders);
CREATE MATERIALIZED VIEW LOG ON brand with rowid, sequence(brandid, brandname);

--2 create the first mv and it's log

drop MATERIALIZED VIEW mv_target1;
CREATE MATERIALIZED VIEW mv_target1
REFRESH FAST START WITH SYSDATE
NEXT SYSDATE + 1/1440
AS
select t1.rowid t1_rowid, t2.rowid t2_rowid, t3.rowid t3_rowid,
t1.id targetid,
t3.brandname,
[code].....

--3 create the second mv
drop MATERIALIZED VIEW mv_target2;
CREATE MATERIALIZED VIEW mv_target2
REFRESH FAST START WITH SYSDATE
NEXT SYSDATE + 1/1440
AS
select * from mv_target1
pivot(max(EmailPermission) EmailPermission, max(NumberOfAllOrders) NumberOfAllOrders for brandName in ('XXX' XXX,'YYY' YYY ,'ZZZ' ZZZ));

Now, Here is a problem, it throws "ORA-12015: cannot create a fast refresh materialized view from a complex query". Then I used dbms_mview.explain_mview to see the reason, and it tell me the following

REFRESH_FAST_AFTER_INSERT "inline view or subquery in FROM list not supported for this type MV"

declare
lv_sqltext varchar2(4000);
begin
execute immediate 'truncate table mv_capabilities_table';
lv_sqltext := 'select * from mv_target1
pivot(max(EmailPermission) EmailPermission, max(NumberOfAllOrders) NumberOfAllOrders for brandName in (''XXX'' XXX,''YYY'' YYY ,''ZZZ'' ZZZ))';
dbms_mview.explain_mview(lv_sqltext,'nested=>TRUE');
commit;
end;
/

View 6 Replies View Related

SQL & PL/SQL :: Access Attributes Of Objects Of Nested Table In Member Function Of Oracle Database

Nov 17, 2011

I have created two types and a list of the first type:

create type type1;
/
create type type1_list as table of ref type1;
/
create type type2;
/

I have now just created the two types as follows:

create type type1 as object(
id# number
);
/
create type type2 as object(
attribute1 type1_list,
MEMBER FUNCTION function1 RETURN NUMBER
);
/

Ok, I've created the tables (I don't know if it's necessary to point out my problem)

CREATE TABLE type1_table OF type1;
/
CREATE TABLE type2_table OF type2
NESTED TABLE attribute1 STORE AS nested_type1_list_table;
/

And what I wanted to do now is to implement the member function1 and check something of the attributes of type1 in the list of attribute1... And that's where my question occurs, how does it work, I can't figure it out. I tried something like this:

Quote:
create or replace
TYPE BODY type2 AS
MEMBER FUNCTION function1 RETURN NUMBER AS

[Code]....

But I don't get the right way, it doesn't work

View 4 Replies View Related

Using Nested-query To Achieve Info

Apr 19, 2010

For each keeper, show the number of cages cleaned by the keeper, show the average number of animals in the cages cleaned by the keeper and the total cost of the cages cleaned by the keeper."

The data table is shown on the picture.i75.photobucket. com /albums/i297/lovebipbo/SIT103.jpg.. I can learn and do some similar task myself

View 4 Replies View Related

Use Of Query Clause For Nested Tables During Export

Aug 30, 2010

I have a query regarding nested tables while exporting. Are we not allowed to use Query clause during the export of nested table?

I am getting the error:
"EXP-00053: unable to execute QUERY on table NT_LP_COREBAL_MAINT because the table has inner nested tables
Export terminated successfully with warnings."

The exp command we are using is:
exp XXXX/XXXX@XXXX file=test1.dmp log=test1.log tables=nt_lp_corebal_maint query='where domain_id=10110307'.

View 1 Replies View Related

SQL & PL/SQL :: Create Nested Query Within Select Of Attributes

Dec 21, 2011

I'm trying to create a sort of nested-query within my select of attributes . i.e.

select A.a,
B.b,
(select count(C.*)
from C
where C. = B.d
group by C.y)
from A a,
B b
where A.d = B.d
and ...

Over-simplifying my query:

select B.desc "Location",
F.desc "Source",
A.amt "Amount",
sum(G.G_CNT) "No. Units",
c.desc "Status"
[code]....

I need to incorporate a count of the number of units from TableG that have a certain status. I tried the following but when I tried to run it, I get an error saying that it's not a Group By expression -the red part is highlighted in TOAD.

select B.desc "Location",
F.desc "Source",
A.amt "Amount",
sum(G.G_CNT) "No. Units",
(select count(*)
from TableG G2
where G2.D_ID = D.ID
and G2.status = 10
group by G2.D_ID)"Count",
c.desc "Status"
[code]....

Any thoughts how I can incorporate a query in my select of attributes?how to Group By something.

View 8 Replies View Related

SQL & PL/SQL :: Nested Query Based On Value Of Dependent Column?

Sep 10, 2013

In the below Table Structure, TB_Vehicles is the Master table and TB_Cars, TB_Bikes, TB_Cars are Satellite tables which hold more info about respective vehicles.

I want users to search using the Name. So, when users enter Name as 'Access', my query should give all information about that vehicle, including that from Satellite Tables (using both TB_Vehicles and TB_Scooters).

SELECT *
FROM TB_Vehicles
WHERE V_NAME = 'Access';

Similarly, if user enters 'Linea', it should give info from TB_Vehicles and TB_Cars tables.

So, with V_NAME as input, I'll find V_TYPE from TB_Vehicles table, and using that, I need to identify which satellite table, I need to join to retrieve more info.

Do I need to use CASE or DECODE to achieve this?

View 25 Replies View Related

Performance Tuning :: Query With Nested Loop Takes 6 Hours To Complete

Jun 23, 2011

I'm joinging two tables event_types and tmp_acc tables.

event_types contains 2 Billion records
tmp_acc contains 20,000 records.

Resulting rows are about 300,000 records in event_types table end_t and account_obj_id0 are joined indexed

no indexs in tmp_acc.

When I run below query with nexted loop it takes 6 hrs to complete. But when I run with hash join even after 4 days it was still running. what is wrong with hash join here. Why it takes so long. I'm joining only 20000 rows. So I think there should be a way to get result rows quickly.

show parameters hash_area_size

NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
hash_area_size integer 2097152

explain plan for
select --+ parallel(e,6)
[code]....

View 21 Replies View Related

SQL & PL/SQL :: Create View From Dynamic Query (or Function Returning Query)

Dec 5, 2012

I have a dynamic query stored in a function that returns a customized SQL statement depending on the environment it is running in. I would like to create a Materialized View that uses this dynamic query.

View 1 Replies View Related

SQL & PL/SQL :: Change Value That Function USER Returns

Nov 25, 2011

I have an existing database with several hundred tables and triggers on the tables in the schema S1. Most of the triggers are for storing audit information USER and SYSDATE in the respective columns.

We have built procedures what will accept incoming XML parameters from a BPMS application on the intranet which will have information about which table to update, which columns to update, what values to update and what the O/S user id is. The O/S user ids are mapped to oracle user ids in a specific table. Therefore when we receive the request we can easily figure out the oracle user id. The application always connects to the database using a specified user id S2.

The trouble is, the existing tables have triggers which read :NEW.userid := USER;and whenever a DML is fired from the procedure, the function USER always returns S2, since that is the user id the BPMS application connects to and therefore the audit columns do not capture the correct information as required.

The impact of changing all the existing triggers/procedures will be a mammoth task including regression testing and will certainly not be approved by the project sponsor.

override the value that USER returns? Using session contexts, etc? If so, we can possibly set it at the point of connect and have to do nothing else.

View 18 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

SQL & PL/SQL :: Does Oracle Log Exception In User Defined Function

Jan 12, 2012

If a user defined function in Oracle may throw and catch exceptions depending on input, now does the Oracle logs the exception? Fundamentally we are asking if Oracle logs any random DML errors (not bulk operation). We hope not, as we do not want our client DBA get concerned. There might be many levels of settings in Oracle to log or not log. So if Oracle may log it depending on setting, how do we suppress it either at Oracle specific schema level, or function level?

This is my user defined function:

create or replace FUNCTION ISNUMERIC(char_in CHAR) RETURN NUMBER IS
n NUMBER ;
BEGIN
n := TO_NUMBER(char_in);
RETURN 1;
EXCEPTION
WHEN OTHERS THEN
RETURN 0;
END;

View 2 Replies View Related

SQL & PL/SQL :: Function Code To Restrict User From Entering More Than 30 Characters

May 24, 2011

Need a code which prevents the User from entering more than 30 characters in a field. Although the variable can accept more than 30 characters. My requirement is to validate the field by restricting up to 30 characters.

View 6 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

Semantic Technologies :: User-defined Function In FILTER Clause?

Apr 28, 2013

can i create the user-defined functions and use them in the FILTER clause in the sem_match function? there are some built-in functions for the FILTER clasue. however, only one function (DATATYPE(literal)) support for date/time in the built-in functions. i want to implement some user-defined funcitons in the FILTER clause which can check time intervals in ontology. there are some functions about valid time in the WorkSpace Manager such as WM_OVERLAPS, WM_CONTAINS,WM_MEETS, etc. so, can i write some functions using the these valid time functions in WM and use them in the FILTER clause?

View 2 Replies View Related

SQL & PL/SQL :: How To Use DEFINE Command

Jun 5, 2012

set serveroutput on
set verify off
declare
define t1='111';
begin
dbms_output.put_line(t1);
end;
/
define t1='111';
*
ERROR at line 2:
ORA-06550: line 2, column 10:
PLS-00103: Encountered the symbol "=" when expecting one of the following:

:= . ( @ % ; not null range default character

The symbol ":= was inserted before "=" to continue.

View 5 Replies View Related

PL/SQL :: Return Past Timestamp Values On Base Of Input Hour To User Function

Nov 22, 2012

resolve issue while modified the user function code for returns the values as timestamps

---function code

create or replace
function fun_test_timestamp(P_HOUR varchar2) return varchar2
is
sql_stmt varchar2(1000);
begin

[Code].....

Input:-
select fun_test_timestamp('5') from dual;

Output:-

SELECT CURRENT_TIMESTAMP - INTERVAL '5' HOUR FROM DUAL;

Modified Fun Code:

create or replace
function fun_test_timestamp(P_HOUR varchar2) return timestamp
is
sql_stmt varchar2(1000);

[Code]...

Input:-
select fun_test_timestamp('5') from dual;

Output:-

ORA-00911: invalid character
ORA-06512: at "NETVERTEXTRUNK.FUN_TEST_TIMESTAMP", line 8
00911. 00000 - "invalid character"

*Cause:    identifiers may not start with any ASCII character other than letters and numbers. $#_ are also allowed after the first character. Identifiers enclosed by doublequotes may contain
any character other than a doublequote. Alternative quotes (q'#...#') cannot use spaces, tabs, or carriage returns as delimiters. For all other contexts, consult the SQL Language Reference Manual.

*Action: 

View 6 Replies View Related

PL/SQL :: Bind And Define Variable

Apr 2, 2013

What is the difference between these two variables and their usage?

View 6 Replies View Related

Forms :: Define Global Variable In Oracle 6i

Aug 12, 2010

I want to define global variable in oracle form 6i....so this variable may i used anywhere in project...but i don't know where exactly global variable defined?

View 7 Replies View Related

RAC & Failsafe :: Define DB Connection URL For Two Different SID Names In Single URL?

Apr 3, 2012

As you see in the following MY_DB_URL there are two hosts for one SID. This is works perfectly for oracle driver. When one of them is gone down, connection establishes with the other.

MY_DB_URL = jdbc:oracle:thin:@(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=xx.xx.104.18)(PORT=1521))(ADDRESS=(PROTOCOL=TCP)(HOST=xx.xx.104.19)(PORT= 1521))(FAILOVER=true)(LOAD_BALANCE=false)(CONNECT_DATA=(SERVER=DEDICATED)(SID=SIDNAME_1)))

But i have a problem. Our partner uses Golden Gate product, and they said that they must install two different oracle with two different SID names. (For Example one of them is SIDNAME_1 the other is SIDNAME_2) So i can't use this URL in my application.

Is there a way to define a DB connection URL for two different SID names in a single URL?

View 1 Replies View Related

Client Tools :: How To Define ED Command In Sqlplus

Jul 25, 2012

In my sql*plus when i am writing the command ed .It was showing the error as \

SQL> ed
SP2-0110: Cannot create save file "afiedt.buf"

i tried to define the editor by using the command define_editor=notepad;

But still my problem was not solved.

View 2 Replies View Related

PL/SQL :: Define SELECT Clause Once And Reuse It In Many Other Queries?

Mar 16, 2013

Is there a way to define a SELECT clause once and reuse it in many other queries?

I have many procedures with same SELECT statement and I'm trying to find a way to not have to write out the SELECT clause in every function or procedure. Same question applies to FROM, WHERE, etc clauses.

View 12 Replies View Related

SQL & PL/SQL :: Want To Define Dynamic Type For A Variable In Oracle 10g

Jul 17, 2013

I m trying to give table name as parameter to this function. It is compiling properly.But when an anonymous block is created to call this table value, it has to be fetched into a variable of Rowtype of this inputted table. So I am not able to create any ROWTYPE variable for this table dynamically.

//Function
create or replace function instant_tabula(tabula in varchar) return sys_refcursor
as
cur sys_refcursor;
str varchar2(20000);
begin
str := 'select * from ' || tabula;
open cur for str;
return cur;
end;
[code]....

View 7 Replies View Related

Dynamically Define Database Link To Use (at Session Level)?

Sep 1, 2010

Three databases: A, R1, R2. Database A is local and the other two databases are remote. Database A has one db link to each remote database (dblinkR1 and dblinkR2).

In some of my queries I need to get data from the remote databases, but the remote database to use depends on the application user, so, I would like to dynamically use one of the database links.

Something like this:

1 � user logs into the application;
2 � based on the user credentials the application defines the db link to use;
3 � query data using the defined db link.

(for example)

SELECT a.col1, a.col2 FROM table_A@dyndblink a ORDER BY a.col1;

@dyndblink would be a "pointer" to dblinkR1 or dblinkR1.

Is there a way to dynamically define the database link to use (at a session level)?

View 2 Replies View Related

PL/SQL :: SUM Function In Query

Oct 16, 2012

Query:

select sum(2) from employees

How easy it is to tell the answer without running it in SQL Developer or SQL* Plus

I am finding it a bit hard to understand the logic behind allowing Lower(2.3) and Upper(69) etc queries

View 8 Replies View Related







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