Setting object attribute in dynamic sql
I am trying to set an object attribute in PL/SQL. It looks like execute immediate is unhappy with
create type test_object as object(username varchar2(200),id number);
declare
obj test_object;
username varchar2(50);
begin
obj := test_object(null,null);
username := 'MIKE';
execute immedaite 'begin :x.username := :y; end;' using obj,username;
end;
Is this supposed to work?
Hi Tony,
Thanks so much for your response. I've had to study up on the dbms_sql package to understand your function... first time I've used it. I've fed my dynamic query to your function and see that it returns a colon delimited list of the column names; however, I think I need a little more schooling on how and where exactly to apply the function to actually set the column names in APEX.
From my test app, here is the code for my dynamic query. I've got it in a "PL/SQL function body returning sql query" region:
DECLARE
v_query VARCHAR2(4000);
v_as VARCHAR2(4);
v_range_from NUMBER;
v_range_to NUMBER;
BEGIN
v_range_from := :P1_FY_FROM;
v_range_to := :P1_FY_TO;
v_query := 'SELECT ';
-- build the dynamic column selections by looping through the fiscal year range.
-- v_as is meant to specify the column name as (FY10, FY11, etc.), but it's not working.
FOR i IN v_range_from.. v_range_to LOOP
v_as := 'FY' || SUBSTR(i, 3, 4);
v_query := v_query || 'MAX(DECODE(FY_NB,' || i || ',PFH_HEADCOUNT,0)) '
|| v_as || ',';
END LOOP;
-- add the rest of the query to the dynamic column selection
v_query := rtrim(v_query,',') || ' FROM ('
|| 'SELECT FY_NB, PFH_HEADCOUNT FROM ('
|| 'SELECT FY_ID, FY_NB FROM FISCAL_YEAR) A '
|| 'LEFT OUTER JOIN ('
|| 'SELECT FY_ID, PFH_HEADCOUNT '
|| 'FROM PROJECT_FY_HEADCOUNT '
|| 'JOIN PROJECT_FY USING (PF_ID) '
|| 'WHERE PL_ID = ' || :P1_PROJECT || ') B '
|| 'ON A.FY_ID = B.FY_ID)';
RETURN v_query;
END;I need to invoke GET_QUERY_COLS(v_query) somewhere to get the column names, but I'm not sure where I need to call it and how to actually set the column names after getting the returned colon-delimited list.
Can you (or anyone else) please help me get a little further? Once again, feel free to login to my host account to see it first hand.
Thanks again!
Mark
Similar Messages
-
Arbitrary object types in PL/SQL call with OCI for Oracle 9.2
Hi,
i'm trying to develop a generic library that is able to execute a call to a pl/sql with a generic list of types.
If the objects are native (i.e. number, varchar2...) works fine, but i cannot understand how to do the same with a generic user defined object.
For example:
CREATE OR REPLACE TYPE A AS object (
B VARCHAR2(40),
C CLOB
CREATE OR REPLACE TYPE D AS object (
E A
And the pl/sql:
CREATE OR REPLACE PACKAGE PLSQL_EX IS
PROCEDURE exempl (inInfo IN OUT D);
END PLSQL_EX ;
Do you have an example of how to do this ??, obviously i dont whant to use the OTT, because i want the maximum level of flexibility. I think i have to use the OCIObjectNew functions and the related ones, but i don't know how.
thanks.
Best regards,
Stefano.Hi,
i'trying to solve the problem with this code (just use of set Object attribute and get object Attribute) , but it doesn't work:
#define SQLCA_NONE
#define ORACA_NONE
EXEC SQL BEGIN DECLARE SECTION;
sql_context sqlCtx;
char* dbName = "dbName";
char* oraPwd;
char* oraConnection;
char* oraUsr;
EXEC SQL END DECLARE SECTION;
#include <iostream.h>
#include <stdlib.h>
#include <string>
#include <sql2oci.h>
extern "C" {
#include <orid.h>
sword checkErr(sword status, OCIError * error)
text errbuf[512];
sb4 errcode = 0;
int errorCode = 0;
string errorDesc;
switch (status) {
case OCI_SUCCESS:
break;
case OCI_SUCCESS_WITH_INFO:
OCIErrorGet((dvoid *)error, (ub4) 1, (text *) 0, &errcode, errbuf, (ub4) sizeof(errbuf), OCI_HTYPE_ERROR);
errorDesc = (char *)errbuf;
cout << "error: " << errorDesc << endl;
break;
case OCI_NEED_DATA:
cout << "warning: NEED DATA"<< endl;
break;
case OCI_NO_DATA:
cout << "warning: NO DATA" << endl;
break;
case OCI_ERROR:
OCIErrorGet((dvoid *)error, (ub4) 1, (text *) 0, &errcode, errbuf, (ub4) sizeof(errbuf), OCI_HTYPE_ERROR);
errorDesc = (char *)errbuf;
cout << "error: " << errorDesc << endl;
break;
case OCI_INVALID_HANDLE:
cout << "error: INVALID HANDLE" << endl;
break;
case OCI_STILL_EXECUTING:
cout << "error: STILL EXECUTING" << endl;
break;
case OCI_CONTINUE:
cout << "error: CONTINUE" << endl;
break;
default:
cout << "error: ???" << endl;
break;
return status;
int main ()
OCIType * tdo;
dvoid * objectPointer;
dvoid * null_struct =(dvoid*) 0;
OCIString * message4AB= (OCIString *)0;
OCIInd ind4AB = OCI_IND_NOTNULL;
ub4 len[] = {1};
const char *attrName[] = {"B"};
dvoid * attr_null_struct =(dvoid* ) 0;
OCIString* newString = (OCIString*) 0;
OCIType * attr_tdo;
OCIInd newIndMessage = OCI_IND_NULL;
OCITypeCode typecode ;
OCIEnv * mEnvHandler;
OCISvcCtx * mSvcEnv;
OCIError * mErrorHandler;
oraUsr = (char*) "gpridb";
oraPwd = (char*) "gpridb";
oraConnection = "ic9su002";
sqlca sqlca;
EXEC SQL CONTEXT ALLOCATE :sqlCtx;
EXEC SQL CONTEXT USE :sqlCtx;
EXEC SQL CONNECT :oraUsr IDENTIFIED BY :oraPwd AT :dbName USING :oraConnection;
if (SQL_ERROR == SQLEnvGet(sqlCtx, &mEnvHandler) ) {
cout << "Error during creation of environment Handler"<< endl;
exit (1);
if (SQL_ERROR == SQLSvcCtxGet(sqlCtx, (text *)dbName, (ub4) strlen(dbName), &mSvcEnv )) {
cout << "Error during creation of svc Environment"<< endl;
exit (1);
if (SQL_ERROR == OCIHandleAlloc( mEnvHandler, (dvoid **) &mErrorHandler, (ub4) OCI_HTYPE_ERROR, 0, (dvoid **) 0)){
cout << "cannot initialize error handler" << endl;
exit (1);
checkErr (OCITypeByName ( mEnvHandler,mErrorHandler,mSvcEnv,(text *) 0,(ub4) 0,
(const text *) "A", (ub4) strlen ("A"),
(const text *)0, (ub4) 0,OCI_DURATION_SESSION,OCI_TYPEGET_ALL, &tdo),mErrorHandler);
checkErr( OCIObjectNew ( mEnvHandler, mErrorHandler, mSvcEnv,OCI_TYPECODE_OBJECT,tdo, (dvoid*)0,
OCI_DURATION_SESSION,true ,&objectPointer),mErrorHandler);
checkErr(OCIObjectGetInd (mEnvHandler, mErrorHandler,
objectPointer, &null_struct ),mErrorHandler);
checkErr(OCIStringAssignText (mEnvHandler,mErrorHandler, (text *) "INVIO",
strlen ("INVIO") ,&message4AB),mErrorHandler);
cout << "Value in string: " << (char *) OCIStringPtr(mEnvHandler, message4AB) << endl;
checkErr(OCIObjectSetAttr (mEnvHandler, mErrorHandler, objectPointer, null_struct,
tdo, (const text **) attrName , len, (ub4) 1,(ub4 *) 0,
(ub4)0, ind4AB, &attr_null_struct,
(dvoid *) message4AB),mErrorHandler);
checkErr (OCIObjectGetAttr(mEnvHandler, mErrorHandler, objectPointer, null_struct, tdo,
(const text **) attrName, len, 1, (ub4 *)0, (ub4)0, &newIndMessage,&attr_null_struct,
(void **) &newString, &attr_tdo),mErrorHandler);
typecode = OCITypeTypeCode(mEnvHandler, mErrorHandler, attr_tdo);
if (newIndMessage == OCI_IND_NULL) {
cout << "null"<< endl;
} else {
cout << "indicator: " << newIndMessage << endl;
switch (typecode)
case OCI_TYPECODE_DATE : /* fixed length string */
cout << "date" << endl;
break;
case OCI_TYPECODE_RAW : /* RAW */
cout << "raw" << endl;
break;
case OCI_TYPECODE_CHAR : /* fixed length string */
case OCI_TYPECODE_VARCHAR : /* varchar */
case OCI_TYPECODE_VARCHAR2 : /* varchar2 */
cout << "vc" << endl;
break;
case OCI_TYPECODE_SIGNED8:
cout << "sign" << endl;
break;
case OCI_TYPECODE_UNSIGNED8:
cout << "uns" << endl;
break;
case OCI_TYPECODE_OCTET:
cout << "octet" << endl;
break;
case OCI_TYPECODE_UNSIGNED16: /* UNSIGNED SHORT */
case OCI_TYPECODE_UNSIGNED32: /* UNSIGNED LONG */
case OCI_TYPECODE_REAL: /* REAL */
case OCI_TYPECODE_DOUBLE: /* DOUBLE */
case OCI_TYPECODE_INTEGER: /* INT */
case OCI_TYPECODE_SIGNED16: /* SHORT */
case OCI_TYPECODE_SIGNED32: /* LONG */
case OCI_TYPECODE_DECIMAL: /* DECIMAL */
case OCI_TYPECODE_FLOAT: /* FLOAT */
case OCI_TYPECODE_NUMBER: /* NUMBER */
cout << "num" << endl;
break;
default:
cout << "defaut" << endl;
break;
char p = (char ) OCIStringPtr(mEnvHandler, newString);
cout << " read from object (" << typecode << "): " << (char *) OCIStringPtr(mEnvHandler, newString) << endl;
the output is:
Value in string: INVIO
indicator: 0
vc
read from object (9): @| -
Score() operator fails in dynamic SQL
When I try to use the score() operater in dynamic SQL statement, I get "ORA-01858: a
non-numeric character was found where a numeric was expected". When the same statement is executed directly (in a cursor or from SQLPlus) it works fine.
I suspect this problem may be related to BUG1343045. This bug describes errors occuring using the score() operator when CURSOR_SHARING=FORCE is set. Perhaps CURSOR_SHARING=FORCE is set automatically when a dynamic SQL statement is issued?
I'd like to get some comments on the problem from an Oracle engineer & work-around possibilities. I would like to use score to order my search results by relevance, and without dynamic SQL, I would have to code 9 or more separate searcg cursors to account for all the possible combinations of search terms in the query!
Thanks,
Kevin RubeshSajjad2 wrote:
explicit grant to the objectsKarthick's idea about roles was my first thought too. since you have explict grants we will have to look elsewhere.
Do you need synonyms to reference objects in another schema? What happens if you prefix the table names with the schema owner? -
How to create a function with dynamic sql or any better way to achieve this?
Hello,
I have created below SQL query which works fine however when scalar function created ,it
throws an error "Only functions and extended stored procedures can be executed from within a
function.". In below code First cursor reads all client database names and second cursor
reads client locations.
DECLARE @clientLocation nvarchar(100),@locationClientPath nvarchar(Max);
DECLARE @ItemID int;
SET @locationClientPath = char(0);
SET @ItemID = 67480;
--building dynamic sql to replace database name at runtime
DECLARE @strSQL nvarchar(Max);
DECLARE @DatabaseName nvarchar(100);
DECLARE @localClientPath nvarchar(MAX) ;
Declare databaselist_cursor Cursor for select [DBName] from [DataBase].[dbo].
[tblOrganization]
OPEN databaselist_cursor
FETCH NEXT FROM databaselist_cursor INTO @DatabaseName
WHILE @@FETCH_STATUS = 0
BEGIN
PRINT 'Processing DATABASE: ' + @DatabaseName;
SET @strSQL = 'DECLARE organizationlist_cursor CURSOR
FOR SELECT '+ @DatabaseName +'.[dbo].[usGetLocationPathByRID]
([LocationRID])
FROM '+ @DatabaseName +'.[dbo].[tblItemLocationDetailOrg] where
ItemId = '+ cast(@ItemID as nvarchar(20)) ;
EXEC sp_executesql @strSQL;
-- Open the cursor
OPEN organizationlist_cursor
SET @localClientPath = '';
-- go through each Location path and return the
FETCH NEXT FROM organizationlist_cursor into @clientLocation
WHILE @@FETCH_STATUS = 0
BEGIN
SELECT @localClientPath = @clientLocation;
SELECT @locationClientPath =
@locationClientPath + @clientLocation + ','
FETCH NEXT FROM organizationlist_cursor INTO
@clientLocation
END
PRINT 'current databse client location'+ @localClientPath;
-- Close the Cursor
CLOSE organizationlist_cursor;
DEALLOCATE organizationlist_cursor;
FETCH NEXT FROM databaselist_cursor INTO @DatabaseName
END
CLOSE databaselist_cursor;
DEALLOCATE databaselist_cursor;
-- Trim the last comma from the string
SELECT @locationClientPath = SUBSTRING(@locationClientPath,1,LEN(@locationClientPath)- 1);
PRINT @locationClientPath;
I would like to create above query in function so that return value would be used in
another query select statement and I am using SQL 2005.
I would like to know if there is a way to make this work as a function or any better way
to achieve this?
Thanks,This very simple: We cannot use dynamic SQL from used-defined functions written in T-SQL. This is because you are not permitted do anything in a UDF that could change the database state (as the UDF may be invoked as part of a query). Since you can
do anything from dynamic SQL, including updates, it is obvious why dynamic SQL is not permitted as per the microsoft..
In SQL 2005 and later, we could implement your function as a CLR function. Recall that all data access from the CLR is dynamic SQL. (here you are safe-guarded, so that if you perform an update operation from your function, you will get caught.) A word of warning
though: data access from scalar UDFs can often give performance problems and its not recommended too..
Raju Rasagounder Sr MSSQL DBA
Hi Raju,
Can you help me writing CLR for my above function? I am newbie to SQL CLR programming.
Thanks in advance!
Satya
-
Does anyone out there use dynamic SQL with DB2? If so, are the sql statements causing a PreparedStatement to be executed on DB2. I posted this question similarly before, but never resolved it, and it is killing me. I have to resolve this ASAP!
Here is the problem: My DB2 Admin says that EVERY TIME I access the database, my Java app is causing the database to create a PreparedStatement. However, I'm using Statement objects exclusively, with dynamic SQL. He says that DB2 needs an "access path" for the client, and that it converts the Statement to a PreparedStatement, as this is the only way to get this "access path". He says the only solution is either stored procedures or SQLJ, which will do the binding in advance, and increase performance tremendously. However, I am STRONGLY opposed to using SQLJ, and if we do stored procedures, we'd have to write one for every possible SQL statment! I KNOW there is a better solution.
Is anyone out there having these problems with JDBC and DB2? Surely someone out there uses DB2 and JDBC and either has these problems or can confirm that something is incorrectly configured on the database side.
Any help would be great. Thanks, WillNow I'm wondering if maybe the PreparedStatements are ONLY being called on the database when I call getConnection(), and not when I call executeQuery() or executeUpdate() from the Statement object. I just can't see why the database would have to make an access path for every SQL statement executed, but I could see it creating an access path for every connection requested. Any thoughts on that theory?
-
How to use SQL import to set the attribute value based on another?
Hello all,
I want to set an attribute of a dimension based on another attribute (if matches). Let's say I have a dimension PRODUCT. And I have defined two user defined attributes MANAGER and ISVISIBLE.
Now within a PERMIT_READ program I want to set the ISIVISIBLE to true where the MANAGER Value is selected from a table.
Something like
<define a cursor c1 to select all the Manager values>
sql import c1 into -
:MATCHSKIPERR PRODUCT_MANAGER then <PRODUCT_ISVISIBLE (PRODUCT MANAGER) = true>
<etc>
Obviously the above is not correct. But I am stuck as to how this can be done? Can some one on this forum please help me with correct syntax/ approach please?
Thanks a lot.
Pxsheth
This statement assigns true to the isvisible attribute for every gc_dim_bu dimension (selected as part of cursor c1).
SO FAR SO GOOD.. NOW -
If I want to change the above so that the attribute value gets assigned based on another attribute for the dimension (say a flag). i.e.
Set the isvisible to true where attribute flag has a certain value. How do I code this in OLAP DML?There are a number of ways to do this. If you want to use an attribute that has been defined within AWM as an attribute of Product then simply using the mapping tool to populate the attribute as part of the normal dimension load procedure.
Alternatively you could create an attribute at the DML level, and assuming you are not using surrogate keys, you can then define a cursor to read the relational table to populate your attribute. Something like this:
sql declare MKT_BASKET cursor for -
select PRODUCT_ID, PROD_MGR , PROD_VISIBLE -
from PRODUCT_DIM
if SQLCODE ne 0
then goto ERROR
sql open MY_CURSOR
sql fetch MY-CURSOR loop into :append PRODUCT, :PRODUCT_MANAGER, :PRODUCT_ISVISIBLE
sql close MY_CURSOR
sql cleanup
update
commit
If you want to create a complex PERMIT function using OLAP DML then personally I would create a formula and assign a program of type BOOLEAN and have the program return a YES or NO depending on the outcome of your test. Then your PERMIT_READ still references a dimension object. For example:
DEFINE PROD.ISVISIBLE BOOLEAN FORMULA <PRODUCT>
EQ PRG.ISVISIBLE(PRODUCT)
DEFINE PRG.ISVISBLE PROGRAM BOOLEAN
The program will then return Yes or No depending on the processing you need to do.
Hope this helps
Keith Laker
Data Warehouse Solution Architect
Oracle EMEA Consulting
BI Blog: http://oraclebi.blogspot.com/
DM Blog: http://oracledmt.blogspot.com/
BI on Oracle: http://www.oracle.com/bi/
BI on OTN: http://www.oracle.com/technology/products/bi/
BI Samples: http://www.oracle.com/technology/products/bi/samples/ -
Any tricks to use PL/SQL types in object attributes?
I guess this is a bit of a newbie-question, but I haven't been able to find any workarounds elsewhere, so please bear with me... I'm far from new to object orientation, but I'm rather new to Oracle's object features.
I was wondering if there's some trick you can use to keep references to attributes of PL/SQL types even though they are not allowed in object types (as these are "SQL", yes I do think I understand). I was thinking there might be some way you could cast them to some data type that is supported in SQL and then get them back by the reverse process when you need them in the PL/SQL inside the methods?
In the concrete case, I would like to keep a reference to a utl_smtp connection in my object. It doesn't matter that the reference would be meaningless in other sessions etc. (actually I may not even want to store the objects in any persistent table - it's the polymorphism I'm after):
CREATE OR REPLACE TYPE o_test AS OBJECT (
att1 NUMBER,
att2 sys.utl_smtp.connection
- which of course give me:
LINE/COL ERROR
0/0 PL/SQL: Compilation unit analysis terminated
3/12 PLS-00329: schema-level type has illegal reference to
SYS.UTL_SMTP
The problem becomes rather dull since I can't pass the connection record as a parameter to methods either.
The only workaround I could think of was to keep the connection as a global variable in a PL/SQL package and then get it from there inside the methods. Of course this can be refined using an index by table and some object unique id to support multiple objects with their separate connections. But it still seems rather clumbsy - especially given that what I was looking for was the elegance of polymorphism.
Any tricks I don't know of?
I'm working in Oracle 10gR2.
best regards,
Jakob
Edited by: schmidt on Mar 21, 2011 10:52 PMThe UTL_SMTP Connection record is not too complicated, and can be easily translated into SQL object types. Add a package to aid in conversion between SQL and PLSQL, and voila!
create or replace type o_utl_tcp_connection is object (
remote_host VARCHAR2(255),
remote_port INTEGER,
local_host VARCHAR2(255),
local_port INTEGER,
charset VARCHAR2(30),
newline VARCHAR2(2),
tx_timeout INTEGER,
private_sd INTEGER
define typeOf_SQL_BOOLEAN = 'number'
define SQL_BOOLEAN = '&typeOf_SQL_BOOLEAN(1)'
define SQL_TRUE = 1
define SQL_FALSE = 0
create or replace type o_utl_smtp_connection is object (
host VARCHAR2(255), -- remote host name
port INTEGER, -- remote port number
tx_timeout INTEGER, -- Transfer time out (in seconds)
private_tcp_con o_utl_tcp_connection, -- private, for implementation use
private_state INTEGER, -- private, for implementation use
-- Optionally, encapsulate all UTL_SMTP package calls behind object methods
member procedure open(
self IN OUT NOCOPY o_utl_smtp_connection,
host IN VARCHAR2,
port IN INTEGER DEFAULT 25,
tx_timeout IN INTEGER DEFAULT NULL,
wallet_path IN VARCHAR2 DEFAULT NULL,
wallet_password IN VARCHAR2 DEFAULT NULL,
secure_connection_before_smtp IN &typeOf_SQL_BOOLEAN DEFAULT &SQL_FALSE
member procedure writeData(
self IN OUT NOCOPY o_utl_smtp_connection,
data IN VARCHAR2 CHARACTER SET ANY_CS
create or replace type body o_utl_smtp_connection is
member procedure open(
self IN OUT NOCOPY o_utl_smtp_connection,
host IN VARCHAR2,
port IN INTEGER DEFAULT 25,
tx_timeout IN INTEGER DEFAULT NULL,
wallet_path IN VARCHAR2 DEFAULT NULL,
wallet_password IN VARCHAR2 DEFAULT NULL,
secure_connection_before_smtp IN &typeOf_SQL_BOOLEAN DEFAULT &SQL_FALSE
is
begin
self := SMTP_UTILS.toSqlConnection(SYS.UTL_SMTP.Open_Connection(
host
, port
, tx_timeout
, wallet_path
, wallet_password
, nvl(secure_connection_before_smtp = &SQL_TRUE, false)
end;
member procedure writeData(
self IN OUT NOCOPY o_utl_smtp_connection,
data IN VARCHAR2 CHARACTER SET ANY_CS
is
conn SYS.UTL_SMTP.Connection := SMTP_UTILS.toPlSqlConnection(self);
begin
begin
SYS.UTL_SMTP.Write_Data(conn, data);
self := SMTP_UTILS.toSqlConnection(conn);
exception
when others then
self := SMTP_UTILS.toSqlConnection(conn);
raise;
end;
end;
end;
create or replace type o_test is object (
attr1 number,
attr2 o_utl_smtp_connection,
member procedure doSomethingWithConnection
create or replace package SMTP_UTILS
is
function toPLSQLConnection(aConnection in o_utl_smtp_connection)
return SYS.UTL_SMTP.Connection;
function toSQLConnection(aConnection in SYS.UTL_SMTP.Connection)
return o_utl_smtp_connection;
end;
create or replace package body SMTP_UTILS
is
function toPLSQLConnection(aConnection in o_utl_smtp_connection)
return SYS.UTL_SMTP.Connection
is
result SYS.UTL_SMTP.Connection;
begin
result.host := aConnection.host;
result.port := aConnection.port;
result.tx_timeout := aConnection.tx_timeout;
result.private_state := aConnection.private_state;
result.private_tcp_con.remote_host := aConnection.private_tcp_con.remote_host;
result.private_tcp_con.remote_port := aConnection.private_tcp_con.remote_port;
result.private_tcp_con.local_host := aConnection.private_tcp_con.local_host;
result.private_tcp_con.local_port := aConnection.private_tcp_con.local_port;
result.private_tcp_con.charset := aConnection.private_tcp_con.charset;
result.private_tcp_con.newline := aConnection.private_tcp_con.newline;
result.private_tcp_con.tx_timeout := aConnection.private_tcp_con.tx_timeout;
result.private_tcp_con.private_sd := aConnection.private_tcp_con.private_sd;
return result;
end;
function toSQLConnection(aConnection in SYS.UTL_SMTP.Connection)
return o_utl_smtp_connection
is
result o_utl_smtp_connection;
begin
result.host := aConnection.host;
result.port := aConnection.port;
result.tx_timeout := aConnection.tx_timeout;
result.private_state := aConnection.private_state;
result.private_tcp_con.remote_host := aConnection.private_tcp_con.remote_host;
result.private_tcp_con.remote_port := aConnection.private_tcp_con.remote_port;
result.private_tcp_con.local_host := aConnection.private_tcp_con.local_host;
result.private_tcp_con.local_port := aConnection.private_tcp_con.local_port;
result.private_tcp_con.charset := aConnection.private_tcp_con.charset;
result.private_tcp_con.newline := aConnection.private_tcp_con.newline;
result.private_tcp_con.tx_timeout := aConnection.private_tcp_con.tx_timeout;
result.private_tcp_con.private_sd := aConnection.private_tcp_con.private_sd;
return result;
end;
end;
create or replace type body o_test is
member procedure doSomethingWithConnection
is
begin
-- Make SMTP calls thru connection object methods
self.attr2.open();
end;
end;
/Hope it helps.
Gerard
Edited by: gaverill on May 17, 2011 3:02 PM - formatted code -
Hi Experts !
I am trying to build search UIBB where I need to configure the search criteria dynamically in the IF_FPM_GUIBB_SEARCH~GET_DEFAULT_CONFIG method.
Please can anyone tell me is it possible to set the attribute types in dynamic configuration .... because I need to create a drop down field in the selection screen.
Thanks !Was it really necessary to post the whole API description?!?
Locale[] locales = Locale.ENGLISH();ENGLISH is not a method in class Locale, so do not add the braces "( );".
Also, the constant ENGLISH is not an array, but just a single Locale object.
You didn't say what your problem was. What do you want to achieve with your program and what is it that you don't understand? -
Item Values Not Set - Dynamic SQL Fails to Parse.
** Think I've fixed this **
(By simply defining some page computations I was able to set the item values to some default. Please don't feel the need to reply :-))
I have a page consisting of 5 report parameters and a report, all in one region, 4 parameters are LOVs and one is a text field which in the query are all compared to table column values. The report region type is SQL Query(PL/SQL function body returning SQL Query).
If I load the page in a new session with default values for the LOVs as '%' and a null text field, I get the following error message:-
failed to parse SQL query:
ORA-00936: missing expression
If I examine the session state, I see that none of the parameter values are set, which is probably why the dynamic sql is failing.
If I set one of the parameters to something, eg. choose another value in an LOV or type some text in the text field, and re-run the report, it executes without error.
What's the easiest way to fix this, is it to set the page items to some specific values when the page is first loaded? If so how do I do that? I'm not having much luck creating some process to do it.
All help appreciated.
Ian
Message was edited by:
Ian_FHi Ian,
Did you already try to put a default value for that lov?
Or try to do a computation before header?
Thanks,
Dimitri
-- http://dgielis.blogspot.com
-- http://apex-evangelists.com -
Dynamically setting field attributes based on input
Hi all,
I am trying to see if it is possible to dynamically set field attributes depending on other fields. For example, in screen 1100 of IQ01, I want to make it so that "Certification number" becomes mandatory if "certification status" = 1, and becomes optional if "certification status" = 2,3 or 4.
Is this possible? If so, how?
Regards,
D.Have you checked this
http://help.sap.com/saphelp_nw70/helpdata/en/9f/dbab6f35c111d1829f0000e829fbfe/content.htm
if your requirement is to do this in Tcode IQ01 then the above answer is not sufficient
Edited by: Abhishek Jolly on Aug 15, 2008 5:41 PM -
Trying to set control hints in entity object attributes in generic classes
Hi, how are you? I work for a project , that uses JDeveloper 10.1.3.3 version and I am assigned to solve some problems in the part that is associated with ADF Business Components—Model—of the application. The question is how could I implement generic functionality in CustomEntityImpl and there I am to assign some control hint values to some attributes and then the entities that will extend this class will acquire this functionality in their attributes.
I send you some code I have in my mind in order to find out how to write something relevant to set control hints. I have searched in relevant api’s for AttributeHints and EntityDef but I did not find a solution to my problem. I’ve tried this code:
AttributeHints ah=new AttributeHints(new AttributeDef(RIBUTE_DISPLAY_HINT_HIDE ) );
but it does not work. How could I set this value – to hide one attribute whenever it exists in my entities , setting it once in my CustomEntityImpl class?
I’ve read the whole tutorial ADF Business Components For Forms 4GL Developers but I did not find a solution to my problem. Your help would be a gift to me. Thank you very much!
private String primary_key = "Id";
private final String dte_insert = "Dteinsert";
private final String dte_update = "Dteupdate";
private final String user_insert = "Usrinsert";
private final String user_update = "Usrupdate";
private final String afm = "Afm";
protected boolean findAttribute(String name) {
String[] list = this.getAttributeNames();
for (int i = 0; i < list.length; i++) {
if (name.equals(list))
return true;
return false;
protected void doDML(int operation, TransactionEvent transactionEvent) {
//Insert Operation
if (operation == DML_INSERT) {
//Add history column
if (findAttribute(dte_insert)) {
Date date = new Date((new Date()).getCurrentDate());
this.setAttribute(dte_insert, date);
//Update Operation
else if (operation == DML_UPDATE) {
//Add history column
if (findAttribute(dte_update)) {
Date date = new Date((new Date()).getCurrentDate());
this.setAttribute(dte_update, date);
//Delete Operation
else if (operation == DML_DELETE) {
//To DO
super.doDML(operation, transactionEvent);I Suggest you set its Attribute on EOImpl, override doDML, and before call super.doDML set your Attribute. There is a special reason to set Attribute on beforeCommit?
Best Regards -
Setting property attribute values for multiple selected objects.
Hello,
Is there an easy way to set the attribute property values for more that one selected Table Operator Attribute (column) at a time. For example the target table has over 100 columns but I only want to INSERT/UPDATE 10 of those columns. The generated MERGE, INSERT and UPDATE statements will perform DML on all of the columns in the target table, setting the 90 columns with no mapping set to NULL. This is due to the Loading Properties 'Load Column when Updating Row' and 'Load Column when Inserting Row' both default to Yes. I would like to select multiple Attributes in the Table Operator and change the 'Load Column when Updating Row' and 'Load Column when Inserting Row' to No. This is similar to what you were able to do in Oracle Forms 9.0 Designer select multiple Items in a Block and change the properties en-masse.
ThanksHi,
Using OMB scripting to set attribute properties in a data mapping sort of defeats the purpose of utilizing a graphical user interface to define and set properties for a data mapping? Surely the GUI data mapping tool was created to get away from writing scripts and scripting would also require that you know the name of the data mapping, table operator and the set of attribute names for which you have to write one line of script to set each property value, i.e. 90 lines to set 90 attribute values.
Cheers,
Phil -
Help Needed in Dynamic Sql or alternate to Dynamic Sql
Hi Am working in sqlserver 2008 R2 and here is my Table structure and SPC
;create table SalaryReport(IdSalary int primary key identity(1,1),
IDMainCompany int,IDSubCompany int,Salary money,Incentive int,NoofEmployees int, SalaryDate datetime, Creditscore int );
insert into SalaryReport (IDMainCompany,IDSubCompany,Salary,Incentive,NoofEmployees,SalaryDate,Creditscore)
( Select 100 as IDMainCompany , 1000 as IDSubCompany ,200000 AS Salary, 20000 as Incentive, 500 as NoofEmployees,
'2014-01-01' as SalaryDate, 60 as Creditscore union all
Select 100 as IDMainCompany , 1001 as IDSubCompany ,300000 AS Salary, 40000 as Incentive, 600 as NoofEmployees,
'2014-01-01' as SalaryDate , 70 as Creditscore union all
Select 100 as IDMainCompany , 1002 as IDSubCompany ,400000 AS Salary, 40000 as Incentive, 1500 as NoofEmployees,
'2014-01-01' as SalaryDate , 45 as Creditscore union all
Select 101 as IDMainCompany , 1003 as IDSubCompany ,30000 AS Salary, 2000 as Incentive, 100 as NoofEmployees,
'2014-01-01' as SalaryDate, 60 as Creditscore union all
Select 102 as IDMainCompany , 1004 as IDSubCompany ,450000 AS Salary, 25000 as Incentive, 700 as NoofEmployees,
'2014-01-01' as SalaryDate, 30 as Creditscore)
Sample Test Script:
DECLARE @IDMainCompany int = 100;
DECLARE @Process_Date datetime = '2014-01-01';
declare @Query nvarchar(max);
SELECT
CAST(SR.IDMainCompany AS VARCHAR(12)) AS IDMainCompany
,CAST(SR.IDSubCompany AS VARCHAR(12)) AS IDSubCompany
,CAST(SR.Salary AS VARCHAR(12)) AS Salary
,CAST(SR.Incentive AS VARCHAR(12)) AS Incentive
,CAST(SR.NoofEmployees AS VARCHAR(12)) AS NoofEmployees
,CAST(SR.SalaryDate AS VARCHAR(15)) AS SalaryDate
,CAST((SR.Creditscore) AS VARCHAR(15)) AS average
FROM SalaryReport SR
WHERE SR.IDMainCompany = @IDMainCompany
AND DATEPART(MM, SR.SalaryDate) = DATEPART(MM, @Process_Date)
UNION ALL
SELECT
'' AS IDMainCompany
,'' AS IDSubCompany
,'Total: ' + CAST(SUM(SR.Salary) AS VARCHAR(12)) AS Salary
,'Total: ' + CAST(SUM(SR.Incentive) AS VARCHAR(12)) AS Incentive
,'Total: ' + CAST(SUM(SR.NoofEmployees) AS VARCHAR(12)) AS NoofEmployees
,'' AS SalaryDate
,'Total: ' +CAST(avg(SR.Creditscore) AS VARCHAR(12)) AS Totalaverage
FROM SalaryReport SR
WHERE SR.IDMainCompany = @IDMainCompany
AND DATEPART(MM, SR.SalaryDate) = DATEPART(MM, @Process_Date)
group by IDMainCompany, DATEPART(MM, SalaryDate)
the sample data i posted is having less columns. actually i have 20 columns in the select list. Also the parameters to the where condition i gave two i.e IDMainCompany, SalaryDate. I will also need to use IDSubCompany for some case. My skeleton will be
Create Procedure Test(@IDMainCompany int, @IDSubCompany int = null, @SalaryDate datetime)
as
BEGIN
IF(@IDMainCompany is not null && @IDMainCompany > 0 && @SalaryDate is not null && @SalaryDate <> ' ' &&
@IDSubCompany is null)
BEGIN
--The logic what discussed on previous posts will falls here with @IDMainCompany, @SalaryDate as parameter to the where condition
END
IF(@IDMainCompany is not null && @IDMainCompany > 0 && @SalaryDate is not null && @SalaryDate <> ' ' &&
@IDSubCompany is null && @IDSubCompany > 0 )
BEGIN
--The logic what discussed on previous posts will falls here with @IDMainCompany, @SalaryDate,@IDSubCompany as parameter to the where condition
END
END
As said i need to include 20 columns in the select list and as union all used on the previous sample there are 20 columns on the first query and 20 columns on the second query after the union all. The SPC will become big. If i repeat this for second if condition,
it will be too big. How can i reduce this writing more lines.
I am aware of the concept dynamic sql. Is there any other way to do this? or if dynamic sql is the only option, can anyone help me rewriting this select statements as dynamic sql
Could anyone please assist me
loving dotnet>>
thanks for your reply and yes, i am invoking this from my asp.net application using C# language. Would you like to share something?
<<
Yes,
You can use client side dynamic sql. I'm not talking about concatenating strings. I'm talking about using Runtime Text Tamplates (preprocesed templates in Visual Studio 2010).
Add a new "Runtime Text Template" item to your VS project. Be "MyReportTemplate.tt" the file name of the runtime text template. The content of this file should be something like the following:
<#@ template language="C#" #>
<#@ assembly name="System.Core" #>
SELECT
-- part of your query goes here
-- the interesting part come next
FROM
SalaryReport SR
WHERE
SR.IDMainCompany = @IDMainCompany
<# if (IDSubCompany.HasValue && IDSubCompany.Value > 0) { #>
AND SR.IDSubCompany = @IDSubCompany
<# } #>
AND
DATEPART(MM, SR.SalaryDate) = DATEPART(MM, @Process_Date)
GROUP BY
IDMainCompany, DATEPART(MM, SalaryDate)
Add a new c# code file named MyReportTemplate.partial.cs closed to MyReportTemplate.tt with the following code:
public partial class MyReportTemplate
public int? IDSubCompany { get; set; }
Then, to execute the query you can write a code similar to the following:
public DataTable ExecuteReport(int mainCompanyId, int? subCompanyId, DateTime processDate )
using (var cn = CreateConnection())
using (var cmd = new SqlCommand())
using (var adapter = new SqlDataAdapter(cmd))
cmd.Connection = cn;
var template = new MyReportTemplate
IDSubCompany = subCompanyId
cmd.CommandText = template.TransformText();
cmd.Parameters.AddWithValue("@IDSubCompany", subCompanyId == null ? (object) DBNull.Value : subCompanyId.Value);
cmd.Parameters.AddWithValue("@IDMainCompany", mainCompanyId);
cmd.Parameters.AddWithValue("@Process_Date", processDate);
var table = new DataTable();
adapter.Fill(table);
return table;
EntityLite: A Lightweight, Database First, Micro ORM -
Use Granfeldts Create Object to create dynamic groups
Trying to use Sorens Granfeldts, Create Object WF activity to create dynamic groups.
In a standard function evaluator activity I generate the Filter as [//WorkflowData/Filter]
The "string" I set it to is:
<Filter xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" Dialect="http://schemas.microsoft.com/2006/11/XPathFilterDialect" xmlns="http://schemas.xmlsoap.org/ws/2004/09/enumeration">/Person[ObjectID
= /*[ObjectID = '8dfcb5e8-ff01-400c-8ca7-2a0002d2d2d4']/ComputedMember]</Filter>
In the CreateObject activity I then just have [//WorkflowData/Filter],Filter among the initial values.
The creation works if I remove this attribute so the rest of the attributes seems to be working.
The creation fails however end I get the error below in the Forefront Identity Manager event log.
System.NullReferenceException: Object reference not set to an instance of an object.
at Microsoft.ResourceManagement.WFActivities.Resolver.GetDisplayStringFromGuid(Guid id, String[] expansionAttributes)
at Microsoft.ResourceManagement.WFActivities.Resolver.ReplaceGuidWithTemplatedString(Match m)
at System.Text.RegularExpressions.RegexReplacement.Replace(MatchEvaluator evaluator, Regex regex, String input, Int32 count, Int32 startat)
at System.Text.RegularExpressions.Regex.Replace(String input, MatchEvaluator evaluator)
at Microsoft.ResourceManagement.WFActivities.Resolver.GetStringAttributeValue(Object attribute)
at Microsoft.ResourceManagement.WFActivities.Resolver.ResolveEvaluatorWithoutAntiXSS(String match, ResolverOptions resolveOptions)
at Microsoft.ResourceManagement.WFActivities.Resolver.ResolveEvaluatorForWithAntiXSS(String match, ResolverOptions resolveOptions)
at Microsoft.ResourceManagement.WFActivities.Resolver.ReplaceMatches(String input, Boolean useAntiXssEncoding, ResolverOptions resolveOptions)
at Microsoft.ResourceManagement.Workflow.Hosting.ResolverEvaluationServiceImpl.ResolveLookupGrammar(Guid requestId, Guid targetId, Guid actorId, Dictionary`2 workflowDictionary, Boolean encodeForHTML, String expression)
at Microsoft.ResourceManagement.Workflow.Activities.ResolveGrammarActivity.Execute(ActivityExecutionContext executionContext)
at System.Workflow.ComponentModel.ActivityExecutor`1.Execute(T activity, ActivityExecutionContext executionContext)
at System.Workflow.ComponentModel.ActivityExecutor`1.Execute(Activity activity, ActivityExecutionContext executionContext)
at System.Workflow.ComponentModel.ActivityExecutorOperation.Run(IWorkflowCoreRuntime workflowCoreRuntime)
at System.Workflow.Runtime.Scheduler.Run()
Have anyone used this WF activity to create dynamic groups and can tell how to set the Filter?Hey Kent!
I did the same thing, with Søren`s Create Object WF. I did it like this on the filter part:
<Filter xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" Dialect="http://schemas.microsoft.com/2006/11/XPathFilterDialect" xmlns="http://schemas.xmlsoap.org/ws/2004/09/enumeration">/Person[(Department = '[//Target/ObjectID]')]</Filter>,Filter
The whole thing looks like this:
(I use Function evaluator to generate a AccountName for groups based on a clean version of DisplayName).
[//Target/DisplayName],DisplayName
SEC_[//WorkFlowData/CleanAccountName],AccountName
[//Target/Manager],Owner
Security,Type
DOMAIN_STRING,Domain
Universal,Scope
[//Target/DisplayName]_SecGroup,Description
[//Target/Manager],DisplayedOwner
None,MembershipAddWorkflow
True,MembershipLocked
[//Target/CleanAccountName],MailNickname
<Filter xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" Dialect="http://schemas.microsoft.com/2006/11/XPathFilterDialect" xmlns="http://schemas.xmlsoap.org/ws/2004/09/enumeration">/Person[(Department = '[//Target/ObjectID]')]</Filter>,Filter
Regards, Remi www.iamblogg.com -
Add Object Attributes to a DisplayObject that is created in the Authoring Tool
Hello, how can I add attributes to a Display Object, that I have created in the Authoring Tool, so I can acces it by:
myDisplayObjectInstance.myNewAttribute
Is a DisplayObejct a dynamic class, that can be extended from anywhere?
Thanks a lotI just found the syntax to add a new ObjectAttribute to an Instance of the Object. But is this ObjectAttribute also added to all other Instances of the Obejct?
My plan was to create a MovieClip and set some ActionScript inside its timeline in the first frame that adds some Objcet Attributes to that MovieClip, so that the new Object Attribute can be used for all Instances of this MovieClip, that are created in the runtime.
Maybe you are looking for
-
How to use a Westell 7500 as a router-switch ?
I have an extra Verizon Westell 7500 DSL modem router (A90-750015-07). How do I turn it into a router-switch that will take an ethernet (not DSL) network feed (with internet access) and distribute it among a few devices and put those devices into som
-
This is totally insane!! They took someone's money in a sec by 'MISTAKE' but haven't returned after 10days. I already have chatted with two staffs about this but different from what they promised, this still has not solved yet! My devoted time for th
-
Apple Remote Desktop - Where do I start?
I need some help. I have three Macs at home and one at my moms. I bought ARD today and installed it. I can only control one Mac. Can anyone walk me through the process of finding and establishing a client? When I put in an IP address, ARD cannot find
-
RH HTML 9 - CHM file Slow performance when opening project.
Recently RH 9 runs very slow when I open my project, I even cannot open a folder in the Project Manager pod. I think maybe there are some corrupt files cause it. Anyone has experience please help me. Thank you.
-
Hi there For several months now I have had an issue with my MAC whereby the machine simply freezes up and I need to force shut down and then re-start to get it going again. Lately it is becoming increasingly unreliable. I have considered that perhaps