How to pass XDIM_MEMBERSET scope to SQL?
Hi all.
I need to run a script, based on the entries that were just entered by users, from a BPC Input Schedule.
Basically, I need to call an SQL script from default logic. (SQL 2008 R2), BPC 7.5 SP7.
However, I need to also be able to pass the scope outlined by XDIM_MEMBERSET in the default logic.
I have tried using the information from both
How to Pass Data Manager Selections(Scope) to Stored Procedure - SAP BPC MS
and
SAP BPC MS: Passing Data Manager Selection (Scope) to SSIS Package
but both of those only appear to work from user prompts (selection box), whereas I need something that works whenever a user hits SEND on an input schedule.
Can anyone give me any pointers?
The closest I can get so far is that there seems to be both a %SELECTION% and a %TOSELECTION% variable that appear to contain what I need, but I now need some way to send that scope to either a variable or a temporary table in SQL.
Thanks
Craig
Hi Craig,
don't use the document of Vadim if you are on MS version, script has different in NW version also in the behaviour so you can have some problem.
Don't use *XDIM_MEMBERSET in default logic, this routine will be execute on every send data and you will force some scope also when the data has another scope.
You can use *XDIM_FILTER and after *RUN_STORED_PROCEDURE=<your stor proc>('%CATEGORY_SET%', etc.) to run this stored procedure only in if the dimension(s) is specified in the filter.
e.g.
*XDIM_FILTER ENTITY=[ENTITY].[h1]properties("IDCODE")="XXXX"
*XDIM_FILTER CATEGORY=[CATEGORY].[H1].properties("IDCODE")="ACTUAL"
*RUN_STORED_PROCEDURE=mySTPR([APPSET], '%TIME_SET%', [%SCOPETABLE%], [%LOGTABLE%]) (this is just an example don't know your parameter of the s.p.)
Regards
Roberto
Similar Messages
-
How to Passing clob to PL/SQL pipeline function
I have a PL/SQL stored function which takes clob as input parameter and sends the results in a pipe line.
create or replace function GetIds(p_list clob, p_del varchar2 := ',') return ideset_t pipelined is
I am using ojdbc14.jar (Oracle 10g driver) with oracle 9i (9.2.0.1.0).
I want to use the following SQL Query select * from table(GetIds(clob))
Now the question is how can I pass the clob from JDBC?
Here is my client code
PreparedStatement stmt = con.prepareStatement("SELECT COLUMN_VALUE FROM TABLE(GETIDS(?, ','))");
stmt.setCharacterStream(1, new StringReader(str), str.length());
stmt.executeQuery();
I get the following error when I try to run the program. The same thing works fine if the chracter lenght is less than some chaaracters.
java.sql.SQLException: ORA-01460: unimplemented or unreasonable conversion requested
at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:125)
at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:305)
at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:272)
at oracle.jdbc.driver.T4C8Oall.receive(T4C8Oall.java:623)
at oracle.jdbc.driver.T4CPreparedStatement.doOall8(T4CPreparedStatement.java:181)
at oracle.jdbc.driver.T4CPreparedStatement.execute_for_describe(T4CPreparedStatement.java:420)
at oracle.jdbc.driver.OracleStatement.execute_maybe_describe(OracleStatement.java:896)
at oracle.jdbc.driver.T4CPreparedStatement.execute_maybe_describe(T4CPreparedStatement.java:452)
at oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout(OracleStatement.java:986)
at oracle.jdbc.driver.OraclePreparedStatement.executeInternal(OraclePreparedStatement.java:2888)
at oracle.jdbc.driver.OraclePreparedStatement.executeUpdate(OraclePreparedStatement.java:2960)
at Test.main(Test.java:42)
Exception in thread "main"
The setChracterStream works for any insert/update clob. Example when I tried the query (INSERT INTO CLOB_TEST VALUES(?)) setCharacterStream just works fine.
Please any one can help me how to solve this.
Thanks in advance.Hóla LuÃs,
when you pick the PL/SQL function body returning a boolean, it implicitly means that TRUE means OK, while FALSE means error, always.
In order to associate such error to a given form field, you have to go back to the page definiton / validations and specify the name of the item in the corresponding field.
When you first create the validation rule, this value is not present even if you ask for the error message inline with the field.
The error message text can be specified in the validation definition, if I am not wrong.
When you need to return special error messages, including dynamic content for instance, you can use the Function Returning Error Message type, which reports an error when the string returned by the function is not null. This comes in handy when you want to display an item's code, for example, rather than generic text.
Even in this case, you must go back to the validation and specify the name of the field if you want to see it inline.
Hope it helps,
Flavio -
How to pass ouput from PL/SQL to perl script
Hi !
I have a PL/SQL package which returns REF CURSOR. How can I pass this ref cursor to perl script?
can any one help me in this matter, pl? it is very very urgent.
Thanks
..mvpThanks for the help but I can't use DBI, we sre using SQLPLUS. So if u can give me any examples on it.
Thanks
..mvp -
How to pass ksh $1 to sql plus and pl/sql
Hi,
How do I pass a ksh $1 to pl/sql code? Is it through sqlplus bind variables? Please give examples. Thank you.in your shell script you can do:
sqlplus user/password@connect_str @myscript $1And in the sql script, for example:
Select '&1' from dual;Max
[My Italian Oracle blog|http://oracleitalia.wordpress.com] -
How to pass parameter to pl/sql block
Hi,
I am getting following error when trying to create staging table from shell script by passing parameter.
SQL*Loader-941: Error during describe of table T1_1DAY_STG
ORA-04043: object T1_1DAY_STG does not existThis is PL/SQL block being called inside shell script
begin
execute immediate 'create table t1_&1._stg as select * from t1_rpt_tmt';
endShell Script Call
load_data_to_oracle()
for i in 1DAY 7DAY 15DAY
do
${ORACLE_HOME}/bin/sqlplus ${ORACLE_USER}/${ORACLE_PASSWD}@${ORACLE_SID} << EOF > ${TMP_LOG_FILE} 2>&1
set serveroutput on
@${CREATE_STAGE_SQL} "$i"
COMMIT;
QUIT;
EOF
########Main#######
load_data_to_oraclethanks
sandyi dont understand why you want run it from shell script. you can write procedure like this :
SQL>
SQL> CREATE OR REPLACE PROCEDURE mytestProc(p_in VARCHAR2) AS
2 begin
3 FOR i IN (select REGEXP_SUBSTR(p_in,'[^,]+',1,ROWNUM) tblName
4 from dual
5 CONNECT BY INSTR(p_in, ',', 1, level - 1) > 0)
6 LOOP
7 execute immediate 'create table t1_'||i.tblname||'_stg as select * from myt2';
8 END LOOP;
9 end;
10 /
Procedure createdand run it
SQL> exec mytestProc('1day,7day,15day');
PL/SQL procedure successfully completed
SQL> select * from t1_15day_stg
2 union all
3 select * from t1_1day_stg
4 union all
5 select * from t1_7day_stg;
T N
SQL>
SQL> drop table t1_15day_stg;
Table dropped
SQL> drop table t1_1day_stg;
Table dropped
SQL> drop table t1_7day_stg;
Table dropped
SQL> purge table t1_15day_stg;
Done
SQL> purge table t1_1day_stg;
Done
SQL> purge table t1_7day_stg;
Done
SQL> -
How to pass a result of SQL query to shell script variable
Hi all,
I am trying to pass the result of a simple SQL query that only returns a single row into the shell script variable ( This particular SQL is being executed from inside the same shell script).
I want to use this value of the variable again in the same shell scirpt by opening another SQL plus session.
I just want to have some values before hand so that I dont have to do multiple joins in the actual SQL to process data.Here an example :
SQL> select empno,ename,deptno from emp;
EMPNO ENAME DEPTNO
7369 SMITH 20
7499 ALLEN 30
7521 WARD 30
7566 JONES 20
7654 MARTIN 30
7698 BLAKE 30
7782 CLARK 10
7788 SCOTT 20
7839 KING 10
7844 TURNER 30
7876 ADAMS 20
7900 JAMES 30
7902 FORD 20
7934 MILLER 10
14 rows selected.
SQL> select * from dept;
DEPTNO DNAME LOC
10 ACCOUNTING NEW YORK
20 RESEARCH DALLAS
30 SALES CHICAGO
40 OPERATIONS BOSTON
SQL> exit
Disconnected from Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production
With the Partitioning, OLAP and Data Mining options
$ cat my_shell.sh
### First query #####
ENAME_DEPTNO=`sqlplus -s scott/tiger << EOF
set pages 0
select ename,deptno from emp where empno=$1;
exit
EOF`
ENAME=`echo $ENAME_DEPTNO | awk '{print $1}'`
DEPTNO=`echo $ENAME_DEPTNO | awk '{print $2}'`
echo "Ename = "$ENAME
echo "Dept = "$DEPTNO
### Second query #####
DNAME_LOC=`sqlplus -s scott/tiger << EOF
set pages 0
select dname,loc from dept where deptno=$DEPTNO;
exit
EOF`
DNAME=`echo $DNAME_LOC | awk '{print $1}'`
LOC=`echo $DNAME_LOC | awk '{print $2}'`
echo "Dept Name = "$DNAME
echo "Dept Location = "$LOC
$ ./my_shell.sh 7902
Ename = FORD
Dept = 20
Dept Name = RESEARCH
Dept Location = DALLAS
$ -
How to pass variable into lov sql query using like operator
hi.
i want to use a lov where i want to pass a variable using like operator.
my query is
select empno,name from table where empno like ':ed%';
my empno is A001 TO A199 AND B001 TO B199 so i want show either A% or B% empno
how can i do this ?
reagrdskindly press Shift+F1 at a time you face this error to see the exact Oracle error message.
and provide us with that detail
and its better if you start new topic for that error... because that will be new error,,,
-- Aamir Arif
Edited by: Aamiz on Apr 7, 2010 12:27 PM -
How to pass datetype parameter in Sql Select Statements to
public void Mountain()
String dat=lastcollecteddatestr.substring(0,2);
String mon=lastcollecteddatestr.substring(3,5);
String yr=lastcollecteddatestr.substring(6,10);
try
SimpleDateFormat sdf = new SimpleDateFormat("yyyy"+"MM"+"dd");
java.util.Date utilDate = new java.util.Date(Integer.parseInt(yr)-1900,Integer.parseInt(mon),Integer.parseInt(dat));
Date newdate=sdf.parse(yr+"-"+mon+"-"+dat);
System.out.println(newdate);
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection con = DriverManager.getConnection(url);
Statement stat = con.createStatement();
ResultSet rs=stat.executeQuery("select empcd,date from mmm where date = '"+newdate+"' ");
while(rs.next())
String str1= new String(rs.getString("empcd"));
String str2= new String(rs.getString("date"));
System.out.println(str1+"\t"+str2);
}catch(Exception ex){System.out.println(ex);}
Error : [MicroSoft] [ODBC Visual FoxPro Driver]Operator/operand type mismatch.
myNote: There is no Problem with connecting to database of something like that
its working well with Different SQL Statment
like: ("select empcd,date from mmm where empcd = '"+empcdstr+"' ")
This is not Working and giving errors
like: ("select empcd,date from mmm where date = '"+newdate+"' ")
HOW TO SOLVE THIS PLZ HELP. It's Urgent.You will see this error if the search condition was entered with an invalid or missing relational operator.
You need to include a valid relational operator such as
=, !=, ^=, <>, >, <, >=, <=, ALL, ANY, [NOT] BETWEEN, EXISTS, [NOT] IN, IS [NOT] NULL, or [NOT] LIKE in the condition. in the sql statement.
Can you throw some more light on how are you designing your project? -
How to pass two parameters to sql query
I try to create a sql script to update two columns in one table. I want to set it as parameter. When people execute this sql script, they need to pass parameter into sql query, then query will be executed successfully. The problem is I am only able to pass one parameter. If set two parameters in one line code, it will get ORA-00933 errors. Please advice me where I was wrong. The code is simple and like this:
update MY_TABLE set year = &year AND month = &month where application_type = 'xxxx';
If I only have: update MY_TABLE set year = &year where application_type = 'xxxx'; It works. If I set two parameters to pass value. It will get error.Hi,
When you UPDATE two or more columns in the same statement, use ',' instead of 'AND' to separate them:
update MY_TABLE
set year = &year
, month = &month
where application_type = 'xxxx';The correct syntax for all SQL statements, including UPDATE, can be found in the [SQL Language manual|http://download.oracle.com/docs/cd/B28359_01/server.111/b28286/statements_10008.htm#sthref9598]. -
How to pass parameters to a SQL query or Data template
Hi,
The requirement is that my final report will take 'date' as input from the user and print only those records which have date later than the user-supplied 'date'. ('Date' is a field in the database).
I know the way to achieve this is to use user-defined parameters.
I have read the user guide, and have created user parameters. From the user guide: "The Report Editor allows you to define your query, define
the parameters that you want users to pass to the query,..."
However there is no example given. (I could not find).
Any guidance?Are you using Enterprise Server environment ? If so, you can find a sample report in the Shared Folders under HR Manager - Employee Salary Report. Please revert if you still have confusion.
-
How to pass value by using SQL*PLUS
Dear all,
I have a file (e.g. test.sql) and run in SQL*PLUS. The code like the following:
set serveroutput on
variable v_a number;
variable v_b number;
variable v_x number;
:v_x := 12345;
execute packagename.procedure(:v_x, :v_a, :v_b);
print v_a;
print v_b;
Why it does not work??
Thanks for any advice.
Regrads.Test it:
set ver off;
set serveroutput on
variable v_a number;
variable v_b number;
variable v_x number;
accept v_a prompt 'Input value for v_a: '
accept v_b prompt 'Input value for v_b: '
accept v_x prompt 'Input value for v_x: '
begin
:v_a := &v_a;
:v_b := &v_b;
:v_x := &v_x;
end;
print v_a;
print v_b;
print v_x; -
How to pass a structure in PL/SQL external proc.
This is for educational purpose only. I am trying to implement kernel32.dll and shell32.dll in PL/SQL using external proc. Everything is working fine, except When there is a structure in OUT parameter.
My database version.
SQL> SELECT * FROM v$version;
BANNER
Oracle Database 10g Enterprise Edition Release 10.2.0.3.0 - Prod
PL/SQL Release 10.2.0.3.0 - Production
CORE 10.2.0.3.0 Production
TNS for 32-bit Windows: Version 10.2.0.3.0 - Production
NLSRTL Version 10.2.0.3.0 - ProductionI have set up the listner.ora and tnsnames.ora and written a package called dbms_kernel32sb.
There are 9 program units.
1. CreateFile -- working fine
2. CloseFile -- working fine
3. GetSize -- working fine
4. FindFirstFile -- NOT working, because one OUT parameter has the structure type WIN32_FIND_DATA.
5. GetFileTime -- NOT working, because one OUT parameter has the structure type FILETIME
6. GetDiskFreeSpace -- working fine
7. GetDriveType -- working fine.
8. GetLastError -- working fine
9. ExecuteCommand -- working fine.
Here is the package specification:
CREATE OR REPLACE PACKAGE dbms_kernel32sb AS
Name: dbms_kernel32sb.pks
Author: Saubhik Banerjee
Date: 24th Jan 2011
Version: 1.0
Comment: This package is to implement some functionality from kernel32.dll.
Usng extproc
OPEN_EXISTING_FILE CONSTANT PLS_INTEGER :=3;
FILE_ATTRIBUTE_NORMAL CONSTANT PLS_INTEGER :=128;
DISABLE_FILE_SHARE_MODE CONSTANT PLS_INTEGER :=0;
NO_FILE_SECURITY_ATTRIBUTE CONSTANT PLS_INTEGER :=0;
NO_TEMPLATE_FILE CONSTANT PLS_INTEGER :=0;
GENERIC_FILE_ACCESS CONSTANT PLS_INTEGER :=0;
FILE_SIZE_HIGH CONSTANT PLS_INTEGER :=400000000;
EXECUTE_FILE CONSTANT VARCHAR2(4):='open';
PRINT_FILE CONSTANT VARCHAR2(5):='print';
NO_PARAMATER CONSTANT VARCHAR2(2):=' ';
FUNCTION CreateFile(pi_FileName VARCHAR2 --1, File name
,pi_DesiredAccess BINARY_INTEGER --2, Type of access required (read/write ect)
,pi_ShareMode BINARY_INTEGER --3, share mode
,pi_SecurityAttributes BINARY_INTEGER --4, securoty attribute
,pi_CreationDisposition BINARY_INTEGER --5, open existing, create new etc
,pi_FlagsAndAttributes BINARY_INTEGER --6, File attribute- normal
,pi_TemplateFile BINARY_INTEGER) --Not required.
Return BINARY_INTEGER;
FUNCTION CloseFile (pi_FileHandle BINARY_INTEGER)
Return BINARY_INTEGER;
FUNCTION GetSize (pi_FileHandle BINARY_INTEGER,
pio_FileSizeHigh IN OUT BINARY_INTEGER)
RETURN BINARY_INTEGER;
FUNCTION FindFirstFile ( pi_FileName VARCHAR2
,pio_Win32_Find_data OUT
WIN32_FIND_DATA
RETURN BINARY_INTEGER;
FUNCTION GetFileTime ( pi_FileHandle BINARY_INTEGER
,pio_FileCreationTime IN OUT FILETIME
,pio_LastAccessTime IN OUT FILETIME
,pio_LastWriteTime IN OUT FILETIME
RETURN BINARY_INTEGER;
FUNCTION GetDiskFreeSpace ( pi_RootPathName VARCHAR2
,pio_SectorsPerCluster OUT BINARY_INTEGER
,pio_BytesPerSector OUT BINARY_INTEGER
,pio_NumberOfFreeClusters OUT BINARY_INTEGER
,pio_TotalNumberOfClusters OUT BINARY_INTEGER
RETURN BINARY_INTEGER;
FUNCTION GetDriveType( pi_driveLetter VARCHAR2) RETURN VARCHAR2;
FUNCTION GetLastError RETURN BINARY_INTEGER;
FUNCTION ExecuteCommand ( pi_OperationType VARCHAR2
,pi_FileName VARCHAR2
,pi_Parameters VARCHAR2
,pi_DefaultDirectory VARCHAR2
RETURN VARCHAR2;
END dbms_kernel32sb;
Here is the package body:
CREATE OR REPLACE PACKAGE BODY dbms_kernel32sb AS
/* Name: dbms_kernel32sb.pkb
Author: Saubhik Banerjee
Date: 24th Jan 2011
Version: 1.0
Comment: This package is to implement some functionality from kernel32.dll.
Usng extproc
FUNCTION
CreateFile( pi_FileName VARCHAR2 --1
, pi_DesiredAccess BINARY_INTEGER --2
, pi_ShareMode BINARY_INTEGER --3
, pi_SecurityAttributes BINARY_INTEGER --4
, pi_CreationDisposition BINARY_INTEGER --5
, pi_FlagsAndAttributes BINARY_INTEGER --6
, pi_TemplateFile BINARY_INTEGER) --7
Return BINARY_INTEGER IS EXTERNAL LIBRARY kernel32 Name "CreateFileA"
PARAMETERS( pi_FileName STRING
, pi_DesiredAccess long
, pi_ShareMode long
, pi_SecurityAttributes long
, pi_CreationDisposition long
, pi_FlagsAndAttributes long
, pi_TemplateFile long
, return long);
FUNCTION CloseFile (pi_FileHandle BINARY_INTEGER)
Return BINARY_INTEGER
IS EXTERNAL
LIBRARY kernel32 Name "CloseHandle"
PARAMETERS (pi_FileHandle long, return long);
FUNCTION GetSize (pi_FileHandle BINARY_INTEGER,
pio_FileSizeHigh IN OUT BINARY_INTEGER)
RETURN BINARY_INTEGER
IS EXTERNAL
LIBRARY kernel32 NAME "GetFileSize"
PARAMETERS (pi_FileHandle long, pio_FileSizeHigh long, return long );
FUNCTION GetFileTime ( pi_FileHandle BINARY_INTEGER
,pio_FileCreationTime IN OUT FILETIME
,pio_LastAccessTime IN OUT FILETIME
,pio_LastWriteTime IN OUT FILETIME
RETURN BINARY_INTEGER
IS EXTERNAL
LIBRARY kernel32 NAME "GetFileTime"
WITH CONTEXT
PARAMETERS ( CONTEXT,
pi_FileHandle long
, pio_FileCreationTime OCIColl
, pio_FileCreationTime INDICATOR SHORT
, pio_LastAccessTime OCIColl
, pio_LastAccessTime INDICATOR SHORT
, pio_LastWriteTime OCIColl
, pio_LastWriteTime INDICATOR SHORT
, return long );
FUNCTION FindFirstFile ( pi_FileName VARCHAR2
,pio_Win32_Find_data OUT
WIN32_FIND_DATA
RETURN BINARY_INTEGER
IS EXTERNAL
LIBRARY kernel32 NAME "FindFirstFileA"
--WITH CONTEXT
PARAMETERS
( --CONTEXT,
pi_FileName STRING--, pi_FileName INDICATOR SHORT
, pio_Win32_Find_data BY REFERENCE OCIColl--,pio_Win32_Find_data INDICATOR long
, return long );
FUNCTION GetDiskFreeSpace ( pi_RootPathName VARCHAR2
,pio_SectorsPerCluster OUT BINARY_INTEGER
,pio_BytesPerSector OUT BINARY_INTEGER
,pio_NumberOfFreeClusters OUT BINARY_INTEGER
,pio_TotalNumberOfClusters OUT BINARY_INTEGER
RETURN BINARY_INTEGER
IS EXTERNAL
LIBRARY kernel32 NAME "GetDiskFreeSpaceA"
PARAMETERS ( pi_RootPathName STRING
, pio_SectorsPerCluster BY REFERENCE long
, pio_BytesPerSector BY REFERENCE long
, pio_NumberOfFreeClusters BY REFERENCE long
, pio_TotalNumberOfClusters BY REFERENCE long
, return long );
FUNCTION GetDriveTypeA( pi_driveLetter VARCHAR2) RETURN BINARY_INTEGER
IS EXTERNAL
LIBRARY kernel32 NAME "GetDriveTypeA"
PARAMETERS (pi_driveLetter STRING, RETURN long);
FUNCTION GetDriveType( pi_driveLetter VARCHAR2) RETURN VARCHAR2 IS
BEGIN
CASE GetDriveTypeA(pi_driveLetter)
WHEN 2 THEN RETURN 'Removable';
WHEN 3 THEN RETURN 'Drive Fixed';
WHEN 4 THEN RETURN 'Remote';
WHEN 5 THEN RETURN 'Cd-Rom';
WHEN 6 THEN RETURN 'Ram disk';
ELSE RETURN 'Unrecognized';
END CASE;
END;
FUNCTION GetLastError RETURN BINARY_INTEGER
IS EXTERNAL
LIBRARY kernel32 NAME "GetLastError"
PARAMETERS (return long);
FUNCTION ShellExecute( pi_Hwnd BINARY_INTEGER
,pi_Operation VARCHAR2
,pi_FileName VARCHAR2
,pi_Parameters VARCHAR2
,pi_DefaultDirectory VARCHAR2
,pi_ShowCmd BINARY_INTEGER
) RETURN BINARY_INTEGER
IS EXTERNAL
LIBRARY SHELL32 NAME "ShellExecuteA"
PARAMETERS (pi_Hwnd long,pi_Operation STRING,pi_FileName STRING
,pi_Parameters STRING,pi_DefaultDirectory STRING
,pi_ShowCmd long, return long
FUNCTION ExecuteCommand ( pi_OperationType VARCHAR2
,pi_FileName VARCHAR2
,pi_Parameters VARCHAR2
,pi_DefaultDirectory VARCHAR2
RETURN VARCHAR2 IS
v_return_val BINARY_INTEGER;
BEGIN
v_return_val:= ShellExecute(0,pi_OperationType
,pi_FileName,pi_Parameters
,pi_DefaultDirectory,0
IF v_return_val <=32 THEN
RETURN 'Error!';
ELSE RETURN 'Success!';
END IF;
END;
END dbms_kernel32sb;
Now the working demos:
SQL> SET SERVEROUT ON
SQL> /* Demo I:- How to obtain file size */
SQL> DECLARE
2 v_FileSize BINARY_INTEGER;
3 v_FileSizeHigh PLS_INTEGER;
4 v_FileHandle BINARY_INTEGER;
5 v_filename VARCHAR2(500) :='C:\test2.csv';
6 v_dummy BINARY_INTEGER;
7 BEGIN
8 v_FileSizeHigh := DBMS_KERNEL32SB.FILE_SIZE_HIGH;
9 v_FileHandle:=DBMS_KERNEL32SB.CreateFile(v_filename -- File name
10 ,DBMS_KERNEL32SB.GENERIC_FILE_ACCESS
11 ,DBMS_KERNEL32SB.DISABLE_FILE_SHARE_MODE
12 ,DBMS_KERNEL32SB.NO_FILE_SECURITY_ATTRIBUT
13 ,DBMS_KERNEL32SB.OPEN_EXISTING_FILE
14 ,DBMS_KERNEL32SB.FILE_ATTRIBUTE_NORMAL
15 ,DBMS_KERNEL32SB.NO_TEMPLATE_FILE);
16 v_FileSize := DBMS_KERNEL32SB.Getsize(v_FileHandle, v_FileSizeHigh)
17 DBMS_OUTPUT.put_line('File Size in Bytes: ' ||v_FileSize);
18 v_dummy:=DBMS_KERNEL32SB.CloseFile(v_FileHandle);
19 END;
20 /
File Size in Bytes: 61
PL/SQL procedure successfully completed.
SQL>
SQL> /* Demo II:- How to find free disk space */
SQL> DECLARE
2 v_rootpath VARCHAR2(500) :='C:\';
3 v_dummy BINARY_INTEGER;
4 v_sectorspercluster BINARY_INTEGER;
5 v_bytespersector BINARY_INTEGER;
6 v_numberoffreeclusters BINARY_INTEGER;
7 v_totalnumberofclusters BINARY_INTEGER;
8 v_freespace NUMBER;
9 v_totalspace NUMBER;
10 BEGIN
11 v_dummy:=DBMS_KERNEL32SB.GetDiskFreeSpace(v_rootpath
12 ,v_sectorspercluster
13 ,v_bytespersector
14 ,v_numberoffreeclusters
15 ,v_totalnumberofclusters
16 );
17
18 DBMS_OUTPUT.put_line('Sector pre Cluster: ' ||v_sectorspercluster);
19 DBMS_OUTPUT.put_line('Bytes per sector: ' ||v_bytespersector);
20 DBMS_OUTPUT.put_line('Number Of Free Clusters: ' ||v_numberoffreeclusters);
21 DBMS_OUTPUT.put_line('Total Number Of Clusters: ' ||v_totalnumberofclusters);
22 v_freespace:=v_numberoffreeclusters/1024/1024/1024;
23 v_freespace:=ROUND(v_freespace*v_sectorspercluster*v_bytespersector,3);
24 v_totalspace:=v_totalnumberofclusters/1024/1024/1024;
25 v_totalspace:=ROUND(v_totalspace*v_sectorspercluster*v_bytespersector,3);
26 DBMS_OUTPUT.put_line('Total Space (GB):' ||v_totalspace);
27 DBMS_OUTPUT.put_line('Total number of Free space (GB): '||v_freespace );
28 END;
29 /
Sector pre Cluster: 8
Bytes per sector: 512
Number Of Free Clusters: 739477
Total Number Of Clusters: 9765622
Total Space (GB):37.253
Total number of Free space (GB): 2.821
PL/SQL procedure successfully completed.
SQL>
SQL> /* Demo IV:- How to get drive type*/
SQL> SELECT dbms_kernel32sb.GetDriveType('C:\') FROM dual;
DBMS_KERNEL32SB.GETDRIVETYPE('C:\')
Drive Fixed
SQL> SELECT dbms_kernel32sb.GetDriveType('D:\') FROM dual;
DBMS_KERNEL32SB.GETDRIVETYPE('D:\')
Cd-Rom
SQL> SELECT dbms_kernel32sb.GetDriveType('E:\') FROM dual;
DBMS_KERNEL32SB.GETDRIVETYPE('E:\')
Unrecognized
SQL>
SQL> /* Demo V:- How to execute an Operating System Command*/
SQL> DECLARE
2 v_FileToExecute VARCHAR2(20):='test.bat';
3 v_Parameter VARCHAR2(20):='test1.csv';--dbms_kernel32sb.NO_PARAMATER
4 v_DefaultDirectory VARCHAR2(20):='C:\';
5 v_ReturnValue VARCHAR2(20);
6 BEGIN
7 v_ReturnValue:=dbms_kernel32sb.ExecuteCommand(dbms_kernel32sb.EXECUTE_FILE
8 ,v_FileToExecute
9 ,v_Parameter
10 ,v_DefaultDirectory
11 );
12 DBMS_OUTPUT.put_line('Status: '||v_ReturnValue);
13 END;
14 /
Status: Success!
PL/SQL procedure successfully completed.
SQL> Now the sub programs with structures are NOT getting called successfully.
SQL> /* Demo III:- How to obtain file time */
SQL> DECLARE
2 v_FileHandle BINARY_INTEGER;
3 v_filename VARCHAR2(500) :='C:\test2.csv';
4 v_dummy BINARY_INTEGER;
5 v_filecreationtime FILETIME;
6 v_lastaccesstime FILETIME;
7 v_lastwritetime FILETIME;
8 v_err BINARY_INTEGER;
9 BEGIN
10 v_FileHandle:=DBMS_KERNEL32SB.CreateFile(v_filename -- File name
11 ,DBMS_KERNEL32SB.GENERIC_FILE_ACCESS
12 ,DBMS_KERNEL32SB.DISABLE_FILE_SHARE_MODE
13 ,DBMS_KERNEL32SB.NO_FILE_SECURITY_ATTRIBUTE
14 ,DBMS_KERNEL32SB.OPEN_EXISTING_FILE
15 ,DBMS_KERNEL32SB.FILE_ATTRIBUTE_NORMAL
16 ,DBMS_KERNEL32SB.NO_TEMPLATE_FILE);
17 v_dummy := DBMS_KERNEL32SB.GetFileTime( v_FileHandle
18 ,v_filecreationtime
19 ,v_lastaccesstime
20 ,v_lastwritetime
21 );
22 v_err:=DBMS_KERNEL32SB.GetLastError;
23 DBMS_OUTPUT.put_line('File Size in Bytes: ' ||v_dummy);
24 DBMS_OUTPUT.put_line('Error:'||v_err);
25 v_dummy:=DBMS_KERNEL32SB.CloseFile(v_FileHandle);
26 END;
27 /
File Size in Bytes: 0
Error:203
PL/SQL procedure successfully completed.
SQL> So, I have noticed that, Where ever a STRUCTURE is involved in external routine, there is a problem. I want to know, How to implement functions with STRUCTURE as OUT parameter.
Forgot to mention: This is my FILETIME object which corresponds to FILETIME structure of win32.
CREATE OR REPLACE TYPE FILETIME_rec IS OBJECT
( LowDateTime NUMBER
,HighDateTime NUMBER
CREATE OR REPLACE TYPE FILETIME IS TABLE OF FILETIME_rec;Edited by: Saubhik on Feb 1, 2011 4:15 PMSaubhik wrote:
This is for educational purpose only. I am trying to implement kernel32.dll and shell32.dll in PL/SQL using external proc. Interesting. Familiar with the Wn32 API, but do not run Oracle on Windows and never looked at this aspect of integration.
So, I have noticed that, Where ever a STRUCTURE is involved in external routine, there is a problem. I want to know, How to implement functions with STRUCTURE as OUT parameter.
Forgot to mention: This is my FILETIME object which corresponds to FILETIME structure of win32.The problem is that this passes the parameter by reference and not value. In a vanilla C/C++/Delphi program, you will create a variable of that struct and then pass a long pointer to that variable when making the API call. That pointer will be dereferenced and the memory it points to, populated. This is not a problem as the underlying DLL you call that does this, uses your process's data segment.
Extproc is different. In order to protect the integrity of the database server process, an external call is done by a "proxy" process. It acts as the interface between your PL/SQL code and the actual external call.
In this case, this "proxy" process will be doing the implicit LoadLibrary() call to load kernel32.dll interface - and the DLL will expect to dereference and access this process's memory struct to populate it. This "proxy" process in turn needs to know that despite it calling the interface by reference, it needs to return that parameter to PL/SQL by value - as your PL/SQL code cannot dereference a pointer passed back by that "proxy" process and access its memory to gain access to that struct.
In basic terms - that argument is a 32 bit number containing a pointer. That is what the "proxy" process needs to pass to the interface call. Your code is passing a struct and not a pointer, right?
And that is the basic problem I believe. How to address this.. not sure. You can have your own DLL as interface that does not use pointers but expect arguments to be passed by value. But this will suck as you then need to include a custom DLL to deploy and have PL/SQL call that, instead of simply accessing and calling the native kernel interface.
Doubt that many Win32 programmers with OCI (Oracle Call Interface) frequents this forum. So perhaps this is not the best place to ask. I would be hitting Metalink (support.oracle.com) search function in your sho3s though as there should be support notes dealing with this subject matter. -
I am having trouble with passing dynamic string to sql query for executing SSRS reports.
I am using oracle database and I want to pass where clause parameter as "where LAND_NR = 6" to my select query.
For example: I want to execute Select * from employee :p_where.
where p_where parameter holds value "where LAND_NR = 6"
So it will treat as "Select * from employee where LAND_NR = 6" statement which will give me the list of records to display in my reports.
But it's not taking correct sql command throwing an error as "SQLcommand not properly ended."
How can I achieve this?You need to use dynamic sql
But please keep in mind that since you're using Oracle you may be better off posting this in some Oracle forums
This forum is specifically for SQL Server
Please Mark This As Answer if it helps to solve the issue Visakh ---------------------------- http://visakhm.blogspot.com/ https://www.facebook.com/VmBlogs -
How to pass 100+ tags in a single sql/tag query
<b>In my current application I have to pass 180+ tags in a single query to retrieve data from iHistorian.
I want to know how to pass more thatn 100 tags in a single SQL or TAG Query using OLEDB or UDC connectors.
If anybody has done it in the past ,please share with me and also let me know how to do it</b>Currently you can only query a maximum of 128 tags, this is a hard limit and may be changed in future releases of xMII, but < 11.5 (im fairly sure 12 also) all have the limit of 128.
As for iHistorian with the OLEDB UDS, you can write a query that would return over 128 queries becasue this is an input limitation on the UDSs. (PLEASE DON"T ASK US HOW TO WRITE iHistorian QUERIES... we aren't experts in iHistorian).
Please note that though you can query over 128 tags, the performance may not be what you expect... This may take a very long time to return.
Martin -
How to pass values to XML complex type of a Webservice using PL/SQL
HI,
I need to call a web service from PL/SQL that has an complex type element. That complex type element has 4 child elements each of integer type.
I want to pass values for this complex type using SOAP_API.add_parameter but I can't understand how to pass the values.
<xsd:element name="getBestFit">
<xsd:complexType>
<xsd:sequence>
<xsd:element maxOccurs="1" minOccurs="1" name="circleId" type="xsd:string"/>
<xsd:element maxOccurs="1" minOccurs="1" name="usage" type="Q1:UsageInfoType"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
<complexType name="UsageInfoType">
<sequence>
<element maxOccurs="1" minOccurs="1" name="a1" type="int"/>
<element maxOccurs="1" minOccurs="1" name="a2" type="int"/>
<element maxOccurs="1" minOccurs="1" name="a3" type="int"/>
<element maxOccurs="1" minOccurs="1" name="a4" type="int"/>
</sequence>
</complexType>
Please help me in getting a solution here.
Thanks in advance.Have you tried doing a google search on "SOAP_API.add_parameter" to see what comes back? I see a lot of hits come back so hopefully one of those will help you. I've never used soap_api as I used utl_http to make WS calls. This required me to build the SOAP message (aka XML of a specific nature) by hand and then pass it to the WS using utl_http. How this approach is done via SOAP_API, I can't say.
Maybe you are looking for
-
Copy of service plan item SPLA in contracts not working
Hi, 1. I have created a service plan product SP (item category group SPLA) 2. I copied the standard trans SC -> ZSC and item category SPLA -> ZSPL 3. I then maintained the determination as per the standard. I have not changed any of the attributes of
-
SNP planned order deleted in APO, but not in R/3.
OK Guru's, We have a situation where during the weekend SNP planning runs, SNP Planned orders are deleted in APO, but the order is never deleted in R/3. The change pointer is not in CPP and there are no failed queues. Also, when you run CCR on plan
-
Finder crashes when I attach an external HD
Hi, since updating to 10.5.2 the Finder disappears whenever I attach my external HD (Time Machine HD)and the HD is not mounted. Relaunching the finder does not help. The finder just tries to start, the light below comes on for a second or so and then
-
My iPod touch 5gen sees the wifi but does not accept the password
My iPod touch does not accept the password for my home wifi but can connect to other wifi like Best Buy's.
-
Upgrading from Elements 2.0 to 11.0
I am in the process of upgrading from Elements 2.0 to Elements 11.0 AND setting up a new computer. How do I make sure I don't lose any of my photos and in which order should I do this? Do I need to install 2.0 on new computer? thanks!