Using IN and TABLE operators via JDBC
Greetings,
Hope this may be of benefit to someone.
Any and all feedback greatly appreciated.
import java.math.BigDecimal;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import javax.sql.DataSource;
import oracle.sql.ARRAY;
import oracle.sql.ArrayDescriptor;
import oracle.jdbc.pool.OracleDataSource;
* Tests an SQL query that uses the IN operator and the TABLE keyword.
* The TABLE keyword transforms a PL/SQL collection into a regular table.
* Hence a query can use the IN operator with a PL/SQL collection.
* A PL/SQL collection maps to a java array.
* Hence you can execute a query using a <code>PreparedStatement</code> and an
* array as the parameter value.
* Note, however, that the PL/SQL collection type <em>must</em> be a database
* named type, one that is defined using the CREATE TYPE [DDL] statement.
public class SqlQuery {
public static void main(String[] args) {
Connection c = null;
Object[] oa = new Object[3];
oa[0] = new BigDecimal("9712061");
oa[1] = new BigDecimal("9712062");
oa[2] = new BigDecimal("9712063");
PreparedStatement ps = null;
ResultSet rs = null;
String sql = "select ENAME " +
"from EMP " +
"where EMPNO in (" +
"select * " +
"from table(?)" +
String url = "jdbc:oracle:thin:scott/tiger@//localhost:1521/orcl";
try {
OracleDataSource ods = new OracleDataSource();
ods.setURL(url);
c = ods.getConnection();
ArrayDescriptor ad = ArrayDescriptor.createDescriptor(
"<nested table type name>",
c);
ARRAY a = new ARRAY(ad, c, (Object) oa);
ps = c.prepareStatement(sql);
ps.setArray(1, a);
rs = ps.executeQuery();
while (rs.next()) {
System.out.println(rs.getString(1));
catch (Exception x) {
x.printStackTrace();
finally {
if (rs != null) {
try {
rs.close();
catch (Exception x) {
System.err.println("Failed to close result set.");
x.printStackTrace();
if (ps != null) {
try {
ps.close();
catch (Exception x) {
System.err.println("Failed to close statement.");
x.printStackTrace();
if (c != null) {
try {
c.close();
catch (Exception x) {
System.err.println("Failed to close database connection.");
x.printStackTrace();
}Good Luck,
Avi.
Thanks a lot for your replies!
We've solved the issue by converting the de table of record type into a sys_refcursor.
The types are now defined globally (instead of in a package) and we wrote a wrapper around the original function:
create or replace type my_result_rec as object(
val1 number,
val2 number );
create or replace type my_result_tab is table of my_result_rec;
function my_function_wrapper(
param1 in number,
param2 in number
) return sys_refcursor is
result sys_refcursor;
begin
open result for
select * from table(my_function(param1,param2));
return result;
end;
Rob
Similar Messages
-
How to display table data without using ALV and table element.
Hi,
Its possible to display table data without using ALV and table element.
Every time i am fetching data based on (customer,status) fields and displaying these data in my output using alv
(every time i am fetching single row data ),
But problem is alv occupying more space in the output , i want to display data part only i dont want field names,
settings and header data etc..things.
Give solution to display data part..
Regards,
Rakhi.Hi,
Does you mean that you need ALV without default Function Toolbar...? If this is the case, the easy solution would have been to use Table Element rather. But, if you need to use ALV only without Function Toolbar, you can do away with that as well.
In that case, after calling GET_MODEL, you need to add few more lines of codes to achieve your goal. Those lines are --
DATA LV_VALUE TYPE REF TO CL_SALV_WD_CONFIG_TABLE.
LV_VALUE = LO_INTERFACECONTROLLER->GET_MODEL(
* Standard Filter Function setting to FALSE
LV_VALUE->IF_SALV_WD_STD_FUNCTIONS~SET_SORT_COMPLEX_ALLOWED( ABAP_FALSE ).
LV_VALUE->IF_SALV_WD_STD_FUNCTIONS~SET_FILTER_COMPLEX_ALLOWED( ABAP_FALSE ).
LV_VALUE->IF_SALV_WD_STD_FUNCTIONS~SET_FILTER_FILTERLINE_ALLOWED( ABAP_FALSE ).
LV_VALUE->IF_SALV_WD_STD_FUNCTIONS~SET_DISPLAY_SETTINGS_ALLOWED( ABAP_FALSE ).
LV_VALUE->IF_SALV_WD_STD_FUNCTIONS~SET_VIEW_LIST_ALLOWED( ABAP_FALSE ).
LV_VALUE->IF_SALV_WD_STD_FUNCTIONS~SET_SORT_HEADERCLICK_ALLOWED( ABAP_FALSE ).
LV_VALUE->IF_SALV_WD_STD_FUNCTIONS~SET_HIERARCHY_ALLOWED( ABAP_FALSE ).
* Standard Filter Function setting to FALSE Ends
Here as you can easily notice that LV_VALUE is instantiated on CL_SALV_WD_CONFIG_TABLE. Now, using this LV_VALUE, you set standard functions as False to dis-allow their display.
Hope this answers your query.
Thanks.
Kumar Saurav. -
Hello,
we have a java-program, that accesses data via jdbc to a mysql-database.
Now we want to migrate the mysql-table to abap-table.
How can we access from the java-program to theese migrated abap-tables via jdbc?
Regards OliverOliver,
If you want to access those tables from SAP, then you have to use the Java Connectors (
JCO).
Please write the more details abount the java IDE and OS, which you are using I will send you appropriate help.
Thanks -
Reg Using , Changing and Tables
hi all,
I am using select-options for matnr.
i am using an internal table with matnr, mbrsh , mtart fields .
i want to use subroutine with using matnr and changing it_mara.
So in the FORM and ENDFORM block how to declare the variables in the FORM stmt.
If i use LIKE its working. but i want to use TYPE stmt. Please help in solving the problem. If possible please provide any small example
Sample code is as follows:
perform get_data using s_matnr
changing it_mara.
FORM get_data USING P_S_MATNR type XXXXXXXXX
CHANGING P_IT_MARA type XXXXXXXX
select .....from mara into p_it_mara where matnr in p_s_matnr.
ENDFORM.
<REMOVED BY MODERATOR>
Thanks in advance.
Thanks and Regards.
Edited by: Alvaro Tejada Galindo on Apr 21, 2008 3:06 PMNO need for using parameter in your case. as you are using select options simply use changing parameters alone.
perform get_data changing it_mara.
FORM get_data CHANGING P_IT_MARA type XXXXXXXX
select .....from mara into p_it_mara where matnr in s_matnr.
ENDFORM. -
SAP BI 4.0 SP2 on Linux and Postgresql Datasource via JDBC drivers
Hi,
I installed SAP BI Platform 4.0 SP2 on Redhat 5.2 and i try to access as a universe datasource a postgresql database (v8.4). But i don't know how to configure the postgresql JDBC driver on linux server.
does anyone have a step by step procedure to configure this JDBC postgresql driver on linux ?
I download this driver : http://jdbc.postgresql.org/download/postgresql-8.4-703.jdbc3.jar
I read the SAP Data Access document for SAP BI 4.0 SP2 about JDBC connexions, they talk about a SBO file located in $ROOT_DIR/sap_bobj/enterprise_xi40/dataAccess/connectionServer/jdbc , but there isn't any SBO file for postgresql database ?
Thanks in advance
JP
Edited by: Jean-Philippe ARNALOT on Oct 6, 2011 6:58 PMHi
I found a solution alone, this note 1347514 helps me :
My conf : Redhat 5.2 + SAP BI 4.0 SP2 + postgresql 8.4 datasource + jdbc drivers
My solution :
1) Download JDBC drivers on client side (http://jdbc.postgresql.org/download/postgresql-8.4-703.jdbc3.jar)
2) Create and export a JDBC connexion for postgresql8
3) Create and export a universe using this connexion (test a query in universe design tool tools/Querybuilder)
4) install JDBC drivers on server side, i copied the jar file in this location : $ROOT_DIR/sap_bobj/enterprise_xi40/dataAccess/connectionServer/drivers/java/postgresql-8.4-703.jdbc3.jar
5) Set your classpath in your .profile : CLASSPATH=$CLASSPATH:/export/logiciels/tes-boxi/sap_bobj/enterprise_xi40/dataAccess/connectionServer/drivers/java/postgresql-8.4-703.jdbc3.jar; export CLASSPATH
6) Source your .profile
7) Restart servers (i think restarting only webi server would be ok)
8) Open BI LaunchPad, start Webi and execute a query on postgresql universe
It Works with my configuration
Thanks for your help
JP -
ROLLUP AND CUBE OPERATORS IN ORACLE 8I
제품 : PL/SQL
작성날짜 : 2000-06-29
========================================
ROLLUP AND CUBE OPERATORS IN ORACLE 8I
========================================
PURPOSE
ROLLUP 과 CUBE Operator에 대해 설명하고자 한다.
Explanation
ROLLUP operator는 SELECT문의 GROUP BY절에 사용된다.
SELECT절에 ROLLUP 을 사용함으로써 'regular rows'(보통의 select된 data)와
'super-aggregate rows'(총계)을 구할 수 있다. 기존에는 select ... union select
를 이용해 구사해야 했었던 것이다. 'super-aggregate rows'는 'sub-total'
(중간 Total, 즉 소계)을 포함한다.
CUBE operator는 Cross-tab에 대한 Summary를 추출하는데 사용된다. 모든 가능한
dimension에 대한 total을 나타낸다. 즉 ROLLUP에 의해 나타내어지는 item total값과
column total값을 나타낸다.
NULL값은 모든 값에 대한 super-aggregate 을 나타낸다. GROUPING() function은
모든 값에 대한 set을 나타내는 null값과 column의 null값과 구별하는데 쓰여진다.
GROUPING() function은 GROUP BY절에서 반드시 표현되어야 한다. GROUPING()은 모든
값의 set을 표현합에 있어서 null이면 1을 아니면 0을 return한다.
ROLLUP과 CUBE는 CREATE MATERIALIZED VIEW에서 사용되어 질수 있다.
Example
아래와 같이 테스트에 쓰여질 table과 data을 만든다.
create table test_roll
(YEAR NUMBER(4),
REGION CHAR(7),
DEPT CHAR(2),
PROFIT NUMBER );
insert into test_roll values (1995 ,'West' , 'A1' , 100);
insert into test_roll values (1995 ,'West' , 'A2' , 100);
insert into test_roll values (1996 ,'West' , 'A1' , 100);
insert into test_roll values (1996 ,'West' , 'A2' , 100);
insert into test_roll values (1995 ,'Central' ,'A1' , 100);
insert into test_roll values (1995 ,'East' , 'A1' , 100);
insert into test_roll values (1995 ,'East' , 'A2' , 100);
SQL> select * from test_roll;
YEAR REGION DE PROFIT
1995 West A1 100
1995 West A2 100
1996 West A1 100
1996 West A2 100
1995 Central A1 100
1995 East A1 100
1995 East A2 100
7 rows selected.
예제 1: ROLLUP
SQL> select year, region, sum(profit), count(*)
from test_roll
group by rollup(year, region);
YEAR REGION SUM(PROFIT) COUNT(*)
1995 Central 100 1
1995 East 200 2
1995 West 200 2
1995 500 5
1996 West 200 2
1996 200 2
700 7
7 rows selected.
위의 내용을 tabular로 나타내어 보면 쉽게 알 수 있다.
Year Central(A1+A2) East(A1+A2) West(A1+A2)
1995 (100+NULL) (100+100) (100+100) 500
1996 (NULL+NULL) (NULL+NULL) (100+100) 200
700
예제 2: ROLLUP and GROUPING()
SQL> select year, region, sum(profit),
grouping(year) "Y", grouping(region) "R"
from test_roll
group by rollup (year, region);
YEAR REGION SUM(PROFIT) Y R
1995 Central 100 0 0
1995 East 200 0 0
1995 West 200 0 0
1995 500 0 1
1996 West 200 0 0
1996 200 0 1
700 1 1
7 rows selected.
참고) null값이 모든 값의 set에 대한 표현으로 나타내어지면 GROUPING function은
super-aggregate row에 대해 1을 return한다.
예제 3: CUBE
SQL> select year, region, sum(profit), count(*)
from test_roll
group by cube(year, region);
YEAR REGION SUM(PROFIT) COUNT(*)
1995 Central 100 1
1995 East 200 2
1995 West 200 2
1995 500 5
1996 West 200 2
1996 200 2
Central 100 1
East 200 2
West 400 4
700 7
위의 내용을 tabular로 나타내어 보면 쉽게 알 수 있다.
Year Central(A1+A2) East(A1+A2) West(A1+A2)
1995 (100+NULL) (100+100) (100+100) 500
1996 (NULL+NULL) (NULL+NULL) (100+100) 200
100 200 400 700
예제 4: CUBE and GROUPING()
SQL> select year, region, sum(profit),
grouping(year) "Y", grouping(region) "R"
from test_roll
group by cube (year, region);
YEAR REGION SUM(PROFIT) Y R
1995 Central 100 0 0
1995 East 200 0 0
1995 West 200 0 0
1995 500 0 1
1996 West 200 0 0
1996 200 0 1
Central 100 1 0
East 200 1 0
West 400 1 0
700 1 1
10 rows selected.
===============================================
HOW TO USE ROLLUP AND CUBE OPERATORS IN PL/SQL
===============================================
Release 8.1.5 PL/SQL에서는 CUBE, ROLLUP 이 지원되지 않는다. 8i에서는 DBMS_SQL
package을 이용하여 dynamic SQL로 구현하는 방법이 workaround로 제시된다.
Ordacle8i에서는 PL/SQL block에 SQL절을 직접적으로 위치시키는 Native Dynamic SQL
(참고 bul#11721)을 지원한다.
Native Dynamic SQL을 사용하기 위해서는 COMPATIBLE 이 8.1.0 또는 그 보다 높아야
한다.
SVRMGR> show parameter compatible
NAME TYPE VALUE
compatible string 8.1.0
예제 1-1: ROLLUP -> 위의 예제 1과 비교한다.
SQL> create or replace procedure test_rollup as
my_year test_roll.year%type;
my_region test_roll.region%type;
my_sum int;
my_count int;
begin
select year, region, sum(profit), count(*)
into my_year, my_region, my_sum, my_count
from test_roll
group by rollup(year, region);
end;
Warning: Procedure created with compilation errors.
SQL> show errors
Errors for PROCEDURE TEST_ROLLUP:
LINE/COL ERROR
10/8 PL/SQL: SQL Statement ignored
13/18 PLS-00201: identifier 'ROLLUP' must be declared
SQL> create or replace procedure test_rollup as
type curTyp is ref cursor;
sql_stmt varchar2(200);
tab_cv curTyp;
my_year test_roll.year%type;
my_region test_roll.region%type;
my_sum int;
my_count int;
begin
sql_stmt := 'select year, region, sum(profit), count(*) ' ||
'from test_roll ' ||
'group by rollup(year, region)';
open tab_cv for sql_stmt;
loop
fetch tab_cv into my_year, my_region, my_sum, my_count;
exit when tab_cv%NOTFOUND;
dbms_output.put_line (my_year || ' '||
nvl(my_region,' ') ||
' ' || my_sum || ' ' || my_count);
end loop;
close tab_cv;
end;
SQL> set serveroutput on
SQL> exec test_rollup
1995 Central 100 1
1995 East 200 2
1995 West 200 2
1995 500 5
1996 West 200 2
1996 200 2
700 7
PL/SQL procedure successfully completed.
예제 2-1: ROLLUP and GROUPING() -> 위의 예제 2와 비교한다.
SQL> create or replace procedure test_rollupg as
my_year test_roll.year%type;
my_region test_roll.region%type;
my_sum int;
my_count int;
my_g_region int;
my_g_year int;
begin
select year, region, sum(profit),
grouping(year), grouping(region)
into my_year, my_region, my_sum, my_count,
my_g_year, my_g_region
from test_roll
group by rollup(year, region);
end;
Warning: Procedure created with compilation errors.
SQL> show error
Errors for PROCEDURE TEST_ROLLUPG:
LINE/COL ERROR
12/4 PL/SQL: SQL Statement ignored
17/13 PLS-00201: identifier 'ROLLUP' must be declared
SQL> create or replace procedure test_rollupg as
type curTyp is ref cursor;
sql_stmt varchar2(200);
tab_cv curTyp;
my_year test_roll.year%type;
my_region test_roll.region%type;
my_sum int;
my_count int;
my_g_region int;
my_g_year int;
begin
sql_stmt := 'select year, region, sum(profit), count(*), ' ||
'grouping(year), grouping(region) ' ||
'from test_roll ' ||
'group by rollup(year, region)';
open tab_cv for sql_stmt;
loop
fetch tab_cv into my_year, my_region, my_sum, my_count,
my_g_year, my_g_region;
exit when tab_cv%NOTFOUND;
dbms_output.put_line (my_year || ' '||my_region ||
' ' || my_sum || ' ' || my_count ||
' ' || my_g_year || ' ' || my_g_region);
end loop;
close tab_cv;
end;
Procedure created.
SQL> set serveroutput on
SQL> exec test_rollupg
1995 Central 100 1 0 0
1995 East 200 2 0 0
1995 West 200 2 0 0
1995 500 5 0 1
1996 West 200 2 0 0
1996 200 2 0 1
700 7 1 1
PL/SQL procedure successfully completed.
예제 3-1: CUBE -> 위의 예제 3과 비교한다.
SQL> create or replace procedure test_cube as
my_year test_roll.year%type;
my_region test_roll.region%type;
my_sum int;
my_count int;
begin
select year, region, sum(profit), count(*)
into my_year, my_region, my_sum, my_count
from test_roll
group by cube(year, region);
end;
Warning: Procedure created with compilation errors.
SQL> show error
Errors for PROCEDURE TEST_CUBE:
LINE/COL ERROR
10/4 PL/SQL: SQL Statement ignored
13/13 PLS-00201: identifier 'CUBE' must be declared
SQL> create or replace procedure test_cube as
type curTyp is ref cursor;
sql_stmt varchar2(200);
tab_cv curTyp;
my_year test_roll.year%type;
my_region test_roll.region%type;
my_sum int;
my_count int;
begin
sql_stmt := 'select year, region, sum(profit), count(*) ' ||
'from test_roll ' ||
'group by cube(year, region)';
open tab_cv for sql_stmt;
loop
fetch tab_cv into my_year, my_region, my_sum, my_count;
exit when tab_cv%NOTFOUND;
dbms_output.put_line (my_year || ' '||
nvl(my_region,' ') ||
' ' || my_sum || ' ' || my_count);
end loop;
close tab_cv;
end;
Procedure created.
SQL> set serveroutput on
SQL> exec test_cube
1995 Central 100 1
1995 East 200 2
1995 West 200 2
1995 500 5
1996 West 200 2
1996 200 2
Central 100 1
East 200 2
West 400 4
700 7
PL/SQL procedure successfully completed.
예제 4-1: CUBE and GROUPING() -> 위의 예제 4와 비교한다.
SQL> create or replace procedure test_cubeg as
my_year test_roll.year%type;
my_region test_roll.region%type;
my_sum int;
my_count int;
my_g_region int;
my_g_year int;
begin
select year, region, sum(profit),
grouping(year), grouping(region)
into my_year, my_region, my_sum, my_count,
my_g_year, my_g_region
from test_roll
group by cube(year, region);
end;
Warning: Procedure created with compilation errors.
SQL> show error
Errors for PROCEDURE TEST_CUBEG:
LINE/COL ERROR
12/4 PL/SQL: SQL Statement ignored
17/13 PLS-00201: identifier 'CUBE' must be declared
SQL> create or replace procedure test_cubeg as
type curTyp is ref cursor;
sql_stmt varchar2(200);
tab_cv curTyp;
my_year test_roll.year%type;
my_region test_roll.region%type;
my_sum int;
my_count int;
my_g_region int;
my_g_year int;
begin
sql_stmt := 'select year, region, sum(profit), count(*), ' ||
'grouping(year), grouping(region) ' ||
'from test_roll ' ||
'group by cube(year, region)';
open tab_cv for sql_stmt;
loop
fetch tab_cv into my_year, my_region, my_sum, my_count,
my_g_year, my_g_region;
exit when tab_cv%NOTFOUND;
dbms_output.put_line (my_year || ' '||my_region ||
' ' || my_sum || ' ' || my_count ||
' ' || my_g_year || ' ' || my_g_region);
end loop;
close tab_cv;
end;
Procedure created.
SQL> set serveroutput on
SQL> exec test_cubeg
1995 Central 100 1 0 0
1995 East 200 2 0 0
1995 West 200 2 0 0
1995 500 5 0 1
1996 West 200 2 0 0
1996 200 2 0 1
Central 100 1 1 0
East 200 2 1 0
West 400 4 1 0
700 7 1 1
PL/SQL procedure successfully completed.
Reference Ducumment
Note:67988.1Hello,
As previously posted you should use export and import utilities.
To execute exp or imp statements you have just to open a command line interface, for instance,
a DOS box on Windows.
So you don't have to use SQL*Plus or TOAD.
About export/import you may care on the mode, to export a single or a list of Tables the Table mode
is enough.
Please, find here an example to begin:
http://wiki.oracle.com/page/Oracle+export+and+import+
Hope this help.
Best regards,
Jean-Valentin -
Problem with Stored Procedure exection in Sender and Receiver side of JDBC
Hi All,
I am facing problem while executing Stored Procedures using sender and receiver sides of JDBC adapter.
Here is my SP in Oracle DB :
PROCEDURE EMP
( ID IN VARCHAR2,NAME IN VARCHAR2,PROCESSED IN VARCHAR2 ) AS
BEGIN
INSERT INTO EMPLOYEE VALUES (ID, NAME, PROCESSED);COMMIT;END EMP;
Now I want to execute this SP using sender JDBC channel and receiver JDBC channel.
Can anyone please help me executing this SP?
Regards,
SooryaHi Soorya,
The receiver Data type should be like this:
<StatementName>
<storedProcedureName action=u201D EXECUTEu201D>
<table>realStoredProcedureeName</table>
<param1 [isInput=u201Dtrueu201D] [isOutput=true] type=SQLDatatype>val1</param1>
</storedProcedureName >
</StatementName>
Check the link http://help.sap.com/saphelp_nw04/helpdata/en/64/ce4e886334ec4ea7c2712e11cc567c/frameset.htm
Which DB are you using?? The sender structure will be like
<resultset>
<row>
<field1></field1>
<field2></field2>
<field3></ field3>
</row>
</resultset>
Search SDN you will get lot of examples
Regards
Suraj -
Dynamic tabstrips and table control in custom infotype
Dear Experts,
I have a requirement to create a custom infotype using tabstrips and table control. The tabstripes should also be dynamically populated. For example we have infty 8(Basic pay) used table control and 24(Qualifications) for tabstripes.
Could you please tell me how to do this. Please do the needful ASAP.
Thanks,
Chaitanya.
Moderator message - Please don't just post your requirements and ask the forum to do your work for you...especially ASAP - Thread locked
Edited by: Rob Burbank on Oct 7, 2009 4:16 PMHi Partha,
Pls check the threads:
Best way to store a table control into an infotype
Re: Custom Infotype with table control - Overview/List Screen
Dilek -
Lost index stats in Ora 8.1.6 Tables when selecting via jdbc
Hi,
i'm using JBuilder8 and Kylix2 on a Linux machine with Oracle oci drivers of client 8.1.7.
The connect through JB8 jdbc via DBPilot is succesful and shows the tables of the db.
After executing a select on any table the index stats of this table are lost.
Kylix works fine without this failure.
Thanks for any comments to this problem
JensWell, it's not the PL/SQL code that is causing a problem. Everything worked fine for many months. Then one day (without any changes in the environment or code) the update of a table from a java application (via JDBC) fails. The same update done directly on the DB with SQL Plus still succeeds!
This led us to think that something is wrong with the JDBC connection (which was up for several months). Maybe a memory corruption?
Anyone that experienced similar problems with JDBC? -
How to upload an html file using jsp and jdbc
Hi,
im trying to upload an html page using JSP and jdbc. but of no success.
my aim is to keep some important html pages in the database.the file size can vary.the file has to be selected from a local machine (through the browser) and uploaded to a remote machine(where the databse resides).
any help/sample code or pointer to any helpful link is appreciated.
thanks in advance
javajar2003When uploading a file, I use a byte array as a temporary buffer..
So, you should then be able to store the byte array in the
database as binary data.
example>
//Temporary Buffer To Store File
byte[] tmpbuffer = new byte[860];
//Some Code To Upload File...
//File Should Now Be In Byte Array
//Get DB Connection and execute Prepared Statement
Connection con=//GET DB CONNECTION;
String sql=insert into TABLE(page) values(?);
PreparedStatement ps=con.prepareStatement(sql);
ps.setBytes(1,tempbuffer);
ps.executeUpdate();
//Close PS and Free DB Connection
..... and this method looks like you dont even have
to store the file in a byte array, you can just give
it the input stream.
ps.setBinaryStream(int, inputStream, int);
You may have to make several attempts at this. I have
uploaded a file and temporarily stored it in a byte array,
but have never from there stored it in the DB as binary
data.. but this looks like it'll work.
Good Luck! -
PowerPivot - Create a Lookup Table and Calculate Totals via PowerQuery
Hi,
I have got a question to powerpivot/powerquery.
I have got one source file "product-sku.txt" with product data (product number, product size, product quantity etc.).
In powerpivot I created via this text file 2 powerpivot tables:
product-sku and
products.
The "products" table is a lookup table and was created via powerquery using the columns prodnumber, removing the prodsize and the prodquantity columns and then removing duplicates.
My question: How could I show/leave a column prodquantity in the lookup table "products" which shows the total of all sizes per prodnumber?
I need this prodquantity in the lookup table to do a banding analysis via the "products" table (e.g. products with quantity 0-100, 101-200 etc.).
I give you an example:
source file columns (product-sku.txt):
Source
Date
ProdNumber
ProdSize
ProdQuantity
ProdGroup
ProdSubGroup
ProdCostPrice
ProdSellingPrice
The powerpivot table "product-sku" contains all columns from the txt file above
The lookup table "products" created via powerquery has the following columns:
Source
Date
ProdNumber
ProdQuantity (this column I would wish to add; if a prodnumber 123 had two sizes (36 and 38) with quantities of 5 and 10, the prodquantity should add up in the lookup table to 15. How could this be achieved?)
I enclose a link to my dropbox with example files: PowerPivot-Example-Files
Thank you for any help.
ChiemoChiemo,
If you would like to consolidate to one table as Olaf has suggested, that would be very easy to do. I have included the modified DAX for the calculated column below. This calculated column would be created in the 'product-sku' table itself.
You are correct in your assumption that you need an explicitly calculated column to most easily do banding analysis.
Olaf is correct that avoiding the creation of a separate 'products' table as you have done is a good idea. I was not thinking about modeling best practices when I replied. If the only purpose of your 'products' table was to create this calculated column,
then I do suggest deleting that table and implementing the calculated column in 'product-sku' with the DAX below.
Edit: If you need to use 'products' as a dimension table which will have a relationship to a fact table, then it will be necessary to keep it. PowerPivot does not natively handle a many-to-many relationship. Dimension tables must have a unique key. If [ProdNumber]
is the key, then it will be necessary to have your 'products' table. If you need to implement a many-to-many relationship, please see this
post as a primer.
=
CALCULATE (
SUM ( 'product-sku'[ProdQuantity] ),
'product-sku'[ProdNumber] = EARLIER ( 'product-sku'[ProdNumber] ) -
JDBC Schema and Table Names Reversed
Hi,
We're currently evaluating CR4E but are unable to successfully run/preview any reports.
We have successfully created a JDBC connection using the generic JDBC driver. We are connecting to an Ingres database. The connection is successful and we can browse databases/schemas/tables with no problem. The problem is with the SQL that the reporting engine is generating.
A simple example:
SELECT "currency"."description" FROM "currency"."john" "currency"
In this statement, "currency" is actually the table and "john" is the schema name.
The query should read:
SELECT "currency"."description" FROM "john"."currency" "currency"
Help would be appreciated as we're completely stuck.
Many thanks,
Darran SmithHi Tej,
Thanks for clarifying the issue on the JRC.
Executing:
SELECT "price_type"."currency", "price_type"."description" FROM "price_type"."john" "price_type"
against the DB results in "Table 'john' does not exist or is not owned by you" as expected.
Executing
SELECT "price_type"."currency", "price_type"."description" FROM "john"."price_type" "price_type"
against the DB works just fine.
I amended my code to simply call:
CRJavaHelper.changeDataSource(reportClientDocument, userName, password, connectString, driverName, JNDIName);
and changed the CRJavaHelper.java file around line 145 that originally reads:
newTable.setQualifiedName (origTable.getAlias ());
I tried setting the qualified name to various different things:
"price_type"
"john.price_type"
"otherSchema.price_type"
None of these worked, but they did produce different things in the JDBC trace log. I've uploaded the JDBC log file to showing what happens with either "price_type" or "john.price_type":
[http://www.romofabrics.com/iijdbc.txt|http://www.romofabrics.com/iijdbc.txt]
As you can see, everything looks OK (including the schema and table name) until the very final select statement is created.
When you say that generic JDBC is supported, is that what I'm effectively using?
Cheers,
Darran -
Accessing and retreiving ResultSets through CORBA via JDBC
Hey,
Im in the middle of doing a project and I was originally planning to connect to the database through JDBC over TCP/IP only. Everything worked fine. Now Ive been told that I have to use CORBA to relay the result sets over from the remote database. ie An applet requests information, queries the CORBA server, the CORBA server via JDBC then queries the database and gets the result set. The result set is sent back via CORBA to the client applet, where the data is then manipulated.
What I want to know is it actually possible to do this? I only know a small amount of CORBA and Ive been crawling the web for even a small example of it. Could anyone help me out. Ive been looking for the past week and you guys are my last hope.
Thanks in advanceHi,
You won't be able to send actual instances of the Java class ResultSet via CORBA. All interfaces and data structures you use must be defined in CORBA IDL. You should be able to find a lot of tutorials about general CORBA, including the ones at the bottom of
http://java.sun.com/j2se/1.4.1/docs/guide/idl/index.html
You should define an interface in CORBA IDL for your server that the client applet will call. Probably you'll have a method which takes the query parameters and returns some sort of data structure that you also define in IDL.
The only problem I really see is whether or not the JVM your browser uses does CORBA very well.
- Everett -
Configuration the connection between portal and srm server only via JDBC
Dear all:
We want to implement the SRM server and present the supplier web/page in the portal server. Our SRM and portal server install in intranet network.
For internal employee use the SRM server and the Supplier access the portal server via Internet, we install Web Dispather in DMZ to exchange the HTTP request.
Network TOP like this :
SRM server--Portal||FireWall||-Web Dispatcher--Supplier
(--Internal|firewall--|DMZ|-Internet )
The question is : Between DMZ zone and our internal network zone ,there is the firewall and it only allows JDBC protocol (SQL statements or result set) to pass. Other protocol and port could not pass this firewall.
So ,it seems that no way to implement this ,right? Or any other way to implement it ?thanks
-
Hi All,
I need to get the "Creation Script" of the existing table using c# and without using SMO dlls (is it possible? I don't know).
I.e. In SQL Management Studio -> right click on any table -> Script table as -> Create To - > open in the new query editor window. This will give you the schema of the table with the constraints of the table.
For E.g. In Northwind database, for the table "Categories", I would like to get it as show below
USE [Northwind]
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[Categories](
[CategoryID] [int] IDENTITY(1,1) NOT NULL,
[CategoryName] [nvarchar](15) NOT NULL,
[Description] [ntext] NULL,
[Picture] [image] NULL,
CONSTRAINT [PK_Categories] PRIMARY KEY CLUSTERED
[CategoryID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]
GO
I would like to get the same schema using c#. Please help.
Thanks & Regards,
Kalai.SMO is the easiest way to get this. This is what Management Studio uses. If you can't use SMO, get a Profiler trace of the queries that SMO executes when generating the script and execute the same using ADO.NET.
Regards,
Farooq Mahmud
Support Escalation Engineer
• Microsoft Health Solutions Group
Maybe you are looking for
-
Error when starting repository browser listener on Oracle Database
I have successfully installed oracle database 11g release2 (11.2.0.2.0). The associated Oracle Warehouse Builder 11g Release 2 (11.2.0.3.0) Standalone Software works fine, everything is ok. Now I want to start Repository Browser. So, I must run the s
-
A question about subclasses of visibility
Hello, I read a book named Learning Java it say "as you override methods in a subclass, the overriding method must be at least as visible as the overridden method.While it is possible to take a private method and override it with a public method in a
-
INSERT in PLSQL loop in Oracle 9i scheduled job has poor performance
Hi, I have a scheduled job running in Oracle 9i. But everytime it executes the following piece of code, the INSERT process slows down drastically. -------------------------------typical piece of code having problem-----------------------------------
-
Hello I have a ix4-400d Nas with 4 HD of 3TB each I would like to change all of then What is the maximum hard disk size this device can manage ? thanks michael Solved! Go to Solution.
-
What's the code of SetCINArraySize and NumericArrayResize? Thanks
Hello, I work with LabView and Visula C++. I do CIN and want to know the code of SetCINArraySize because I have a little problem in operation with matrix. If you have the code of NumericArrayResize too, could you send me please? Thank you in advance.