Unable to retrieve results using dynamic query
Hi Experts,
I have created a custom table and have created a custom bol to integrate it with web ui. I have redefined the dynamic query result method of genil layer. I find the data into LT_RESULT but when I invoke the root list method the LR_OBJECT does not contain the values.
Please see below the code that I have written.
====================================
METHOD IF_GENIL_APPL_INTLAY~GET_DYNAMIC_QUERY_RESULT.
DATA: LR_OBJECT TYPE REF TO IF_GENIL_CONT_ROOT_OBJECT,
LT_RESULT TYPE TABLE OF ZCRMST_XXXX,
LV_DYN_WHERE TYPE STRING,
LV_LEN TYPE I,
LS_RANGE TYPE SELOPTOBJ.
DATA: LT_XXXX TYPE TABLE OF SELOPTOBJ,
LT_YYYY TYPE TABLE OF SELOPTOBJ.
FIELD-SYMBOLS: <LFS_RESULT> TYPE ZCRMST_XXXX,
<LFS_SELECTION_RANGE> TYPE GENILT_SELECTION_PARAMETER.
decomposition of selection parameters and build a dynamic where condition
SELECT * FROM ZXXXX INTO TABLE LT_RESULT[].
CHECK LINES( LT_RESULT[] ) > 0.
LOOP AT LT_RESULT[] ASSIGNING <LFS_RESULT>.
LR_OBJECT = IV_ROOT_LIST->ADD_OBJECT( IV_OBJECT_NAME = 'Root'
IS_OBJECT_KEY = <LFS_RESULT>-XXXX ).
CHECK LR_OBJECT IS BOUND.
LR_OBJECT->SET_QUERY_ROOT( ABAP_TRUE ).
ENDLOOP.
ENDMETHOD.
==================================================
Thanks in advance,
Hi,
Please check your get_objects method of the genil class. I made some changes to my implementation of get_objects method and it fixed the problem.
Regards,
Sandeep
Similar Messages
-
How to use dynamic query for Result table
Hello Experts,
I want to use dynamic query and then display the result in the assignment block.
Using dynamic query BTQAct and BTQRAct and base on some search criteria i want tofilter and then append the result in the result table of that custom context node, and then it should display the result in the view in UI.
SO can you please provide me the samplle code on how to use the dynamic query and append in the result table.
Regards.Hi,
Please find below sample code:
data: query TYPE REF TO cl_crm_bol_dquery_service,
result TYPE REF TO if_bol_bo_col.
DATA: lt_params TYPE crmt_name_value_pair_tab,
lwa_params TYPE crmt_name_value_pair.
query = cl_crm_bol_dquery_service=>get_instance( 'BTQAct' ). " Get instance of dynamic query
Set general query parameter for maximum number of hits
lwa_params-name = 'MAX_HITS' .
lwa_params-value = '50'.
APPEND lwa_params TO lt_params.
query->set_query_parameters( it_parameters = lt_params ).
query->add_selection_param( iv_attr_name = 'OBJECT_ID'
iv_sign = 'I'
iv_option = 'EQ'
iv_low = <lv_objectid>
iv_high = '' ). " Set your search criteria. Repeat this code if you have multiple parameters
"You can find possible search options for a query object in GENIL_BOL_BROWSER
result ?= query->get_query_result( ). " Get result from your search query
me->typed_context-> <your result context node>->set_collection( result ).
Here you will have to create a context node in your view which would refer to query result object like for BTQAct its BTQRAct
Hope this helps.
e Regards,
Bhushan -
Ref Cursor Using Dynamic Query
Hi,
I need to use the ref cursor to fetch result from dynamic query.
e.g.
Open ref_test_tbl for Select * from tbl1 where tbl1.field1= :1
and tbl1.field2 =:2 using i_v1,i_v2;
The thing is i_v1, i_v2 are dynamic.
i.e. using clause can include i_v3, i_v4 also.
How to include dynamic variables in the using clause.
thanks> How to include dynamic variables in the using clause.
Cannot using a ref cursor.. (and anyone that post code that writes dynamic PL/SQL in order to achieve this, I will call an idiot).
What you should be using in PL/SQL is a DBMS_SQL cursor. This allows you to create a fully dynamic SQL statement with bind variables. E.g.
select * from tbl1 where col1 = :1
select * from tbl1 where col2 = :1 order by 2
select * from tbl1 where col3 between :0 and :1
Using this dynamically created SQL statement, you can parse it using DBMS_SQL, determine the number of bind variables, and bind each of these dynamically.
You can then execute the SQL and again, dynamically, determine just what the projection of the cursor is. How many columns are returned, their names, data types, precision and so on.
This is what APEX (see http://apex.oracle.com) use extensively in order to run SQLs and render these as reports - all dynamically.
DBMS_SQL is detailed in the [url http://download.oracle.com/docs/cd/B19306_01/appdev.102/b14258/d_sql.htm#BABEDAHF]Oracle® Database PL/SQL Packages and Types Reference manual. -
Converting rows to columns using dynamic query.
I am trying to use the below code that I founnd on the web to conver rows to columns. the reason that I want to use dynamic query is that the number of rows are not know and changes.
declare
lv_sql varchar2(32767) := null ;
begin
lv_sql := 'SELECT Iplineno ';
for lv_rec in (SELECT distinct vendor from bidtabs where letting = '10021200' and call ='021')
loop
lv_sql := lv_sql
|| CHR(10)
|| ', MAX( DECODE( vendor, '
|| chr(39)
|| lv_rec.vendor
|| CHR(39)
|| ', bidprice, NULL ) ) as "'
|| lv_rec.vendor
|| '" ' ;
end loop;
lv_sql := lv_sql
|| CHR(10)
|| 'FROM bidtabs where letting = ''10021200'' and call = ''021'' and lineflag = ''L'' '
|| CHR(10)
|| 'GROUP BY iplineno ;' ;
here is the result
BIDPRICE CALL IPLINENO LETTING VENDOR
9,585 021 0010 10021200 C0104
1,000 021 0020 10021200 C0104
1,000 021 0030 10021200 C0104
17 021 0040 10021200 C0104
5 021 0050 10021200 C0104
11,420 021 0010 10021200 K0054
1,100 021 0020 10021200 K0054
1,100 021 0030 10021200 K0054
5 021 0040 10021200 K0054
3 021 0050 10021200 K0054
8,010 021 0010 10021200 V070
900 021 0020 10021200 V070
1,320 021 0030 10021200 V070
11 021 0040 10021200 V070
3 021 0050 10021200 V070
and here is the desired output
CALL IPLINENO LETTING C0104 K0054 V070
021 0010 10021200 9,585 11,420 8,010
021 0020 10021200 1,000 1,100 900
021 0030 10021200 1,000 1,100 1,320
021 0040 10021200 17 5 11
021 0050 10021200 5 3 3Here is the error message I am getting:
RA-06550: line 22, column 43:
PLS-00103: Encountered the symbol "end-of-file" when expecting one of the following:
begin case declare end exception exit for goto if loop mod
null pragma raise return select update while with
<an identifier> <a double-quoted delimited-identifier>
<a bind variable> << close current delete fetch lock insert
open rollback savepoint set sql execute commit forall merge
pipe -
Using Dynamic Query in For Loop
I have a doubt whether i can use the result from dynamic query in the for loop.
for example,
declare
v_sql varchar2(1000);
v_Id INTEGER;
begin
v_sql := 'select id from table1 where id in ('||v_Id||')';
FOR i in vsql LOOP
dbms_output.put_line(i.id);
end loop;
end;
The above query is possible ?And here's a basic example of opening up a cursor for your dynamic query...
SQL> ed
Wrote file afiedt.buf
1 declare
2 v_sql varchar2(2000);
3 v_cur sys_refcursor;
4 i emp.sal%type;
5 begin
6 v_sql := 'select sal from emp';
7 open v_cur for v_sql;
8 loop
9 fetch v_cur into i;
10 exit when v_cur%NOTFOUND;
11 dbms_output.put_line('Salary: '||i);
12 end loop;
13* end;
SQL> /
Salary: 800
Salary: 1600
Salary: 1250
Salary: 2975
Salary: 1250
Salary: 2850
Salary: 2450
Salary: 3000
Salary: 5000
Salary: 1500
Salary: 1100
Salary: 950
Salary: 3000
Salary: 1300
PL/SQL procedure successfully completed.
SQL> -
Finding minimum value in each row using dynamic query
need to find the minimum and maximum value from each row using dynamic query
[from curr] will be given as input
TukyDECLARE @t TABLE(a INT,b INT,c INT);
INSERT @t VALUES(1,2,3),(9,8,7),(4,6,5);
SELECT *
, ( SELECT MAX(val)
FROM (VALUES (a)
, (b)
, (c)
) AS value(val)
) AS MaxVal
, ( SELECT MIN(val)
FROM (VALUES (a)
, (b)
, (c)
) AS value(val)
) AS MinVal
FROM @t;
Best Regards,Uri Dimant SQL Server MVP,
http://sqlblog.com/blogs/uri_dimant/
MS SQL optimization: MS SQL Development and Optimization
MS SQL Consulting:
Large scale of database and data cleansing
Remote DBA Services:
Improves MS SQL Database Performance
SQL Server Integration Services:
Business Intelligence -
How to use three part name with using dynamic query.
Dear all, (sqlserver 2008 express r2)
q1)following is showing error, is it possible to accomplish the task with out using dynamic query.
DECLARE @A VARCHAR(100)
DECLARE @A1 VARCHAR(100)
SET @A='DB1'
SET @A1='DBO'
SELECT * FROM @[email protected]
q2) table value function is not accepting dynamic query , is there any way to do this task.
yours sincerleyCertain parts in an SQL query like FROM tablename cannot be local variables. In such a case, dynamic SQL can be applied:
http://www.sqlusa.com/bestpractices/dynamicsql/
As noted above, more information needed to decide if dynamic SQL the correct solution in this instance.
Kalman Toth Database & OLAP Architect
SQL Server 2014 Design & Programming
New Book / Kindle: Exam 70-461 Bootcamp: Querying Microsoft SQL Server 2012 -
Two different results using one query
Hi Friends
Oracle version that I am using is : Oracle Database 10g Enterprise Edition Release 10.2.0.2.0 - 64bit Production
With the Partitioning, OLAP and Data Mining options
I have a scenario where one account can be related to two customers. Hence, in table have many rows for one account. Here’s the sample data:
Account_ID | product_code | cust_id | relationship_code | entity_code
1111 | ABC | 1234 | SOL | CUST
1111 | ABC | 2222 | ZZZ | LINK
1111 | ABC | 4455 | ABC | LINK
2222 | ABC | 7890 | SOL | CUST
2222 | ABC | 5678 | ZZZ | LINK
3333 | JFK | 5878 | TST | CUST
3333 | JFK | 3254 | PRI | CUST
3333 | JFK | 3299 | PRI | CUST
4444 | JFK | 2535 | SOL | CUST
4444 | JFK | 4565 | SOL | CUST
5555 | DEF | 6666 | PRI | CUST
5555 | DEF | 6667 | TST | CUST
5555 | DEF | 9667 | TST | CUSTIn this scenario, I need two outputs differently:
Output 1: When an account has relationship_code = ‘SOL’ then take the least cust_id
1111 | ABC | 1234 | SOL | CUST
2222 | ABC | 5678 | ZZZ | LINK
4444 | JFK | 2535 | SOL | CUST Output 2: else take the highest cust_id
3333 | JFK | 5878 | TST | CUST
5555 | DEF | 9667 | TST | CUSTHow can I get this result using one query?Not sure what you mean. Works OK:
SQL> with t as (
2 select 1111 account_ID,'ABC' product_code,1234 cust_id,'SOL' relationship_code,'CUST' entity_code from dual union all
3 select 1111,'ABC',2222,'ZZZ','LINK' from dual union all
4 select 1111,'ABC',4455,'ABC','LINK' from dual union all
5 select 2222,'ABC',7890,'SOL','CUST' from dual union all
6 select 2222,'ABC',5678,'ZZZ','LINK' from dual union all
7 select 3333,'JFK',5878,'TST','CUST' from dual union all
8 select 3333,'JFK',3254,'PRI','CUST' from dual union all
9 select 3333,'JFK',3299,'PRI','CUST' from dual union all
10 select 4444,'JFK',2535,'SOL','CUST' from dual union all
11 select 4444,'JFK',4565,'SOL','CUST' from dual union all
12 select 5555,'DEF',6666,'PRI','CUST' from dual union all
13 select 5555,'DEF',6667,'TST','CUST' from dual union all
14 select 5555,'DEF',9667,'TST','CUST' from dual union all
15 select 6666,'XYZ',8877,'SOL','CUST' from dual
16 )
17 select account_ID,
18 product_code,
19 cust_id,
20 relationship_code,
21 entity_code
22 from (
23 select account_ID,
24 product_code,
25 cust_id,
26 relationship_code,
27 entity_code,
28 case max(case relationship_code when 'SOL' then 1 else 0 end) over(partition by account_ID)
29 when 1 then dense_rank() over(partition by account_ID order by cust_id)
30 else dense_rank() over(partition by account_ID order by cust_id desc)
31 end rnk
32 from t
33 )
34 where rnk = 1
35 /
ACCOUNT_ID PRO CUST_ID REL ENTI
1111 ABC 1234 SOL CUST
2222 ABC 5678 ZZZ LINK
3333 JFK 5878 TST CUST
4444 JFK 2535 SOL CUST
5555 DEF 9667 TST CUST
6666 XYZ 8877 SOL CUST
6 rows selected.
SQL> SY. -
Help! Inaccessible iterator when using dynamic query
Hi!
I have a problem retreiving results from a dynamic query into sqlj iterator.
I consulted the Oracle App Dev Guide and Oracle SQLJ Dev Guide and wrote the following code:
<PRE>
package pmServer;
#sql iterator LocIterator (int id, String name);
public class pmRISDImpl
public int GetLocations(...)
LocIterator locIt;
String q = "select ID, NAME from PMADM.LOCATIONS";
#sql
BEGIN
open :OUT locIt for :q;
END;
</PRE>
When I try to compile it using tools provided by JDeveloper ver 3.2.2.(Build 915) for JDK 1.2.2 I get error for #sql statement:
Inaccessible Java type for host item locIt (at position #1): pmServer.LocIterator
and warning:
Type pmServer.LocIterator of host item locIt (at position #1) is not permitted in JDBC. This will not be portable.
Althow the code is identcal to those demonstrated in Oracle document "Oracle8 i
SQLJ Developers Guide and Reference
Release 3 (8.1.7)
July 2000
Part No. A83723-01" pp 12-67 (PL/SQL in SQLJ for Dynamic SQLDynamicDemo.sqlj). There it looks like
<PRE>
private static void dynamicSelectMany(String what_cond)
throws SQLException {
System.out.println("dynamic multi-row query on table emp");
Employees empIter;
// table/column names cannot be bind args in dynamic PL/SQL, so
// build up query as Java string
String query = "select ename, sal from emp " +
(((what_cond == null) | | (what_cond.equals(""))) ? "" :
(" where " + what_cond)) +
"order by ename";
#sql {
begin
open :OUT empIter for -- opening ref cursor with dynamic query
:query;
-- can have USING clause here if needed
end;
while (empIter.next()) {
System.out.println("Employee " + empIter.ename() +
" has salary " + empIter.sal() );
empIter.close();
</PRE>
Please guide me what should I do to get it working.
nullIn the CAST statement the SQLJ runtime must be able to produce an instance of you SQLJ iterator using Java reflection.
This necessitates that the iterator class must be accessible by public.
You have two options:
(1) Declare the iterator public. This requires that you put it in its own file LocIterator.sqlj:
#sql public iterator LocIterator (int id, String name);
(2) Declare the iterator as an inner class. In this case you want to make it public static (that is it does not require an instance of the outer class in scope). You might write the following.
package pmServer;
public class pmRISDImpl
#sql public static iterator LocIterator (int id, String name);
(3) If you are using Oracle 9i you have another option. You can embed dynamic SQL fragments directly in your SQLJ code and do not need to use the CAST:
public int GetLocations(...)
LocIterator locIt;
String q = "PMADM.LOCATIONS";
#sql locIt = { select ID, NAME from :{q} }; // Note new syntax :{q} for embedding SQL source code
} -
Display results from dynamic query created and executed inside procedure
Hi;
I have created this code:
CREATE OR REPLACE PROCEDURE RunDynamicQuery(Var1 IN VARCHAR2, Var2 IN VARCHAR2, VAR3 IN VARCHAR2) AS
-- Do something
-- That ends up with a variable holding a query.... (just an example)
MainQuery :='select sysdate from dual';
end RunDynamicQuery;
How can I run this procedure and see the result on the dymanic query generated inside it?
BEGIN
compare_tables_content('VAR1','VAR2','VAR3');
END;
Expected Output for this given example:
20-05-2009 11:04:44 ( the result of the dymanic query inside the procedure variable MainQuery :='select sysdate from dual';)
I tested with 'execute immediate':
CREATE OR REPLACE PROCEDURE RunDynamicQuery(Var1 IN VARCHAR2, Var2 IN VARCHAR2, filter IN VARCHAR2) AS
-- Do something
-- That ends up with a variable holding a query.... (just an example)
MainQuery :='select sysdate from dual';
execute immediate (MainQuery );
end RunDynamicQuery;
BEGIN
compare_tables_content('VAR1','VAR2','VAR3');
END;
Output:"Statement processed'' (no sysdate displayed ! )
Please consider that the collums in the query are always dynamic... PIPELINE Table would not work because I would need to define a container, example:
CREATE OR REPLACE TYPE emp_tabtype AS TABLE OF emp_type;
FUNCTION RunDynamicQuery (p_cursor IN sys_refcursor)
RETURN emp_tabtype PIPELINED
IS
emp_in emp%ROWTYPE;
BEGIN
LOOP
FETCH p_cursor
INTO emp_in;
EXIT WHEN p_cursor%NOTFOUND;
PIPE ROW (...)That would be a nice solution, thanks :)
''For now'' I implemented like this:
My dynamic query now returns a single string ( select col1 || col2 || col3 from bla)
This way I don't have dynamic collumns issue, and from business side, this ''string'' format works for them.
This way I can use the pipelines to get the result out...
OPEN myCursor FOR MainQuery;
FETCH myCursor
INTO myRow;
WHILE (NOT myCursor%notFound) LOOP
PIPE ROW(myRow);
FETCH myCursor
INTO myRow;
END LOOP;
CLOSE myCursor; -
Web Intelligence Report unable to retrieve data on "Run Query" option
When I add a new dimension or measure to a report using "Edit query" and there after i run the query, it takes 10 to 12 mints to process the data and there after shows the message "no data retrieved" but as I click on refresh data button , I am able to see the data.
Hi,
May be the new combination may not result any data or if you are using .net panel where we can't edit the data provider. If you are using java interactive panel then you can edit the query and get the result.
cheers,
Suresh Aluri.
Edited by: Suresh Babu Aluri on Sep 8, 2009 8:49 PM -
How to use dynamic query for this ??
hi , i am new to ABAP. i got a requirement to write dynamic query for the following code.
kindly address. two set of queries are same.but condition is different.
.IF p_psd EQ ' '.
*C--End of change DF 1232137- (Transport # :CIDK980530 )
*C--FETCH THE Deliverd Quantiity and Material Number
SELECT aufnr "ORDER number
wemng "Quantity of goods received for the order item
matnr "MATERIAL NUMBER
pwerk "PLANT
dauat "Order Type
FROM afpo
INTO TABLE t_afpo
WHERE aufnr IN s_order
AND wemng IN s_dqt
AND matnr IN s_matnr
AND pwerk IN s_plant
AND dauat = c_ro.
IF sy-subrc = 0.
SORT t_afpo BY aufnr matnr pwerk.
*C--FETCH THE OBJECT NUMBER
SELECT aufnr "ORDER number
objnr "Object number
FROM aufk
INTO TABLE t_aufk
FOR ALL ENTRIES IN t_afpo
WHERE aufnr = t_afpo-aufnr.
IF sy-subrc = 0.
SORT t_aufk BY aufnr objnr.
*C--FETCH THE Target Quantiity
SELECT aufnr "ORDER number
gamng "Total order quantity target quantity
FROM afko
INTO TABLE t_afko
FOR ALL ENTRIES IN t_afpo
WHERE aufnr = t_afpo-aufnr
AND gamng IN s_tqt.
IF sy-subrc = 0.
SORT t_afko BY aufnr .
ENDIF.
ENDIF.
ELSE.
MESSAGE text-e03 TYPE c_s. " No data for the selection criteria
LEAVE LIST-PROCESSING.
ENDIF.
*C--Begin of change DF 1232137- (Transport # :CIDK980530 )
ENDIF.
IF p_psd EQ c_x.
SELECT aufnr "ORDER number
wemng "Quantity of goods received for the order item
matnr "MATERIAL NUMBER
pwerk "PLANT
dauat "Order Type
FROM afpo
INTO TABLE t_afpo
WHERE aufnr IN s_order
AND wemng > 0
AND matnr IN s_matnr
AND pwerk IN s_plant
AND dauat = c_ro.
if sy-subrc = 0.
*C--FETCH THE OBJECT NUMBER
IF NOT t_afpo[] IS INITIAL.
SORT t_afpo BY aufnr matnr pwerk.
SELECT aufnr "ORDER number
objnr "Object number
FROM aufk
INTO TABLE t_aufk
FOR ALL ENTRIES IN t_afpo
WHERE aufnr = t_afpo-aufnr.
IF sy-subrc = 0.
SORT t_afko BY aufnr gamng.
ELSE.
MESSAGE text-e03 TYPE c_s. " No data for the selection criteria
LEAVE LIST-PROCESSING.
ENDIF.
ENDIF.
IF NOT t_afpo[] IS INITIAL.
*C--FETCH THE Target Quantiity
SELECT aufnr "ORDER number
gamng "Total order quantity target quantity
FROM afko
INTO TABLE t_afko
FOR ALL ENTRIES IN t_afpo
WHERE aufnr = t_afpo-aufnr
AND gamng <> t_afpo-wemng .
IF sy-subrc = 0.
SORT t_afko BY aufnr gamng.
ELSE.
MESSAGE text-e03 TYPE c_s. " No data for the selection criteria
LEAVE LIST-PROCESSING.
ENDIF.
ENDIF.
ELSE.
MESSAGE text-e03 TYPE c_s. " No data for the selection criteria
LEAVE LIST-PROCESSING.
ENDIF.
Edited by: Thomas Zloch on Jan 5, 2011 1:30 PM please use code tagsHi friend,
Try using MACRO and dynamic WHERE condition.
Group simialr Select statements under a Macro.
Build a dynamic where by checking conditions
Call macro passing dynamic where condition.
TABLES afpo.
DATA: str TYPE string.
*Macro definition
DEFINE operation.
select single *
from afpo into afpo
where (&1). " Dynamic condition
END-OF-DEFINITION.
*Build dynamic WHERE by checking some conditions
*If conditon
CONCATENATE 'AUFNR = ''000000700008''' 'AND POSNR = ''0001''' INTO str SEPARATED BY space.
*Else
CONCATENATE 'AUFNR = ''000000700008''' 'AND POSNR = ''0002''' INTO str SEPARATED BY space.
*Endif.
*Call Macro passing dynamic WHERE condition
operation str. -
Create table problem using Dynamic Query
Hi all,
I want to create a temporary table within a stored procedure so I decided to do it using a dynamic query:
create or replace procedure p1
as
begin
execute immediate 'CREATE GLOBAL TEMPORARY TABLE tt(id number(2))';
end;
/ It created successfuly but when I execute that procedure I got:SQL> exec p1;
BEGIN p1; END;
ERROR at line 1:
ORA-01031: insufficient privileges
ORA-06512: at "SCOTT.P1", line 4
ORA-06512: at line 1 While I can create that table using the same user without any problem!
My question is:What privilege should I grant to user(minimum of privileges please! ) to execute that procedure successfuly?
-ThanksHi,
To say a little bit more about Nicolas' answer:
SQL> grant create table to scott;
This is the right answer, but you might wonder why you have to do so if you usually can create tables with this user..
11:59:19 TEST.SQL>CREATE USER UTEST
11:59:28 2 IDENTIFIED BY UTEST;
User created.
11:59:35 TEST.SQL>CREATE ROLE RTEST;
Role created.
11:59:40 TEST.SQL>GRANT RTEST TO UTEST;
Grant succeeded.
11:59:45 TEST.SQL>GRANT CREATE SESSION TO RTEST;
Grant succeeded.
11:59:54 TEST.SQL>GRANT CREATE TABLE TO RTEST;
Grant succeeded.
12:00:03 TEST.SQL>GRANT UNLIMITED TABLESPACE TO UTEST;
Grant succeeded.
12:00:17 TEST.SQL>CREATE PROCEDURE UTEST.CT_TEST
12:00:32 2 IS
12:00:33 3 BEGIN
12:00:35 4 EXECUTE IMMEDIATE 'CREATE TABLE UTEST.TTEST (A NUMBER)';
12:00:56 5 END;
12:00:58 6 /
Procedure created.
12:00:59 TEST.SQL>EXEC UTEST.CT_TEST;
BEGIN UTEST.CT_TEST; END;
ERROR at line 1:
ORA-01031: insufficient privileges
ORA-06512: at "UTEST.CT_TEST", line 4
ORA-06512: at line 1
12:01:06 TEST.SQL>GRANT CREATE TABLE TO UTEST;
Grant succeeded.
12:01:15 TEST.SQL>EXEC UTEST.CT_TEST;
PL/SQL procedure successfully completed.Don't forget that when you're using PL/SQL, privileges granted via roles are ignored!
Regards,
Yoann. -
Unable to display results of multiple query in grid in Oracle SQL Developer
Hi, I am a newbie to this forum and couldn't find the Oracle SQL Developer forum so posting it here.
My question: How to display multiple query results in grid in Oracle SQL Developer.
Example:
select * from Employee;
select * from Department;
- when I select both the queries and hit F5 in Oracle sql developer. By default it displays in output window.
- How to display result of both the queries in Grid.
Any thoughts on this would be really helpful.
Thanks in advance.
HarshHi Harsh,
I'd say that the Results grid is designed to only show the results of 1 query at a time. I don't know/can't see how it would display multiple queries at a time.
I would suggest either joining your tables to create a single query or opening another SQL Worksheet for one of the queries so that you can display the results side-by-side.
Maybe you could explain what you're trying to do. Why are you trying to display multiple results in the same query grid? -
Unable to get Results using Connection Pool
Hi All,
I have been trying to create JDBC connection pooling provided by the Apache Tomcat 4.0 with MySQL 4.0.16-nt at http://jakarta.apache.org/tomcat/tomcat-4.1-doc/jndi-datasource-examples-howto.html and my configuration is as follows
server.xml
<Context path="/DBTest" docBase="DBTest"
debug="5" reloadable="true" crossContext="true">
<Logger className="org.apache.catalina.logger.FileLogger"
prefix="localhost_DBTest_log." suffix=".txt"
timestamp="true"/>
<Resource name="jdbc/TestDB"
auth="Container"
type="javax.sql.DataSource"/>
<ResourceParams name="jdbc/TestDB">
<parameter>
<name>factory</name>
<value>org.apache.commons.dbcp.BasicDataSourceFactory</value>
</parameter>
<!-- Maximum number of dB connections in pool. Make sure you
configure your mysqld max_connections large enough to handle
all of your db connections. Set to 0 for no limit.
-->
<parameter>
<name>maxActive</name>
<value>100</value>
</parameter>
<!-- Maximum number of idle dB connections to retain in pool.
Set to 0 for no limit.
-->
<parameter>
<name>maxIdle</name>
<value>30</value>
</parameter>
<!-- Maximum time to wait for a dB connection to become available
in ms, in this example 10 seconds. An Exception is thrown if
this timeout is exceeded. Set to -1 to wait indefinitely.
-->
<parameter>
<name>maxWait</name>
<value>10000</value>
</parameter>
<!-- MySQL dB username and password for dB connections -->
<parameter>
<name>username</name>
<value>javauser</value>
</parameter>
<parameter>
<name>password</name>
<value>javadude</value>
</parameter>
<!-- Class name for mm.mysql JDBC driver -->
<parameter>
<name>driverClassName</name>
<value>org.gjt.mm.mysql.Driver</value>
</parameter>
<!-- The JDBC connection url for connecting to your MySQL dB.
The autoReconnect=true argument to the url makes sure that the
mm.mysql JDBC Driver will automatically reconnect if mysqld closed the
connection. mysqld by default closes idle connections after 8 hours.
-->
<parameter>
<name>url</name>
<value>jdbc:mysql://localhost:3306/javatest?autoReconnect=true</value>
</parameter>
</ResourceParams>
</Context>
web.xml
<?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE web-app PUBLIC
"-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
"http://java.sun.com/dtd/web-app_2_3.dtd">
<web-app>
<description>MySQL Test App</description>
<resource-ref>
<description>DB Connection</description>
<res-ref-name>jdbc/TestDB</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth>
</resource-ref>
</web-app>
test.jsp
<jsp:useBean id="foo" class="foo.DBTest" scope="page" />
<html>
<head>
<title>DB Test</title>
</head>
<body>
<%
foo.DBTest tst = new foo.DBTest();
tst.init();
%>
<h2>Results</h2>
Foo <%= tst.getFoo() %>
Bar <%= tst.getBar() %>
</body>
</html>
DBTest.java package
package foo;
import javax.naming.*;
import javax.sql.*;
import java.sql.*;
public class DBTest {
String foo = "Not Connected";
int bar = -1;
public void init() {
try{
Context ctx = new InitialContext();
if(ctx == null )
throw new Exception("Boom - No Context");
DataSource ds =
(DataSource)ctx.lookup(
"java:comp/env/jdbc/TestDB");
if (ds != null) {
Connection conn = ds.getConnection();
if(conn != null) {
foo = "Got Connection "+conn.toString();
Statement stmt = conn.createStatement();
ResultSet rst =
stmt.executeQuery(
"select id, foo, bar from testdata");
if(rst.next()) {
foo=rst.getString(2);
bar=rst.getInt(3);
conn.close();
}catch(Exception e) {
e.printStackTrace();
public String getFoo() { return foo; }
public int getBar() { return bar;}
Now when I am trying to run this on browser, everything goes fine except it doesn't show the expected results, instead of that it shows following in the browser:-
Results
Foo Not Connected
Bar -1
Can anybody help me out as to why I am getting such result while everything is right from my side. Is the program unable to connect to the database or it is not supporting the JDBC version that I am using.
Thanks in advance
Regards
VikasI've seen cases where NOT using the ResourceParams section, and instead using attributes in the Resource section will fix this. Don't know why.
i.e.
Instead of using:
<parameter>
<name>driverClassName</name>
<value>org.gjt.mm.mysql.Driver</value>
</parameter>use the driver attribute of the Resource tag:
<Resource name="jdbc/TestDB"
auth="Container"
type="javax.sql.DataSource"
driver="org.gjt.mm.mysql.Driver"/>Also note...I don't use the org.gjt.mm.mysql.Driver class (which is in the distribution), I use com.mysql.jdbc.Driver. Any reason you don't? This could be part of it. I don't really know.
Maybe you are looking for
-
How to Uninstall Leopard Upgrade and go back to Tiger
I would like to go back to Tiger and was wondering how to uninstall the Leopard upgrade without having to do a full reformat. Is this possible? Thanks in advance!
-
any one please
-
I am having problems getting a mouse click registered in a Java 3D environment. Basically I have a canvas3D object, onto which I have created a 3D graph and have populated it with points (plotted in 3D space). I really need to be able to click on the
-
InDesign unexpectedly quits when trying to create pdf
in Design and photoshop unexpectedly quit when i try to create a pdf from within the programs. what can i do to fix this? i can't even creat the pdf from acrobat because it says that the file type is either not supported or the file is damaged, but i
-
I have a small number of users on my corporate network who have Firefox installed. I need to be able to control the settings in the same way as I can for Internet Explorer in order to force the users to go through our web proxy. What's the best metho