Query embedded SOLID database in WCS
I was wondering if it is possible to query the WCS embedded SOLID DB with the Solid JDBC driver?
I am using syslog to analyze the logs but I would like to have the mapping MAC to AP name available from outside WCS so I can send more readable error mails.
Hi there,
Please have a look to this post: https://supportforums.cisco.com/message/3683444.
It explains how you can change the password to directly access the WCS DB.
HTH
Stephan
Similar Messages
-
Query in timesten taking more time than query in oracle database
Hi,
Can anyone please explain me why query in timesten taking more time
than query in oracle database.
I am mentioning in detail what are my settings and what have I done
step by step.........
1.This is the table I created in Oracle datababase
(Oracle Database 10g Enterprise Edition Release 10.2.0.1.0)...
CREATE TABLE student (
id NUMBER(9) primary keY ,
first_name VARCHAR2(10),
last_name VARCHAR2(10)
2.THIS IS THE ANONYMOUS BLOCK I USE TO
POPULATE THE STUDENT TABLE(TOTAL 2599999 ROWS)...
declare
firstname varchar2(12);
lastname varchar2(12);
catt number(9);
begin
for cntr in 1..2599999 loop
firstname:=(cntr+8)||'f';
lastname:=(cntr+2)||'l';
if cntr like '%9999' then
dbms_output.put_line(cntr);
end if;
insert into student values(cntr,firstname, lastname);
end loop;
end;
3. MY DSN IS SET THE FOLLWING WAY..
DATA STORE PATH- G:\dipesh3repo\db
LOG DIRECTORY- G:\dipesh3repo\log
PERM DATA SIZE-1000
TEMP DATA SIZE-1000
MY TIMESTEN VERSION-
C:\Documents and Settings\dipesh>ttversion
TimesTen Release 7.0.3.0.0 (32 bit NT) (tt70_32:17000) 2007-09-19T16:04:16Z
Instance admin: dipesh
Instance home directory: G:\TimestTen\TT70_32
Daemon home directory: G:\TimestTen\TT70_32\srv\info
THEN I CONNECT TO THE TIMESTEN DATABASE
C:\Documents and Settings\dipesh> ttisql
command>connect "dsn=dipesh3;oraclepwd=tiger";
4. THEN I START THE AGENT
call ttCacheUidPwdSet('SCOTT','TIGER');
Command> CALL ttCacheStart();
5.THEN I CREATE THE READ ONLY CACHE GROUP AND LOAD IT
create readonly cache group rc_student autorefresh
interval 5 seconds from student
(id int not null primary key, first_name varchar2(10), last_name varchar2(10));
load cache group rc_student commit every 100 rows;
6.NOW I CAN ACCESS THE TABLES FROM TIMESTEN AND PERFORM THE QUERY
I SET THE TIMING..
command>TIMING 1;
consider this query now..
Command> select * from student where first_name='2155666f';
< 2155658, 2155666f, 2155660l >
1 row found.
Execution time (SQLExecute + Fetch Loop) = 0.668822 seconds.
another query-
Command> SELECT * FROM STUDENTS WHERE FIRST_NAME='2340009f';
2206: Table SCOTT.STUDENTS not found
Execution time (SQLPrepare) = 0.074964 seconds.
The command failed.
Command> SELECT * FROM STUDENT where first_name='2093434f';
< 2093426, 2093434f, 2093428l >
1 row found.
Execution time (SQLExecute + Fetch Loop) = 0.585897 seconds.
Command>
7.NOW I PERFORM THE SIMILAR QUERIES FROM SQLPLUS...
SQL> SELECT * FROM STUDENT WHERE FIRST_NAME='1498671f';
ID FIRST_NAME LAST_NAME
1498663 1498671f 1498665l
Elapsed: 00:00:00.15
Can anyone please explain me why query in timesten taking more time
that query in oracle database.
Message was edited by: Dipesh Majumdar
user542575
Message was edited by:
user542575TimesTen
Hardware: Windows Server 2003 R2 Enterprise x64; 8 x Dual-core AMD 8216 2.41GHz processors; 32 GB RAM
Version: 7.0.4.0.0 64 bit
Schema:
create usermanaged cache group factCache from
MV_US_DATAMART
ORDER_DATE DATE,
IF_SYSTEM VARCHAR2(32) NOT NULL,
GROUPING_ID TT_BIGINT,
TIME_DIM_ID TT_INTEGER NOT NULL,
BUSINESS_DIM_ID TT_INTEGER NOT NULL,
ACCOUNT_DIM_ID TT_INTEGER NOT NULL,
ORDERTYPE_DIM_ID TT_INTEGER NOT NULL,
INSTR_DIM_ID TT_INTEGER NOT NULL,
EXECUTION_DIM_ID TT_INTEGER NOT NULL,
EXEC_EXCHANGE_DIM_ID TT_INTEGER NOT NULL,
NO_ORDERS TT_BIGINT,
FILLED_QUANTITY TT_BIGINT,
CNT_FILLED_QUANTITY TT_BIGINT,
QUANTITY TT_BIGINT,
CNT_QUANTITY TT_BIGINT,
COMMISSION BINARY_FLOAT,
CNT_COMMISSION TT_BIGINT,
FILLS_NUMBER TT_BIGINT,
CNT_FILLS_NUMBER TT_BIGINT,
AGGRESSIVE_FILLS TT_BIGINT,
CNT_AGGRESSIVE_FILLS TT_BIGINT,
NOTIONAL BINARY_FLOAT,
CNT_NOTIONAL TT_BIGINT,
TOTAL_PRICE BINARY_FLOAT,
CNT_TOTAL_PRICE TT_BIGINT,
CANCELLED_ORDERS_COUNT TT_BIGINT,
CNT_CANCELLED_ORDERS_COUNT TT_BIGINT,
ROUTED_ORDERS_NO TT_BIGINT,
CNT_ROUTED_ORDERS_NO TT_BIGINT,
ROUTED_LIQUIDITY_QTY TT_BIGINT,
CNT_ROUTED_LIQUIDITY_QTY TT_BIGINT,
REMOVED_LIQUIDITY_QTY TT_BIGINT,
CNT_REMOVED_LIQUIDITY_QTY TT_BIGINT,
ADDED_LIQUIDITY_QTY TT_BIGINT,
CNT_ADDED_LIQUIDITY_QTY TT_BIGINT,
AGENT_CHARGES BINARY_FLOAT,
CNT_AGENT_CHARGES TT_BIGINT,
CLEARING_CHARGES BINARY_FLOAT,
CNT_CLEARING_CHARGES TT_BIGINT,
EXECUTION_CHARGES BINARY_FLOAT,
CNT_EXECUTION_CHARGES TT_BIGINT,
TRANSACTION_CHARGES BINARY_FLOAT,
CNT_TRANSACTION_CHARGES TT_BIGINT,
ORDER_MANAGEMENT BINARY_FLOAT,
CNT_ORDER_MANAGEMENT TT_BIGINT,
SETTLEMENT_CHARGES BINARY_FLOAT,
CNT_SETTLEMENT_CHARGES TT_BIGINT,
RECOVERED_AGENT BINARY_FLOAT,
CNT_RECOVERED_AGENT TT_BIGINT,
RECOVERED_CLEARING BINARY_FLOAT,
CNT_RECOVERED_CLEARING TT_BIGINT,
RECOVERED_EXECUTION BINARY_FLOAT,
CNT_RECOVERED_EXECUTION TT_BIGINT,
RECOVERED_TRANSACTION BINARY_FLOAT,
CNT_RECOVERED_TRANSACTION TT_BIGINT,
RECOVERED_ORD_MGT BINARY_FLOAT,
CNT_RECOVERED_ORD_MGT TT_BIGINT,
RECOVERED_SETTLEMENT BINARY_FLOAT,
CNT_RECOVERED_SETTLEMENT TT_BIGINT,
CLIENT_AGENT BINARY_FLOAT,
CNT_CLIENT_AGENT TT_BIGINT,
CLIENT_ORDER_MGT BINARY_FLOAT,
CNT_CLIENT_ORDER_MGT TT_BIGINT,
CLIENT_EXEC BINARY_FLOAT,
CNT_CLIENT_EXEC TT_BIGINT,
CLIENT_TRANS BINARY_FLOAT,
CNT_CLIENT_TRANS TT_BIGINT,
CLIENT_CLEARING BINARY_FLOAT,
CNT_CLIENT_CLEARING TT_BIGINT,
CLIENT_SETTLE BINARY_FLOAT,
CNT_CLIENT_SETTLE TT_BIGINT,
CHARGEABLE_TAXES BINARY_FLOAT,
CNT_CHARGEABLE_TAXES TT_BIGINT,
VENDOR_CHARGE BINARY_FLOAT,
CNT_VENDOR_CHARGE TT_BIGINT,
ROUTING_CHARGES BINARY_FLOAT,
CNT_ROUTING_CHARGES TT_BIGINT,
RECOVERED_ROUTING BINARY_FLOAT,
CNT_RECOVERED_ROUTING TT_BIGINT,
CLIENT_ROUTING BINARY_FLOAT,
CNT_CLIENT_ROUTING TT_BIGINT,
TICKET_CHARGES BINARY_FLOAT,
CNT_TICKET_CHARGES TT_BIGINT,
RECOVERED_TICKET_CHARGES BINARY_FLOAT,
CNT_RECOVERED_TICKET_CHARGES TT_BIGINT,
PRIMARY KEY(ORDER_DATE, TIME_DIM_ID, BUSINESS_DIM_ID, ACCOUNT_DIM_ID, ORDERTYPE_DIM_ID, INSTR_DIM_ID, EXECUTION_DIM_ID,EXEC_EXCHANGE_DIM_ID),
READONLY);
No of rows: 2228558
Config:
< CkptFrequency, 600 >
< CkptLogVolume, 0 >
< CkptRate, 0 >
< ConnectionCharacterSet, US7ASCII >
< ConnectionName, tt_us_dma >
< Connections, 64 >
< DataBaseCharacterSet, AL32UTF8 >
< DataStore, e:\andrew\datacache\usDMA >
< DurableCommits, 0 >
< GroupRestrict, <NULL> >
< LockLevel, 0 >
< LockWait, 10 >
< LogBuffSize, 65536 >
< LogDir, e:\andrew\datacache\ >
< LogFileSize, 64 >
< LogFlushMethod, 1 >
< LogPurge, 0 >
< Logging, 1 >
< MemoryLock, 0 >
< NLS_LENGTH_SEMANTICS, BYTE >
< NLS_NCHAR_CONV_EXCP, 0 >
< NLS_SORT, BINARY >
< OracleID, NYCATP1 >
< PassThrough, 0 >
< PermSize, 4000 >
< PermWarnThreshold, 90 >
< PrivateCommands, 0 >
< Preallocate, 0 >
< QueryThreshold, 0 >
< RACCallback, 0 >
< SQLQueryTimeout, 0 >
< TempSize, 514 >
< TempWarnThreshold, 90 >
< Temporary, 1 >
< TransparentLoad, 0 >
< TypeMode, 0 >
< UID, OS_OWNER >
ORACLE:
Hardware: Sunos 5.10; 24x1.8Ghz (unsure of type); 82 GB RAM
Version 10g Enterprise Edition Release 10.2.0.3.0 - 64bit Production
Schema:
CREATE MATERIALIZED VIEW OS_OWNER.MV_US_DATAMART
TABLESPACE TS_OS
PARTITION BY RANGE (ORDER_DATE)
PARTITION MV_US_DATAMART_MINVAL VALUES LESS THAN (TO_DATE(' 2007-11-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN'))
LOGGING
NOCOMPRESS
TABLESPACE TS_OS,
PARTITION MV_US_DATAMART_07_NOV_D1 VALUES LESS THAN (TO_DATE(' 2007-11-11 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN'))
LOGGING
NOCOMPRESS
TABLESPACE TS_OS,
PARTITION MV_US_DATAMART_07_NOV_D2 VALUES LESS THAN (TO_DATE(' 2007-11-21 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN'))
LOGGING
NOCOMPRESS
TABLESPACE TS_OS,
PARTITION MV_US_DATAMART_07_NOV_D3 VALUES LESS THAN (TO_DATE(' 2007-12-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN'))
LOGGING
NOCOMPRESS
TABLESPACE TS_OS,
PARTITION MV_US_DATAMART_07_DEC_D1 VALUES LESS THAN (TO_DATE(' 2007-12-11 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN'))
LOGGING
NOCOMPRESS
TABLESPACE TS_OS,
PARTITION MV_US_DATAMART_07_DEC_D2 VALUES LESS THAN (TO_DATE(' 2007-12-21 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN'))
LOGGING
NOCOMPRESS
TABLESPACE TS_OS,
PARTITION MV_US_DATAMART_07_DEC_D3 VALUES LESS THAN (TO_DATE(' 2008-01-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN'))
LOGGING
NOCOMPRESS
TABLESPACE TS_OS,
PARTITION MV_US_DATAMART_08_JAN_D1 VALUES LESS THAN (TO_DATE(' 2008-01-11 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN'))
LOGGING
NOCOMPRESS
TABLESPACE TS_OS,
PARTITION MV_US_DATAMART_08_JAN_D2 VALUES LESS THAN (TO_DATE(' 2008-01-21 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN'))
LOGGING
NOCOMPRESS
TABLESPACE TS_OS,
PARTITION MV_US_DATAMART_08_JAN_D3 VALUES LESS THAN (TO_DATE(' 2008-02-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN'))
LOGGING
NOCOMPRESS
TABLESPACE TS_OS,
PARTITION MV_US_DATAMART_MAXVAL VALUES LESS THAN (MAXVALUE)
LOGGING
NOCOMPRESS
TABLESPACE TS_OS
NOCACHE
NOCOMPRESS
NOPARALLEL
BUILD DEFERRED
USING INDEX
TABLESPACE TS_OS_INDEX
REFRESH FAST ON DEMAND
WITH PRIMARY KEY
ENABLE QUERY REWRITE
AS
SELECT order_date, if_system,
GROUPING_ID (order_date,
if_system,
business_dim_id,
time_dim_id,
account_dim_id,
ordertype_dim_id,
instr_dim_id,
execution_dim_id,
exec_exchange_dim_id
) GROUPING_ID,
/* ============ DIMENSIONS ============ */
time_dim_id, business_dim_id, account_dim_id, ordertype_dim_id,
instr_dim_id, execution_dim_id, exec_exchange_dim_id,
/* ============ MEASURES ============ */
-- o.FX_RATE /* FX_RATE */,
COUNT (*) no_orders,
-- SUM(NO_ORDERS) NO_ORDERS,
-- COUNT(NO_ORDERS) CNT_NO_ORDERS,
SUM (filled_quantity) filled_quantity,
COUNT (filled_quantity) cnt_filled_quantity, SUM (quantity) quantity,
COUNT (quantity) cnt_quantity, SUM (commission) commission,
COUNT (commission) cnt_commission, SUM (fills_number) fills_number,
COUNT (fills_number) cnt_fills_number,
SUM (aggressive_fills) aggressive_fills,
COUNT (aggressive_fills) cnt_aggressive_fills,
SUM (fx_rate * filled_quantity * average_price) notional,
COUNT (fx_rate * filled_quantity * average_price) cnt_notional,
SUM (fx_rate * fills_number * average_price) total_price,
COUNT (fx_rate * fills_number * average_price) cnt_total_price,
SUM (CASE
WHEN order_status = 'C'
THEN 1
ELSE 0
END) cancelled_orders_count,
COUNT (CASE
WHEN order_status = 'C'
THEN 1
ELSE 0
END
) cnt_cancelled_orders_count,
-- SUM(t.FX_RATE*t.NO_FILLS*t.AVG_PRICE) AVERAGE_PRICE,
-- SUM(FILLS_NUMBER*AVERAGE_PRICE) STAGING_AVERAGE_PRICE,
-- COUNT(FILLS_NUMBER*AVERAGE_PRICE) CNT_STAGING_AVERAGE_PRICE,
SUM (routed_orders_no) routed_orders_no,
COUNT (routed_orders_no) cnt_routed_orders_no,
SUM (routed_liquidity_qty) routed_liquidity_qty,
COUNT (routed_liquidity_qty) cnt_routed_liquidity_qty,
SUM (removed_liquidity_qty) removed_liquidity_qty,
COUNT (removed_liquidity_qty) cnt_removed_liquidity_qty,
SUM (added_liquidity_qty) added_liquidity_qty,
COUNT (added_liquidity_qty) cnt_added_liquidity_qty,
SUM (agent_charges) agent_charges,
COUNT (agent_charges) cnt_agent_charges,
SUM (clearing_charges) clearing_charges,
COUNT (clearing_charges) cnt_clearing_charges,
SUM (execution_charges) execution_charges,
COUNT (execution_charges) cnt_execution_charges,
SUM (transaction_charges) transaction_charges,
COUNT (transaction_charges) cnt_transaction_charges,
SUM (order_management) order_management,
COUNT (order_management) cnt_order_management,
SUM (settlement_charges) settlement_charges,
COUNT (settlement_charges) cnt_settlement_charges,
SUM (recovered_agent) recovered_agent,
COUNT (recovered_agent) cnt_recovered_agent,
SUM (recovered_clearing) recovered_clearing,
COUNT (recovered_clearing) cnt_recovered_clearing,
SUM (recovered_execution) recovered_execution,
COUNT (recovered_execution) cnt_recovered_execution,
SUM (recovered_transaction) recovered_transaction,
COUNT (recovered_transaction) cnt_recovered_transaction,
SUM (recovered_ord_mgt) recovered_ord_mgt,
COUNT (recovered_ord_mgt) cnt_recovered_ord_mgt,
SUM (recovered_settlement) recovered_settlement,
COUNT (recovered_settlement) cnt_recovered_settlement,
SUM (client_agent) client_agent,
COUNT (client_agent) cnt_client_agent,
SUM (client_order_mgt) client_order_mgt,
COUNT (client_order_mgt) cnt_client_order_mgt,
SUM (client_exec) client_exec, COUNT (client_exec) cnt_client_exec,
SUM (client_trans) client_trans,
COUNT (client_trans) cnt_client_trans,
SUM (client_clearing) client_clearing,
COUNT (client_clearing) cnt_client_clearing,
SUM (client_settle) client_settle,
COUNT (client_settle) cnt_client_settle,
SUM (chargeable_taxes) chargeable_taxes,
COUNT (chargeable_taxes) cnt_chargeable_taxes,
SUM (vendor_charge) vendor_charge,
COUNT (vendor_charge) cnt_vendor_charge,
SUM (routing_charges) routing_charges,
COUNT (routing_charges) cnt_routing_charges,
SUM (recovered_routing) recovered_routing,
COUNT (recovered_routing) cnt_recovered_routing,
SUM (client_routing) client_routing,
COUNT (client_routing) cnt_client_routing,
SUM (ticket_charges) ticket_charges,
COUNT (ticket_charges) cnt_ticket_charges,
SUM (recovered_ticket_charges) recovered_ticket_charges,
COUNT (recovered_ticket_charges) cnt_recovered_ticket_charges
FROM us_datamart_raw
GROUP BY order_date,
if_system,
business_dim_id,
time_dim_id,
account_dim_id,
ordertype_dim_id,
instr_dim_id,
execution_dim_id,
exec_exchange_dim_id;
-- Note: Index I_SNAP$_MV_US_DATAMART will be created automatically
-- by Oracle with the associated materialized view.
CREATE UNIQUE INDEX OS_OWNER.MV_US_DATAMART_UDX ON OS_OWNER.MV_US_DATAMART
(ORDER_DATE, TIME_DIM_ID, BUSINESS_DIM_ID, ACCOUNT_DIM_ID, ORDERTYPE_DIM_ID,
INSTR_DIM_ID, EXECUTION_DIM_ID, EXEC_EXCHANGE_DIM_ID)
NOLOGGING
NOPARALLEL
COMPRESS 7;
No of rows: 2228558
The query (taken Mondrian) I run against each of them is:
select sum("MV_US_DATAMART"."NOTIONAL") as "m0"
--, sum("MV_US_DATAMART"."FILLED_QUANTITY") as "m1"
--, sum("MV_US_DATAMART"."AGENT_CHARGES") as "m2"
--, sum("MV_US_DATAMART"."CLEARING_CHARGES") as "m3"
--, sum("MV_US_DATAMART"."EXECUTION_CHARGES") as "m4"
--, sum("MV_US_DATAMART"."TRANSACTION_CHARGES") as "m5"
--, sum("MV_US_DATAMART"."ROUTING_CHARGES") as "m6"
--, sum("MV_US_DATAMART"."ORDER_MANAGEMENT") as "m7"
--, sum("MV_US_DATAMART"."SETTLEMENT_CHARGES") as "m8"
--, sum("MV_US_DATAMART"."COMMISSION") as "m9"
--, sum("MV_US_DATAMART"."RECOVERED_AGENT") as "m10"
--, sum("MV_US_DATAMART"."RECOVERED_CLEARING") as "m11"
--,sum("MV_US_DATAMART"."RECOVERED_EXECUTION") as "m12"
--,sum("MV_US_DATAMART"."RECOVERED_TRANSACTION") as "m13"
--, sum("MV_US_DATAMART"."RECOVERED_ROUTING") as "m14"
--, sum("MV_US_DATAMART"."RECOVERED_ORD_MGT") as "m15"
--, sum("MV_US_DATAMART"."RECOVERED_SETTLEMENT") as "m16"
--, sum("MV_US_DATAMART"."RECOVERED_TICKET_CHARGES") as "m17"
--,sum("MV_US_DATAMART"."TICKET_CHARGES") as "m18"
--, sum("MV_US_DATAMART"."VENDOR_CHARGE") as "m19"
from "OS_OWNER"."MV_US_DATAMART" "MV_US_DATAMART"
where I uncomment a column at a time and rerun. I improved the TimesTen results since my first post, by retyping the NUMBER columns to BINARY_FLOAT. The results I got were:
No Columns ORACLE TimesTen
1 1.05 0.94
2 1.07 1.47
3 2.04 1.8
4 2.06 2.08
5 2.09 2.4
6 3.01 2.67
7 4.02 3.06
8 4.03 3.37
9 4.04 3.62
10 4.06 4.02
11 4.08 4.31
12 4.09 4.61
13 5.01 4.76
14 5.02 5.06
15 5.04 5.25
16 5.05 5.48
17 5.08 5.84
18 6 6.21
19 6.02 6.34
20 6.04 6.75 -
Store SQL Query in Oracle database
Hello,
I am storing SQL query in database. here is an example of query.
INSERT INTO TABLE_1 Values (' " + getValue1() + " ', ' " + getValue2() + " ' )
getValue1() and getValue2() are functions to retrieve values.
When I read query from the database and execute it, it doesn't read values from function.
After I read query from database I would expect it to be
INSERT INTO TABLE_1 Values ('value1', ' value2' ) but it is not reading values and trying to execute whatever I got from database.
Any help?
ThanksThanks for your reply. Let me give you more info.
All I am trying to do is storing queries in oracle
database to use it in future for reporting. As I am
doing reporting where clause will be different every
time. Reporting involves queries not updates. But in any case that means that you would use a java SQL string that is useable via a prepared statement. As such your statement would look like....
INSERT INTO TABLE_1 Values (?,?)
Is it not possible to substitute variable string I
got from database?What do you mean?
SQL is SQL. You construct SQL so it is valid and runs. Can you construct SQL so it runs a function/select and uses that value in some more SQL - depends on the database, but usually.
But that has nothing to do with java - it is SQL.
Query contains variables that I have in Java code .Then it is SQL. It is java. You use bind variables (see PreparedStatement) and assign values to it.
The SQL for such a query would look like the following...
select field1, field2 from table1 where id=?
In your java you would then use something like PreparedStatement.setInt(1, 100), to fill in the value for the '?' in the above.
You might also note that your solution will not work for any arbritrary SQL statement unless you are also storing meta data about the SQL itself. For instance the following SQL statements would return the same result set but your java code would have to populate the bind variables different for both...
select field1, field2 from table1 where id=? and name=?
select field1, field2 from table1 where name=? and id=? -
Variable database name in SQL Server query using Oracle database link
Hi All,
I have an ApEx 4.1 app running on 11g x64 (11.2.0.1) on Windows Server 2008 x64, and I have some data integration points with a SQL Server (2005 and 2008) that I need to establish. I have configured the database link with dg4odbc and it works beautifully... I can execute queries against the SQL Server database without any problems using the database link.
However, there is a scenario where the SQL Server database name is dynamic, and I need to generate it on the fly in a PL/SQL block, and then use that in a dynamic SQL query (all of this in ApEx). This is where I run into problems... when I am querying the default database based on the ODBC connection and I don't have to specify the database name, there is no issue. But when I need to access one of several other non-default databases, I keep receiving the "invalid table" error.
This runs fine:* (note that "fv" is the name of my database link)
v_query1 := 'select "ReleaseDate" from dbo.Schedules@fv where dbo.Schedules."SchedID" = :schedule';
EXECUTE IMMEDIATE v_query1 into rel_date using schedule;
I then take that rel_date variable, convert to a varchar2 (rel_date_char), and then use it as the database name in the next query...
This returns an error_ (Error ORA-00903: invalid table name)
v_query2 := 'select "PARTNO" from :rel_date_char.dbo.ProdDetails@fv where "SchedID" = :schedule and "UnitID" = :unit
and "MasterKey" = :master and "ParentKey" = :parent';
EXECUTE IMMEDIATE v_query2 into part_number using schedule, unit, master, parent;
I have also tried using all of the following to no avail:
'select "PARTNO" from ' || :rel_date_char || '.dbo.ProdDetails@fv where "SchedID"...
'select "PARTNO" from ' || rel_date_char || '.dbo.ProdDetails@fv where "SchedID"...
'select "PARTNO" from ' || @rel_date_char || '.dbo.ProdDetails@fv where "SchedID"...
'select "PARTNO" from @rel_date_char.dbo.ProdDetails@fv where "SchedID"...
Is there a way to do this in PL/SQL?
Thanks for any help!
-Ian C.
Edited by: 946532 on Jul 15, 2012 7:45 PMJust did a test using passthrough:
SQL> set serveroutput on
SQL> declare
2 val varchar2(100);
3 c integer;
4 nr integer;
5 begin
6 c:= dbms_hs_passthrough.open_cursor@FREETDS_DG4ODBC_EMGTW_11_2_0_3;
7 dbms_hs_passthrough.parse@FREETDS_DG4ODBC_EMGTW_11_2_0_3 (c, 'select count(*) from EMP');
8 LOOP
9 nr:= DBMS_Hs_Passthrough.fetch_row@FREETDS_DG4ODBC_EMGTW_11_2_0_3(c);
10 exit when nr=0;
11 dbms_hs_passthrough.get_value@FREETDS_DG4ODBC_EMGTW_11_2_0_3(c,1,val);
12 dbms_output.put_line(val);
13 end loop;
14 dbms_hs_passthrough.close_cursor@FREETDS_DG4ODBC_EMGTW_11_2_0_3(c);
15 end;
16 /
24576
PL/SQL procedure successfully completed.
SQL> declare
2 val varchar2(100);
3 c integer;
4 nr integer;
5 begin
6 c:= dbms_hs_passthrough.open_cursor@FREETDS_DG4ODBC_EMGTW_11_2_0_3;
7 dbms_hs_passthrough.parse@FREETDS_DG4ODBC_EMGTW_11_2_0_3 (c, 'select count(*) from dbo.EMP');
8 LOOP
9 nr:= DBMS_Hs_Passthrough.fetch_row@FREETDS_DG4ODBC_EMGTW_11_2_0_3(c);
10 exit when nr=0;
11 dbms_hs_passthrough.get_value@FREETDS_DG4ODBC_EMGTW_11_2_0_3(c,1,val);
12 dbms_output.put_line(val);
13 end loop;
14 dbms_hs_passthrough.close_cursor@FREETDS_DG4ODBC_EMGTW_11_2_0_3(c);
15 end;
16 /
24576
PL/SQL procedure successfully completed.
So all 3 ways work for me.
Edited by: kgronau on Jul 23, 2012 10:08 AM
Now using variables to perform the select:
SQL> declare
2 val varchar2(100);
3 c integer;
4 nr integer;
5 tabname varchar2(20) :='EMP';
6 ownr varchar2(20) :='dbo';
7 dbname varchar2(20) :='gateway';
8 begin
9 c:= dbms_hs_passthrough.open_cursor@FREETDS_DG4ODBC_EMGTW_11_2_0_3;
10 dbms_hs_passthrough.parse@FREETDS_DG4ODBC_EMGTW_11_2_0_3 (c, 'SELECT count(*) FROM '||dbname||'.'|| ownr || '.'||tabname||'');
11 LOOP
12 nr:= DBMS_Hs_Passthrough.fetch_row@FREETDS_DG4ODBC_EMGTW_11_2_0_3(c);
13 exit when nr=0;
14 dbms_hs_passthrough.get_value@FREETDS_DG4ODBC_EMGTW_11_2_0_3(c,1,val);
15 dbms_output.put_line(val);
16 end loop;
17 dbms_hs_passthrough.close_cursor@FREETDS_DG4ODBC_EMGTW_11_2_0_3(c);
18 end;
19 /
24576
PL/SQL procedure successfully completed.
=> instead of executing the statement using "execute Immediate" we have to use PASTHROUGH package to pass the statement to the SQL Server.
Edited by: kgronau on Jul 23, 2012 10:10 AM -
How an INDEX of a Table got selected when a SELECT query hits the Database
Hi All,
How an Index got selected when a SELECT query hits the Database Table.
My SELECT query is as ahown below.
SELECT ebeln ebelp matnr FROM ekpo
APPENDING TABLE i_ebeln
FOR ALL ENTRIES IN i_mara_01
WHERE werks = p_werks AND
matnr = i_mara_01-matnr AND
bstyp EQ 'F' AND
loekz IN (' ' , 'S') AND
elikz = ' ' AND
ebeln IN s_ebeln AND
pstyp IN ('0' , '3') AND
knttp = ' ' AND
ko_prctr IN r_prctr AND
retpo = ''.
The fields in the INDEX of the Table EKPO should be in the same sequence as in the WHERE clasuse?
Regards,
VijiHi,
You minimize the size of the result set by using the WHERE and HAVING clauses. To increase the efficiency of these clauses, you should formulate them to fit with the database table indexes.
Database Indexes
Indexes speed up data selection from the database. They consist of selected fields of a table, of which a copy is then made in sorted order. If you specify the index fields correctly in a condition in the WHERE or HAVING clause, the system only searches part of the index (index range scan).
The primary index is always created automatically in the R/3 System. It consists of the primary key fields of the database table. This means that for each combination of fields in the index, there is a maximum of one line in the table. This kind of index is also known as UNIQUE. If you cannot use the primary index to determine the result set because, for example, none of the primary index fields occur in the WHERE or HAVING clause, the system searches through the entire table (full table scan). For this case, you can create secondary indexes, which can restrict the number of table entries searched to form the result set.
reference : help.sap.com
thanx. -
Executing SQL query in portal database
Hi ,
I wish to do a simple POC . I need to create a table from NWDS , populate it with some data and then access the table data using an sql query . I am aware how to create a table but I am not sure where exactly to write the query .
What I would like to understand is
1) If I create a table where would that table get created (The database) ?
2) Where would I write that query in NWDS ?
3) How would I execute that query in that database ?
Please help for the same .
(Needless to say that I always award points )
Regards
Deepak SinghHi Gopal ,
Thanks for the reply .This is what I did . I am pasting the whole code of the class that I am using to do the POC .
package com.gravity;
import java.sql.Connection;
import java.sql.Statement;
import java.util.Hashtable;
import javax.naming.InitialContext;
import javax.sql.DataSource;
/*import sun.jdbc.odbc.ee.DataSource;/
@author Administrator
To change the template for this generated type comment go to
Window>Preferences>Java>Code Generation>Code and Comments
public class DataHandling {
public static void DataPost(){
Connection con = null ;
try {
Added code
Hashtable env = new Hashtable();
env.put(javax.naming.Context.INITIAL_CONTEXT_FACTORY, "com.sap.engine.services.jndi.InitialContextFactoryImpl");
System.out.println("initial_context_factory put ");
env.put(javax.naming.Context.PROVIDER_URL, "gms29:50004");
System.out.println("provide_url put ");
env.put(javax.naming.Context.SECURITY_PRINCIPAL, "j2ee_admin");
System.out.println("security_principal put ");
env.put(javax.naming.Context.SECURITY_CREDENTIALS, "gravity");
env.put("domain", "true");
env.put("force_remote", "true");
System.out.println("security_credentials put ");
InitialContext iCtxt = new InitialContext(env);
System.out.println("Object made for initial context ");
DataSource ds = (DataSource) iCtxt.lookup("jdbc/my_db");
System.out.println("Datasource obtained ");
try {
con = ds.getConnection();
Statement stmt = con.createStatement();
String query1 ="insert into EmpData (EMPCODE,EMPNAME) VALUES('naveen',125188)";
String query2 ="insert into EmpData (EMPCODE,EMPNAME) VALUES('deepak',125189)";
String query3 ="insert into EmpData (EMPCODE,EMPNAME) VALUES('rajeev',125190)";
stmt.executeUpdate(query1);
stmt.executeUpdate(query2);
stmt.executeUpdate(query3);
}catch (Exception e) {
e.printStackTrace();
}catch (Exception e) {
e.printStackTrace();
} finally {
try {
con.close();
}catch (Exception e) {
e.printStackTrace();
public static void main (String[] args){
System.out.println("Hello");
DataPost();
I have imported all the driver jar files and sapj2eeclient.jar in the classpath .
Also the drivers found in the path
172.16.161.11\usr\sap\EP1\DVEBMGS00\j2ee\cluster\server0\bin\ext\com.sap.portal.jdbcdrivers
have all been added to the classpath .(Not sure if this is required)
Let me know what you find wrong in my code and in the meanwhile I will try to implement what you suggested .
Regards
Deepak Singh -
The query against the database caused an error in https: site
Hi
I have created a new Data source and External content type in sharePoint 2013
I have also given all the permission to this Content type (including "Users(Windows)")
I also having edit permission in the Sql-database.
I have tied almost all the possibilities given in the net for this error.
still the error("the query against the database caused an error") is there.
Is this because of "https:/ " in the url?
Can any one give a suggestion / solution for this?
Thanks
S H A J A NHi,
Can you please check ULS Log as well as event viewer, to see if there's any related error reported?
Thanks,
Sohel Rana
http://ranaictiu-technicalblog.blogspot.com -
Select query on two Database views
Hi all,
Can i fetch the data by writing a select query on two DATABASE VIEWS
Because i am able to fetch data by writing a selct query on ONE DATABASE VIEW and ON TRANSPARANT TABLE
but i am not able to fetch data by writing a query on TWO DATABASE VIEWS
Query which i am able to fetch data is
select * from CSKS where OBJNR = COVJ-OBJNR
Query which i am NOT able to fetch data is
Select * from COAS where OBJNR = COVJ-OBJNR
Here
COVJ is a DATABASE VIEW
CSKS is a Transparant Table
COAS is a DATABASE VIEW
Thanks in advance
Regards
AjayHi
I tried with code and I am able to fetch data from view COAS
DATA:it_coas TYPE STANDARD TABLE OF coas.
SELECT * FROM coas INTO TABLE it_coas.
IF sy-subrc IS INITIAL.
WRITE:/ 'Sucess'.
ENDIF.
I think in your case COAS view does not have a value for COVJ-OBJNR.
Regards
Srilaxmi -
I want to query sql server database from oracle
i want to query sql server database from oracle
can anyone help me in this regardFirst of all - you are in the wrong forum.
Look either for the Database general or search for Transparant / Heterogenous Gateways.
cu
Andreas -
CFC query union with database query
I'm trying to invoke a webservice to return a query, and then
run a parallel query in another database, and UNION the two with a
query of query. Both the webservice server and the local server are
CF7, both running MySQL, both accessing tables with parallel
structures. The webservice returns what appears to be a normal
query from CFDUMP, but then when I UNION it with the second query,
I get either "Incorrect Select List" or "Columns with index number
equal "1" have diffent types (SMALLINT, JAVA_OBJECT)" errors. So
apparently there's something different about the query from the
webservice that's causing problems?Thanks, this fixed it. I had not realized CF had it's own Q
of Q CAST function. Here's the documentation on it, in case it has
eluded others.
http://livedocs.adobe.com/coldfusion/7/htmldocs/wwhelp/wwhimpl/common/html/wwhelp.htm?cont ext=ColdFusion_Documentation&file=00001271.htm
Adobe: It would be nice if the LiveDoc page for a main tag
like CFQUERY would link to all related pages, like this one above.
Then when looking for information on using a particular tag, it
would be much more likely to find the related page. -
How to query on non database item?
I am working on AP Invoice form. The Invoice Header block based on table ap_invoices_all, I have database items such as invoice_num, invoice_date, and invoice_amount. I also have some non databases item like supplier and supplier number. I added POST_QUERY:
declare
supplier varchar2(240);
supplier_number varchar2(30);
supplier_site varchar2(15);
begin
select aps.vendor_name, aps.segment1
into :invoice_header.supplier, :invoice_header.supplier_number
from ap_suppliers aps
where aps.vendor_id = :invoice_header.vendor_id;
Also in PRE-QUERY
declare
supplier varchar2(240);
supplier_number varchar2(30);
supplier_site varchar2(15);
invoice_num varchar2(50);
invoice_date date;
invoice_amount number;
begin
select aia.invoice_num, aia.invoice_date, aia.invoice_amount
into :invoice_header.invoice_num, :invoice_header.invoice_date, :invoice_header.invoice_amount
from ap_invoices_all aia
where aia.vendor_id = (select vendor_id from ap_suppliers where vendor_name = :invoice_header.supplier);
It's showing fine with Suppier iformation I query by invoices, but I doesn't work when I query by supplier.
Can anyone help? I really appreciate.Hello,
Thanks for your reply. I think I need to clarify my problem
Your cursor has the same result as what I have in the post-query:
Select aps.vendor_name, aps.segment1
into :invoice_header.supplier, :invoice_header.supplier_number
from ap_suppliers aps
where aps.vendor_id = :invoice_header.vendor_id;
and they both work when I query on a database item, such as invoice_num and the non database item vendor name and vendor number will show up. I am doing ok with this.
My problem is when I query on vendor name field which is not a database item, such as CLARK PUBLIC UTILITIES, it will not return CLARK PUBLIC UTILITIES only, instead it returned all the suppliers. Could you please help with this? Thanks a lot. -
Execute query with non database block
How to execute query with non database block when new form instance trigger.
Hi Kame,
Execute_Query not work with non database block. To do this Make a cursor and then assign values to non database block's items programmatically, see following example,
DECLARE
BEGIN
FOR i IN (SELECT col1, col2 FROM Table) LOOP
:block.item1 := i.col1;
:block.item2 := i.col2;
NEXT_RECORD;
END LOOP;
END;
Please mark if it help you or correct
Regards,
Danish -
How to query the citadel database
Is there a way using Lookout to query the citadel data base?
I have value that is being saved every second say, into the citadel database
a specific record may look like this for the field
MON_DS = "7:57"
Local Time = "2/19/06 15:59"
I want to have the user enter a date and then lookout to query the citadel database and find the
maximum value for MON_DS for that date.
Is this possible in lookout?
I can download the data to a spreadsheet but that is alot of work to load each of the fields & local time records
frankHi Frank,
You would use the "c" datamembers (see below), of the right datatype:
SQLExec Data Members
Data Member
Type
Read
Write
Description
c1 – c65535
numeric
yes
no
Value of the nth column in the row returned by ODBC.
c1.logical – c65535.logical
logical
yes
no
Value of the nth column in the row returned by ODBC.
c1.txt – c65535.txt
text
yes
no
Value of the nth column in the row returned by ODBC.
-Khalid -
Date query in non database block
Hi Experts
I am doing query in a database via a non data base block.The field in which i want to query is join(DD-MON-YYYY hh24:MI:SS) and my non database block is join.
I want that i shall give the date in the join field like DD-MON-YYYY format and the related datafrom the database will come out.
So In the KEY-EXEQRY i have written
IF :system.mode = 'ENTER-QUERY' THEN
IF :EMP.JOIN_DATE is not null then
TRUNC(:EMP.JOIN_DATE):=to_date(:EMP.JOIN,'DD-MON-YYYY');
END IF;
END IF;
EXECUTE_QUERY;
It is showing compilation error.
The construct is not allowed as the origin of an assignment
Can you please tell me what is wrong with it.
detail of join is -
data type -char
Regards
RajatTo restrict a query to something based on a non-database-block you need a different approach:
1. Do nothing in the KEX-EXEQRY-trigger
2. Create a PRE-QUERY-trigger with the following logic:
IF :CTRL.JOIN_DATE is not null then
SET_BLOCK_PROPERTY('EMP', ONETIME_WHERE, 'TRUNC(JOIN_DATE)=TRUNC(:CTRL.JOIN_DATE)');
END IF;I assumed the following:
- CTRL is the name of your non-database-block and EMP is your database-block
- There is an item JOIN_DATE of datatype DATE in your CTRL-block
- There is a database-column named JOIN_DATE in yourt EMP-table.
- You are using Forms 10g, if not use DEFAULT_WHERE instead of ONETIME_WHERE
If one of these is not TRUE, adjust the code i provided to match your object-names. -
Pagination resubmits the query to the database.
I have a standard report fed by a dynamic query to retrive the data based on the parameter passed. All parameters reside on one page and the report it self is on a new page. When user clicks a go button the report is submitted with a dynamic query based on the user input parameters. The report some times takes a minute or two to capture the result set and display and depending on the number of rows fetched spans multiple Paginations. We recently noticed that every time the next x row arrow is clicked the page is resubmitted and the query to the database is resubmitted and this is a bad experience to the user to wait another minute for the page to return next x rows. Please help resolve this issue.
Hi User XY,
this is the standard APEX behaviour, every time you want a new subset (get next/previous page) the query is executed again.
You can:
- read all rows at once
- tune your datamodel and/or query to get faster response
- prepare the data in an APEX Collection (e.g. with APEX_COLLECTION.CREATE_COLLECTION_FROM_QUERY*) and let your report read from the collection
brgds,
Peter
Blog: http://www.oracle-and-apex.com
ApexLib: http://apexlib.oracleapex.info
BuilderPlugin: http://builderplugin.oracleapex.info
Work: http://www.click-click.at
Maybe you are looking for
-
I am using PP 2014 CC and it and or Encoder keep crashing.. using iMac computer with Yosemite OS anyone have any ideas about this issue?
-
Outgoing Checks, clearing account
FI experts, Can anyone advice what is the best way to configure BRS, All I need to do is debit the clearing account and credit the cash account, and update encashment field after I download the clear checks report from the bank daily. I do not need t
-
I have Photoshop CS2 and I am trying to "fix" a photo. I'm using a tutorial,and it worked on a previous photo but seems to have quit on me. I made a new layer from the original layer, used filter> other> high pass (set to 3.5) then image> adjustments
-
[solved] Conflicting files while trying to install Eclipse
Hi, I tried to install Eclipse but all I got was an output like this : [xxxxx@arch ~]$ sudo pacman -S eclipse [sudo] password for xxxxx: resolving dependencies... looking for inter-conflicts... Packages (17): aspell-0.60.6.1-2 ca-certificates-java-20
-
Standard smartforms for SD-Notification, Service order, Rental agreement
Hello all, Could anyone let me know if any standard SMARTFORMS available for Notification - SD Service order - SD Rental Agreements - SD Reminder for order confirmation - MM Goods issue - MM Physical inventory slips - MM Spare part labels - MM Is the