PL/SQL :: How SQL Queries Act In Back End To Give The Result
Jul 22, 2013
When we are running a query it is giving us the result based on the conditions .But to know what exactly is happening in the database when we are running a query against it and how finally it returns the result.
View 1 Replies
ADVERTISEMENT
Apr 9, 2012
I come from a world of MSSQL and have been thrown into doing some Oracle work. Great! Ok, moving on.. I work in an environment where I do not have direct access to the database tables that I need data from. As a workaround, I have been asked to create a stored procedure that will be loaded into our CRM system's production db once it goes through the internal "approval" process.Basically, I need to return a result set back to the client by calling a stored procedure.
Version 1 of this that was already in place was done with the following code.
procedure events_by_day (p_start_date IN OPERATION_LOG.DT%type,
p_end_date IN OPERATION_LOG.DT%type,
p_results OUT SYS_REFCURSOR) IS
BEGIN
OPEN p_results FOR
[code]....
Then the code is executed from the client side like so:
events_by_day(p_start_date => to_date('2012-3-27 00:00:00', 'YYYY-MM-DD HH24:MI:SS'),
p_end_date => to_date('2012-3-29 23:59:59', 'YYYY-MM-DD HH24:MI:SS'),
p_results => r_cursor);
LOOP
FETCH r_cursor
INTO event_date, event_acct_no, event_type, event_count;
[code]....
As you can see, a SYS_REFCURSOR was used in this case to pass the data back.
View 3 Replies
View Related
Dec 12, 2011
How can i join two quires together to get result.
My requirement is:
First i want to select Table as we do
Select * from tab;
Then i want to describe the table as we do
Desc WO;
How can we join these two queries to have result.
View 21 Replies
View Related
Oct 21, 2012
I am trying to display the results from 2 queries, one is supposed to display the count of the employees, per department, who win over the average of the entire company and the other one is supposed to display the count of the employees, per department, who win under the average of the entire company.
I used a UNION ALL, but all it does is merge the results from the ones that win over and under the average into one row, is there a way to separate them? I tried assigning names to each salary using AS but it only displays the first I put in.
sql
Original
- sql Code
(
SELECT DE.DEPARTMENT_NAME, COUNT (EM.EMPLOYEE_ID) AS MAYORES
FROM DEPARTMENTS DE, EMPLOYEES EM
WHERE DE.DEPARTMENT_ID = EM.DEPARTMENT_ID
AND EM.SALARY > (SELECT AVG(EM.SALARY) FROM EMPLOYEES EM)
GROUP BY DE.DEPARTMENT_NAME
[code].....
View 3 Replies
View Related
Feb 7, 2012
Following are 2 queries, which return same results as far as the input parameter is NOT NULL
select /*+ gather_plan_statistics */ * from PX_CJQ where decode(:x,null,1,object_id) = NVL(:x,object_id);
select /*+ gather_plan_statistics */ * from PX_CJQ where object_id = NVL(:x,object_id);
However the execution plan differs a lot The FTS cost or rows accessed count also varies what could be the reason? The PX_CJQ is simply select * from dba_objects and has index on object_id which anyway is not being used in this case
variable x number
exec :x:= 28
Query - 1
***************
***************
SQL> >select /*+ gather_plan_statistics */ * from PX_CJQ where decode(:x,null,1,object_id) = NVL(:x,object_id);
SQL> >select * from table(dbms_xplan.display_cursor(NULL,NULL,'ALLSTATS LAST'));
[code]...
Query - 2
***************
***************
SQL> >select /*+ gather_plan_statistics */ * from PX_CJQ where object_id = NVL(:x,object_id);
SQL> >select * from table(dbms_xplan.display_cursor(NULL,NULL,'ALLSTATS LAST'));
PLAN_TABLE_OUTPUT
[code]...
29 rows selected.
SQL> >
View 8 Replies
View Related
May 12, 2013
I have three select queries. Each of them returns a single column. I want the result of these queries into a single table..
I tried this way..
select * from
(first select),(second select),(third select);
this gives duplicate rows...
View 4 Replies
View Related
Jul 4, 2013
I would like to know if using varchar parameter in sql queries with number column can result in performance degrade.
Ex: Procedure testa ( myparam varchar) is
begin
select col1 into var1 from table where colno = myparam;
end;
Here col no is a number column and myparam is varchar. I feel its better to change the parameter to number.
View 7 Replies
View Related
Jan 23, 2007
our system has always been running on mysql database and recently we have switched to oracle. As the current system is coded using mysql query syntax, when i run this program using oracle database, i got a error. The language that I'm using is JSP.
this is the error message:
The following query could not run on oracle. To convert these mysql queries to oracle compatible queries.
SELECT productID,productName FROM products order by productName;
select newsID,newsDate,newsHeadLine1 from news order by newsDate Desc limit 3
SELECT fuji_products.productID, productName_Display FROM products,products_availability where products_availability.productID=products.productID and (product_status='enabled' or product_status='all') AND category='12'
SELECT catID, catSub1 from category where catSub = '"+ prodCat +"' AND catSub1 is not null group by catSub1 order by catSub1
View 6 Replies
View Related
Mar 13, 2012
want to create a PL/SQL procedure, update_id(id_emp in number), that gives a new id_emp (id_emp=y) to an existing employee (id_emp=x).So before updating the EMP table, we have to :
1- create a new row on EMP(with id_emp=y) that has the same informations of the employee (id_emp=x),
2- update all tables that contains the id_emp column (update <TAB> set id_emp=y where id_emp=x),
3- delete employee (id_emp=x).
The problem is in step 2 : it creates a lot of locks and makes the DB unusable.To deal with this problem, I thought for many solutions, but the problem is how to implement them correctly and efficiently.
Before executing step 2, we have to ensure (through a marker I guess) that all the tables that have the id_emp column, are managed by our session, and any other acces (through SELECT, UPDATE, DELETE, INSERT statment) from another session will be rejected since we have a marker on that table.
When step 2 ends, we release all the tables from the markers.
My simple question : how to achieve this ?
View 12 Replies
View Related
Jan 14, 2012
i would like to give a hyper link in forms. how it possible, any way to do it.
View 8 Replies
View Related
Aug 29, 2013
Version- 10G I have a stored procedure which contain code like
if () then---update---else if() theninsert --update--------else if()-----------------------end if;end if;end if;
I have to use this code numbers of times in my procedure , is there any way I can give name this code & use it or call it where I need it in my SP.Don't want to make the above code a separate procedure.
View 4 Replies
View Related
Jul 8, 2010
I created a user and granted connect,resource priviliges. I gave access to this user for only 5 tables. when i check it later, other tables are also given access. How can i avoid this and give access to selected tables.
View 9 Replies
View Related
Oct 15, 2012
Suppose I using "scott" user, I need to give administrative permissions to scott. How can I give??
View 6 Replies
View Related
Mar 26, 2010
I have two schemas.In schema1 i hava a table with 20 records,i want to give access only on 10 th row for schema2.
View 6 Replies
View Related
Aug 23, 2012
I have 12 different tables
Record_jan
Record_feb
.
.
.
Record_nov
Record_dec
Based on the month i need to do some i/o operations from these table.
For eg: If it is january then Record_jan table should be accesed or for nov Record_nov table should be accesed.
If I try to store the table name in some variable and then give the variable name in place of table name then it gives error.
var:=Record_month;
Select * from var;
this gives error.
View 3 Replies
View Related
Dec 9, 2010
I try to alter the SGA it give me error The Steps which I do show sga
Total System Global Area 135338868 bytes
Fixed Size 453492 bytes
Variable Size 109051904 bytes
Database Buffers 25165824 bytes
Redo Buffers 667648 bytes
[code]...
View 5 Replies
View Related
Aug 16, 2011
I wanted a query that will give me the list of views using three tables
when i fire
select * from dba_views where text like '%SELECT%';
it is giving me error as expected number got long.
View 2 Replies
View Related
Aug 29, 2013
I would like to know 2 days back lock conflicts session information which user held the lock,sql text,when the lock released. any sql query or view in oracle 11g db.
View 1 Replies
View Related
Apr 15, 2012
I want to get clear with one thing yesterday i installed oracle9i and dev 2000 to my client.
when they run one report they got stuck with pl/sql compilation errorrep-1247
when i checked that report in the report builder, in the query they are using some other table which is not belongs to that schema,then I give that schema.tablename and compiled, but this is coming for other reports also, then only i came to know that they are acceessin other schema also, how can i sort this out.
can i fix this by givin full access privilige or what privilige can i give to get full access of other schema table.
how can i check in the old database what are all the roles and privileges given to this user,
View 5 Replies
View Related
Aug 8, 2012
I have a task assigned to "grant select on sys.link$" to a user which exists on 500 different databases.
This needs to be done in Oracle database.
View 6 Replies
View Related
Apr 16, 2013
I have this code when i run this I get credentials error. How to give credentials .The authentication is set to windows in the https page. Means pop up will appear to get the credentials
declare
req UTL_HTTP.REQ;
resp UTL_HTTP.RESP;
value varchar2(1024);
p_url varchar2(4000);
OPT varchar2(1000);
BEGIN
dbms_output.put_line('');
[code]....
View 1 Replies
View Related
Dec 9, 2011
We have a SSRS Front end screen which sends multi-select column values as comma separated strings to back end ( Oracle 10g) procedure .
The procedure builds the string by inserting single quotes in the following manner.
P_BU_LST is the parameter which have comma separated values
'1234,3456,4577' i.e, BU ids selected by user in front end
the procedure inserts single quotes to this paramer value
i.e., '1234','3456','4577
v_bu_lst := '''' || REPLACE(v_selbu, ',', ''',''')|| '''';
This is used the where clause of the REF CURSOR SELECT query which send the data back to SSRS
ie.,
SELECT BU.*
FROM BU_DETAIL BU
WHERE INSTR(V_BU_LST,BU_ID) <> 0;
INSTR has a chance to fail in this scenario if the value send from the front end is 123456,3456,4577
here 123456 does not exist in table, but it will be true for INSTR and values 1234 from table will be send back to SSRS which is wrong. Earlier I was using a function to convert the comma separated values to multi-rows and treat it like a lookup table.
But the main table has around million records , and each row has to processed against each row of lookup table, which makes it slower. To avoid this I used INSTR which is faster but can give wrong results.
View 8 Replies
View Related
Oct 4, 2012
I am using Oracle 11g .when i query
select sysdate from dualit returns the current UTC date and time as output.
But when i query
select DBTIMEZONE from dual it returns -07:00 which indicates PDT.
i am wondering is this correct behaviour, i am expecting DBTIMEZONE to give +00:00 since sysdate returns as UTC date time.'
View 5 Replies
View Related
Oct 5, 2013
How to give ROLE access to users in PL/SQL developer Tool..??
View 3 Replies
View Related
Aug 2, 2013
I need to take RMAN full backup by every Sunday night and Wednesday night . I have the netbackup script which will take the backup to media.
Question is:1. We have 15 - backup scripts for 15 DB in that server , so if i configure crontab for backup do i need to give all 15 scripts one by one or (*) will work . ie) 00 20 * * 3,7 /app/oracle/rman/scripts/hot_db_<sid>.sh
instead of this if i give : 00 20 * * 3,7 /app/oracle/rman/scripts/hot_db_*.sh then it will works fine or not ? 2.
Already my backup will create .output file in the same location , do i need to give output file location in crontab using ( > ) ? 3.
Is the above crontab timing is correct ? (3,7) for Wednesday and Sunday 8pm? so Sunday is 0(zero) or 7 ?
View 6 Replies
View Related
Dec 21, 2012
Example:
select * from emp
where empno in (123 234 345 124)
View 6 Replies
View Related
Jun 1, 2013
How the loop back entry in /etc/hosts relates to listener?
View 1 Replies
View Related
Nov 12, 2012
When I call a classic report that is exported throuh restful webservice, result depends on whether I also send cookie or not. In the first case, access is enabled, in the latter case, HTTP 404 is returned.
Restful access is enabled in the instance. Having an app with ID=101, page 9901 that is public, a classic report called MYREPORT on the restful side, the following call is issued:
/apex/apex_rest.getReport?app=101&page=9901&reportid=MYREPORT_ID&parmvalues=123445&output=json
If my browser send the cookie below with the request, I get back the result. If I delete the cookie from my browser, the result for the exact same apex_rest call is HTTP 404: Not found.
Cookie: ORA_WWV_USER_64731425336707=04893186A373057F5F1E1FCCD33113FA; PUBLIC_ORA_WWV_USER_64731425336707=-1; ORA_WWV_REMEMBER_UN=MYNAME:myworkspace
Details on my configuration is as follows:
Database: Oracle XE 11g, 11.2.0.2.0
Apex version: 4.1.1.00.23_en
Platform: Linux x64
HTTP is handles by XEXDB as folows from lsnrctl status:
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=kivi.omikk.bme.hu)(PORT=8080))(Presentation=HTTP)(Session=RAW))
Service "XEXDB" has 1 instance(s).
Instance "XE", status READY, has 1 handler(s) for this service...
View 2 Replies
View Related
Aug 16, 2011
The requirement is, the combination of col1,col2,col3 and col4 should always be unique, and wherever the col1, col2,col3 are same then col4 should be the sequence, starting from 1. Likewise the data should be updated back to the table.I'm able to do this using PL/SQL. Can I do the same using a single update statement?
create table tab1 (col1 number(5), col2 number(5), col3 number(5), col4 number(5));
Existing Data:
insert into tab1 values (101,521,3,1);
insert into tab1 values (101,521,3,1);
insert into tab1 values (101,522,3,2);
insert into tab1 values (101,522,3,2);
insert into tab1 values (101,523,3,1);
insert into tab1 values (101,523,3,2);
[code]....
View 3 Replies
View Related
Nov 8, 2010
I have deleted all the records from the table.And I have committed.Now I want to get all the records back.
View 16 Replies
View Related