IScript problem - Cannot use an input in a sql statement
I get the input from an input box and it is correct
¶m = %Request.GetParameter("Dept");
I try to use it in a sql statement lke this and nothing displays even though it its entered correctly and the value exists in the table
Local SQL &usersCursor = CreateSQL("SELECT EMPLID, BIRTHDATE, NAME FROM PS_EMPLOYEES WHERE DEPTNAME_ABBRV = '¶m'");
If I leave out the single quotes around and do it like this ¶m then it errors out
Local SQL &usersCursor = CreateSQL("SELECT EMPLID, BIRTHDATE, NAME FROM PS_EMPLOYEES WHERE DEPTNAME_ABBRV = ¶m");
I need help structuring this correctly
Thanks,
Allen Cunningham
Hi,
CreateSQL does not execute the sql statement, it just creates an SQL object, which you have to execute.
Something like this:
¶m = %Request.GetParameter("Dept");
Local SQL &usersCursor = CreateSQL("SELECT EMPLID, BIRTHDATE, NAME FROM PS_EMPLOYEES WHERE DEPTNAME_ABBRV = :1", ¶m);
While usersCursor.Fetch(&Emplid, &Birthdate, &Name)
/* do processing*/
End-While;
Similar Messages
-
T400 problem, cannot use thinkvantage
I just received the new T400, the first time I opened it, I did as the instruction told, then I chose "shrink volume" of the biggest volume (not the hidden one or the lenovo volume), and formatted the new volume. Then I got bluescreen.
I did use the thinkvantage to restore the system, it went well but I found that the new volume I got last time was still there. Moreover, a lot of the softwares cannot be used, and a lot of functions seem to be blocked or disabled, for example, I cannot get on the wireless network, but before I shrinked the volume, I can.
Now I want to try the thinkvantage again, but I cannot get in anymore!!! What am I supposed to do now!?
Everytime I start the computer, it pops up 2 windows, saying:
"Error loading C:\PROGRA~1\ThinkPad\UTILT~1\PWMTR32V.DLL The specific module could not be found"
"Error loading C:\PROGRA~1\ThinkPad\UTILT~1\BTVLogEx.DLL The specific module could not be found"
Can I still get the free service covered in my one-year default warranty?Hi,
CreateSQL does not execute the sql statement, it just creates an SQL object, which you have to execute.
Something like this:
¶m = %Request.GetParameter("Dept");
Local SQL &usersCursor = CreateSQL("SELECT EMPLID, BIRTHDATE, NAME FROM PS_EMPLOYEES WHERE DEPTNAME_ABBRV = :1", ¶m);
While usersCursor.Fetch(&Emplid, &Birthdate, &Name)
/* do processing*/
End-While; -
Use of Input Variables in SQL-Queries Sometimes Not Possible
Only in simple SELECT-statements the use of input variables ([%0], [%1], etc.) work without problems.
In more complex queries the use of these variables is not possible (e.g. SELECT-statements with sub-queries, sometimes when UNION is used - but I couldn't find any general rule when the problems will arise; sometimes two different queries with the same query-structure behave in different ways when these variables are used).
In these cases the query is not executed - not even the input-window to enter values into the input variables is displayed. The query stops with some strange error-messages in the status line. These error-messages doesn't have any relation to the actual query - sometimes it refers to field-names never used in the query or refers to syntax error which do not exist.
If the input variables are replaced by constant values there are no problems so there can't be any syntax errors - the only difference is the presence or absence of input variables.
Example:
provided that the queries have a certain complexity
SELECT ...
FROM ... OINV Tx ...
WHERE ... Tx.DocDate >= [%0] ...
does not work,
SELECT ...
FROM ... OINV Tx ...
WHERE ... Tx.DocDate >= '1.1.2007' ...
works!
Does anybody have run into the same problem and now if it is a bug of SAP-BO or an error on behalf of the user? Does anybody know a way to correct the problem?
Thanks in advance!
Frank
By the way: Are there any rules where exactly input variables can be used in a query?
Only in SELECT-statements? Where there exactly?
In statements outside of SELECT?Only SAP Partners Can access service.sap.com/notes, but I think it is possible to search in them from the customer portal as well.
Here are summary of the two notes mentioned before this:
730960:
<i>
The following query is an example for how to define variables in long
queries rather than using "Fixed Declares".
You need to use exactly the same template as follows, do not delete
"comments" from this query.
The only changes you need to do :
1. In the first and in the fifth rows you need to select the table to which you would like to relate the variable e.g. in this example, the variable is related to the table VPM1 - 'Payments to Vendors - Rows'.
2. In the fourth and in the eighth rows you need to select the field to which you would like to define the variables e.g. in this example, the variable is the field 'DueDate'.
/SELECT FROM [dbo].[VPM1] T0/
declare @fromdate as datetime
/* WHERE */
set @fromdate = /* T0.DueDate */ '[%0]'
/SELECT FROM [dbo].[VPM1] T1/
declare @tilldate as datetime
/* WHERE */
set @tilldate = /* T0.DueDate */ '[%1]'
select OVPM.docnum, VPM1.dueDate,VPM1.CheckNum, VPM1.Branch,
VPM1.BankCode, VPM1.CheckSum, OVPM.CardName,
case
when OPCH.docnum is null then VPM2.docEntry
else OPCH.docnum
end as 'docnum'
from OVPM INNER join VPM1 on OVPM.docnum = VPM1.docnum
left join VPM2 LEFT JOIN OPCH ON VPM2.DocEntry = OPCH.DocEntry
on OVPM.docnum = VPM2.docnum
where OVPM.Canceled = 'N' AND VPM1.DueDate >=@fromdate AND
VPM1.DueDate <=@tilldate
</i>
955295:
<i>
Using SAP Business One Survey Variables (parameters) in a 'Set' SQL Statement can give an error in the Query Generator.
For Example:
Declare @Num as numeric(2)
Set @Num = [%0]
Select T0.DocNum
From ORDR T0
Where DocNum = @Num
Other terms
query, SQL, parameter, survey, variable, query generator, set, declare, [%0], table, error, SAP Business One
Reason and Prerequisites
FAQ
Solution
In such cases you need to put in an SQL remark statement a reference field in the DB for the Survey Variable (any field).
For Example: (to make the above query work)
Declare @Num as numeric(2)
Set @Num = /* T0.DocNum */ [%0]
Select T0.DocNum
From ORDR T0
Where docnum = @Num
</i> -
I cannot use my pogo account as it states firefox has a bug in it and will not let java open
I cannot use my pogo account this is what it states, how do I fix this, it worked fine this morning and tonight it isn't working
It looks like you’ve the new version of Firefox. Unfortunately, there is currently a bug that is preventing players from playing Java games with version 3.6.14 of Firefox.See this: <br />
https://support.mozilla.com/en-US/kb/pogo-and-other-java-pages-dont-work -
How to write named query if we want to use IN syntax in our sql statement?
I cannot find a suitable category about named query, so please move to appropriate place if there is any.
When we write named query, below statement is fine.
Query q2 = em.createQuery("SELECT o FROM Table1 as o WHERE field1 = :input1"); q2.setParameter("input1", "value1");
Now, my question is, how can I write this type of query when we want to use the IN sql syntax? As below statement CANNOT return correct results. Even I tried to put a pair of single quote [ ':input2' ], it won't help also.
Query q2 = em.createQuery("SELECT o FROM Table1 as o WHERE field2 IN (:input2)"); q2.setParameter("input1", "3633, 3644");
Can anyone suggest? Thanks.roamer wrote:
Now, my question is, how can I write this type of query when we want to use the IN sql syntax? As below statement CANNOT return correct results. Even I tried to put a pair of single quote [ ':input2' ], it won't help also.
Query q2 = em.createQuery("SELECT o FROM Table1 as o WHERE field2 IN (:input2)");
q2.setParameter("input1", "3633, 3644");
Can anyone suggest?The above is in your code right? Not in some configuration file?
Then you do it the same way as with regular jdbc/sql.
1. You start with a collection of values - call it collection A.
1. Create a for loop that dynamically creates the string using 'bind' variables (whatever you want to call the 'colon' entity in the above).
2. Call the createQuery method using the string that was created
3. Create a second loop that iterates over A and populates with setParameter.
Pseudo code
Object[] A = ...
String sql = "SELECT o FROM Table1 as o WHERE field2 IN (";
for (int i=1; i <= A.length; i++)
if (i == 1)
sql += ":input" + i;
else
sql += ",:input" + i;
sql += ")";
Query q2 = em.createQuery(sql);
for (int i=1; i <= A.length; i++
q2.setParameter("input" + i, A[i-1]);
}By the way there is a jdbc forum. -
Can i use commit in between pl sql statements
Hi,
I have written program unit , in that I used insert statements and after that I used commit command.
But in runtime it's getting oracle error unable to insert . because I used some non database items and database items
so that it's coming error.
But my question is , Can i use commit after executing some statements in program unit procedure.
Thanks in advance.FORMS_DDL restrictions
The statement you pass to FORMS_DDL may not contain bind variable references in the string, but the
values of bind variables can be concatenated into the string before passing the result to FORMS_DDL.
For example, this statement is not valid:
Forms_DDL ('Begin Update_Employee (:emp.empno); End;');
However, this statement is valid, and would have the desired effect:
Forms_DDL ('Begin Update_Employee ('||TO_CHAR(:emp.empno)
||');End;');
However, you could also call a stored procedure directly, using Oracle8's shared SQL area over
multiple executions with different values for emp.empno:
Update_Employee (:emp.empno);
SQL statements and PL/SQL blocks executed using FORMS_DDL cannot return results to Form
Builder directly.
In addition, some DDL operations cannot be performed using FORMS_DDL, such as dropping a table
or database link, if Form Builder is holding a cursor open against the object being operated upon.
Sarah -
How do I use a variable within a sql statement
I am trying to use a local variable within an open SQL step but I keep getting an error.
My sql command looks like this "SELECT BoardDetailID FROM BoardDetails WHERE SerialNumber = " + locals.CurrentSerialNo
If I replace the locals.CurrentSerialNo with an actual value such as below the statement works fine.
"SELECT BoardDetailID FROM BoardDetails WHERE SerialNumber = " + " 'ABC001' "
Can someone tell me how to correctly format the statement to use a variable?Hi,
Thanks for the reply. I have changed the required variable to a string, but with no success. I have reattached my updated sequence file and an image of the error.
When looking at the Data operation step I see that the sql statement is missing everything after the last quotation mark.
Thanks again,
Stuart
Attachments:
Database Test Sequence.seq 10 KB
TestStand error.JPG 37 KB -
How to use presentaion variable in the SQL statement
Is there any special syntax to use a presentation variable in the SQL Statement?
I am setting a presentation variable (Fscl_Qtr_Var)in the dashboard prompt.
If i set the filter as ADD->VARIABLE->PRESENTATION, it shows the statement as 'Contract Request Fiscal Quarter is equal to / is in @{Fscl_Qtr_Var} '.
And this works fine but when i convert this to SQL, it returns
"Contract Request Date"."Contract Request Fiscal Quarter" = 'Fscl_Qtr_Var'
And this does not work.It is not being set to the value in the prompt.
I need to combine this condition with other conditions in the SQL Statement. Any help is appreciated. ThanksTry this: '@{Fscl_Qtr_Var}'
-
Using 'NOT IN' Within a SQL Statement
Does anyone know why the following SQL statement does not return any values? The problem is with the SELECT statement within the 'NOT IN' clause. When explicitly typing in the part_ids returned from the select statement, everything works as expected.
Thanks for any help.
SELECT Distinct Part_Id, Trans_Date
FROM Invctrl
WHERE Trans_Type = 0
AND Trans_Date BETWEEN To_Date( '1-Mar-2006 00:00:00', 'dd-mon-yyyy hh24:mi:ss' )
AND To_Date( '31-Jan-2007 23:59:59', 'dd-mon-yyyy hh24:mi:ss' )
AND Part_Id NOT IN (SELECT part_Id From InvCtrl WHERE Trans_Date < To_Date( '1-Mar-2006 00:00:00', 'dd-mon-yyyy hh24:mi:ss'))'NOT IN' should be avoided where ever we can.
Change your query to 'IN' clause as below and it should work.
SELECT DISTINCT part_id, trans_date
FROM invctrl
WHERE trans_type = 0
AND trans_date BETWEEN TO_DATE ('1-Mar-2006 00:00:00',
'dd-mon-yyyy hh24:mi:ss'
AND TO_DATE ('31-Jan-2007 23:59:59',
'dd-mon-yyyy hh24:mi:ss'
AND part_id IN (
SELECT part_id
FROM invctrl
WHERE trans_date BETWEEN TO_DATE ('1-Mar-2006 00:00:00',
'dd-mon-yyyy hh24:mi:ss'
AND TO_DATE ('31-Jan-2007 23:59:59',
'dd-mon-yyyy hh24:mi:ss'
MINUS
SELECT part_id
FROM invctrl
WHERE trans_date <
TO_DATE ('1-Mar-2006 00:00:00',
'dd-mon-yyyy hh24:mi:ss'
[pre] -
Using Toplink to generate UPDATE sql statements?
I have a need to generate a UPDATE sql statement.
This statement will run at startup and will not effect the cache, as no objects will be loaded prior to this command running.
I realize that I can execute arbitrary SQL using Session, however, I have the additional requirement that this UPDATE is compatible with the DB it is running on.
So, I want to use TopLink to generate an UPDATE statment perhaps using the query framework. Is this possible? Is there any way to use TopLink's ability to create SQL before passing this into a Session for execution?In the current versions your only option is to provide the UPDATE SQL directly using the executeCall(new SQLCall("UPDATE ...")).
In 10.1.3 there exists an UpdateAllQuery intended to do such batch update calls. It will additionally invalidate any cached objects if they were to exist.
Doug -
arrow does not open anything 2 in. below the toolbar works fine below that I've installed and uninstalled Firefox several times will not work using Firefox11 very hard to access a lot of things especially when ordering online cannot submit any info required
If the inoperable button or link is near the top of the page....
Recently, the Yahoo Toolbar and the Babylon extension have been reported to cause that problem. They seem to overlap invisibly over the top of the web page display. If you have either or both, uninstall or disable them/it, or see if an update is available that solves the problem.
*Uninstall Yahoo Toolbar --> http://help.yahoo.com/l/us/yahoo/toolbar/toolbar8/general/general-07.html
*Uninstall Babylon --> http://support.babylon.com/index.php?/Knowledgebase/Article/View/177/0/uninstall-babylon-software
*See --> http://support.mozilla.com/en-US/kb/Uninstalling+add-ons
*See --> http://support.mozilla.com/en-US/kb/Cannot%20uninstall%20an%20add-on
*See --> http://kb.mozillazine.org/Uninstalling_toolbars
If that does not solve the problem:
*See --> [http://support.mozilla.org/en-US/kb/Troubleshooting+extensions+and+themes Troubleshooting extensions and themes]
*See --> [http://support.mozilla.org/en-US/kb/Troubleshooting+plugins Troubleshooting plugins]
*See --> [http://support.mozilla.org/en-US/kb/Basic+Troubleshooting Basic Troubleshooting]
'''If this reply solves your problem, please click "Solved It" next to this reply when <u>signed-in</u> to the forum.''' -
Problem when using v$librarycache in PL/SQL
Hi all,
I've a problem where do the select statement like:
SELECT *
FROM v$librarycache;
in procedure using "OEM" tool.
It's popup a error message like:
Error Text = PL/SQL: ORA-00942: TABLE OR VIEW DOES NOT EXITST
NOTE: There is no problem when i'm using sqlplus.
Thank you,
KevinPeter and Jens
I've loged in as "scott" user and created few procedure and i worked fine with "scott" user. I don't need to login as "sys". The problem i have here is somehow the fixed table "v$librarycache" doesn't work in procedure. Although, i've grant select any table, create any procedure to scott;
Thanks,
Kevin -
Cannot use sqlplus variable in create sequence statement
Hello!
I would like to create a sequence object starting with a number retrieved from a select statement:
var max_resp_no number;
begin
select max(substr(resp_no,2)) into :max_resp_no from brc_mast
where substr(resp_no,1,1)='Z';
end;
print max_resp_no;
drop sequence p659_resp;
create sequence p659_resp start with :max_resp_no;
It tells me that :max_resp_no is an 'invalid number';
TIA,
habeebYou need to do this entirely in PL/SQL. You can either create a procedure, or use an anonymous block. The procedure version is below. Just change the CREATE to a DECLARE to get an anonymous block.
CREATE OR REPLACE PROCEDURE new_seq IS
max_resp_no NUMBER;
BEGIN
SELECT to_number(MAX(SUBSTR(resp_no,2)))
INTO max_resp_no
FROM brc_mast
WHERE SUBSTR(resp_no,1,1)='Z';
EXECUTE IMMEDIATE 'DROP SEQUENCE p659_resp';
EXECUTE IMMEDIATE 'CREATE SEQUENCE p659_resp START WITH '|| max_resp_no;
END;
SQL> CREATE SEQUENCE p659_resp START WITH 1;
Sequence created.
SQL> SELECT p659_resp.nextval from dual;
NEXTVAL
1
SQL> SELECT * FROM brc_mast;
RESP_
Z001
Z002
Z003
Z075
SQL> exec new_seq;
PL/SQL procedure successfully completed.
SQL> select p659_resp.nextval from dual;
NEXTVAL
75Note that the user creating this procedure will need to have CREATE SEQUENCE granted explicitly for the procedure to work. The anonymous block version should work if CREATE SEQUENCE is granted through a role.
John -
Problem while using olap cwm2 by pl/sql objects
Dear all:
I want to build an olap multidimension model by oracle cwm2 api. I created the multidimension model successfully by call the cwm2 api directory. however, when I try to write objects to encapsulate the cwm2 apis, it was not work. here is my codes:
call cwm2 api directly, it's work.
/* create star schema */
create table customer (
id number primary key,
id_continent number,
id_country number
create table selling_month (
id number primary key,
yr number (4),
mth number (12) check (mth between 1 and 12),
id_quarter number,
id_month number,
end_of_month date,
end_of_quarter date,
end_of_year date
create table product (
id number primary key,
id_category number
create table item_sold (
qty number(4),
id_customer references customer ,
id_month references selling_month,
id_product references product
/* create dimension */
begin
cwm2_olap_dimension.create_dimension(
user, -- dimension owner
'CUSTOMER_DIM', -- dimension name
'Customer', -- display name
'Customers', -- plural name
'Customer', -- short description
'Customer' -- description
end;
begin
cwm2_olap_dimension.create_dimension(
user, -- dimension owner
'PRODUCT_DIM', -- dimension name
'Product', -- display name
'Product', -- plural name
'Product', -- short description
'Product' -- description
end;
begin
cwm2_olap_dimension.create_dimension(
user, -- dimension owner
'TIME_DIM', -- dimension name
'Time', -- display name
'Time', -- plural name
'Time', -- short description
'Time', -- description
'Time' -- dimension type, note: this is the only time dimension in this example
end;
/* create hierarchy */
begin
cwm2_olap_hierarchy.create_hierarchy (
user, -- owner of dimension to which hierarchy is assigned
'CUSTOMER_DIM', -- name of dimension to which hierarchy is assigned
'CUSTOMER_HIER', -- name of hierarchy
'Customer hierarchy', -- display name
'Customer hierarchy', -- short description
'Customer hierarchy', -- description
'UNSOLVED LEVEL-BASED' -- solved code
end;
begin
cwm2_olap_hierarchy.create_hierarchy (
user, -- owner of dimension to which hierarchy is assigned
'PRODUCT_DIM', -- name of dimension to which hierarchy is assigned
'PRODUCT_HIER', -- name of hierarchy
'Product hierarchy', -- display name
'Product hierarchy', -- short description
'Product hierarchy', -- description
'UNSOLVED LEVEL-BASED' -- solved code
end;
begin
cwm2_olap_hierarchy.create_hierarchy (
user, -- owner of dimension to which hierarchy is assigned
'TIME_DIM', -- name of dimension to which hierarchy is assigned
'TIME_HIER', -- name of hierarchy
'Time hierarchy', -- display name
'Time hierarchy', -- short description
'Time hierarchy', -- description
'UNSOLVED LEVEL-BASED' -- solved code
end;
/* creating levels */
-- Levels for the customer dimension
begin
cwm2_olap_level.create_level (
user, -- owner of dimension to which level is assigned
'CUSTOMER_DIM', -- name of dimension to which level is assigned
'LVL_ALL_CUSTOMERS', -- name of level
'All customers', -- display name
'All customers', -- plural name
'All customers', -- short description
'All customers' -- description
end;
begin
cwm2_olap_level.add_level_to_hierarchy (
user, -- owner of dimension
'CUSTOMER_DIM', -- name of dimension
'CUSTOMER_HIER', -- name of hierarchy
'LVL_ALL_CUSTOMERS', -- name of level
null); -- parent level
end;
begin
cwm2_olap_level.create_level (
user, -- owner of dimension to which level is assigned
'CUSTOMER_DIM', -- name of dimension to which level is assigned
'LVL_CUSTOMERS_CONTINENT',-- name of level
'Customer on continent', -- display name
'Customers on continent', -- plural name
'Customers on continent', -- short description
'Customers on continent' -- description
end;
begin
cwm2_olap_level.add_level_to_hierarchy (
user, -- owner of dimension
'CUSTOMER_DIM', -- name of dimension
'CUSTOMER_HIER', -- name of hierarchy
'LVL_CUSTOMERS_CONTINENT', -- name of level
'LVL_ALL_CUSTOMERS'); -- parent level
end;
begin
cwm2_olap_level.create_level (
user, -- owner of dimension to which level is assigned
'CUSTOMER_DIM', -- name of dimension to which level is assigned
'LVL_CUSTOMERS_COUNTRY', -- name of level
'Customer in country', -- display name
'Customers in country', -- plural name
'Customers in country', -- short description
'Customers in country' -- description
end;
begin
cwm2_olap_level.add_level_to_hierarchy (
user, -- owner of dimension
'CUSTOMER_DIM', -- name of dimension
'CUSTOMER_HIER', -- name of hierarchy
'LVL_CUSTOMERS_COUNTRY', -- name of level
'LVL_CUSTOMERS_CONTINENT');-- parent level
end;
-- Levels for the product dimension
begin
cwm2_olap_level.create_level (
user, -- owner of dimension to which level is assigned
'PRODUCT_DIM', -- name of dimension to which level is assigned
'LVL_ALL_PRODUCTS', -- name of level
'All products', -- display name
'All products', -- plural name
'All products', -- short description
'All products' -- description
end;
begin
cwm2_olap_level.add_level_to_hierarchy (
user, -- owner of dimension
'PRODUCT_DIM', -- name of dimension
'PRODUCT_HIER', -- name of hierarchy
'LVL_ALL_PRODUCTS', -- name of level
null); -- parent level
end;
begin
cwm2_olap_level.create_level (
user, -- owner of dimension to which level is assigned
'PRODUCT_DIM', -- name of dimension to which level is assigned
'LVL_PRODUCT_CATEGORY', -- name of level
'Product category', -- display name
'Product categories', -- plural name
'Product categories', -- short description
'Product categories' -- description
end;
begin
cwm2_olap_level.add_level_to_hierarchy (
user, -- owner of dimension
'PRODUCT_DIM', -- name of dimension
'PRODUCT_HIER', -- name of hierarchy
'LVL_PRODUCT_CATEGORY', -- name of level
'LVL_ALL_PRODUCTS'); -- parent level
end;
-- Levels for the time dimension
begin
cwm2_olap_level.create_level (
user, -- owner of dimension to which level is assigned
'TIME_DIM', -- name of dimension to which level is assigned
'LVL_YEAR', -- name of level
'Year', -- display name
'Years', -- plural name
'Year', -- short description
'Year' -- description
end;
begin
cwm2_olap_level.add_level_to_hierarchy (
user, -- owner of dimension
'TIME_DIM', -- name of dimension
'TIME_HIER', -- name of hierarchy
'LVL_YEAR', -- name of level
null); -- parent level
end;
begin
cwm2_olap_level.create_level (
user, -- owner of dimension to which level is assigned
'TIME_DIM', -- name of dimension to which level is assigned
'LVL_QUARTER', -- name of level
'Quarter', -- display name
'Quarters', -- plural name
'Quarter', -- short description
'Quarter' -- description
end;
begin
cwm2_olap_level.add_level_to_hierarchy (
user, -- owner of dimension
'TIME_DIM', -- name of dimension
'TIME_HIER', -- name of hierarchy
'LVL_QUARTER', -- name of level
'LVL_YEAR'); -- parent level
end;
begin
cwm2_olap_level.create_level (
user, -- owner of dimension to which level is assigned
'TIME_DIM', -- name of dimension to which level is assigned
'LVL_MONTH', -- name of level
'Month', -- display name
'Months', -- plural name
'Month', -- short description
'Month' -- description
end;
begin
cwm2_olap_level.add_level_to_hierarchy (
user, -- owner of dimension
'TIME_DIM', -- name of dimension
'TIME_HIER', -- name of hierarchy
'LVL_MONTH', -- name of level
'LVL_QUARTER'); -- parent level
end;
/* specify the level to hierarchy relationship */
-- Customer
-- Product
-- Time
/* specify the dimesion attributes */
begin
cwm2_olap_dimension_attribute.create_dimension_attribute_2 (
user, -- owner of dimension
'TIME_DIM', -- name of dimension
'End Date', -- name of dimension attribute
'End Date', -- display name
'End Date', -- short description
'End Date', -- description
1); -- use name as type
end;
/* specify the level attributes */
begin
cwm2_olap_level_attribute.create_level_attribute_2 (
user, -- owner of dimension
'TIME_DIM', -- name of dimension
'End Date', -- name of dimension attribute
'LVL_YEAR', -- name of level
'End Date', -- name of level attribute
'End Date', -- display name
'End Date', -- short description
'End Date', -- description
1); -- use name as type
end;
begin
cwm2_olap_level_attribute.create_level_attribute_2 (
user, -- owner of dimension
'TIME_DIM', -- name of dimension
'End Date', -- name of dimension attribute
'LVL_QUARTER', -- name of level
'End Date', -- name of level attribute
'End Date', -- display name
'End Date', -- short description
'End Date', -- description
1); -- use name as type
end;
begin
cwm2_olap_level_attribute.create_level_attribute_2 (
user, -- owner of dimension
'TIME_DIM', -- name of dimension
'End Date', -- name of dimension attribute
'LVL_MONTH', -- name of level
'End Date', -- name of level attribute
'End Date', -- display name
'End Date', -- short description
'End Date', -- description
1); -- use name as type
end;
/* mapping the levels to columns in the dimension table */
-- Customer
-- Hierarycies (from high to low): ID_COUNTRY->ID_CONTINENT->ID
begin
cwm2_olap_table_map.map_dimtbl_hierlevel(
user, -- dimension owner
'CUSTOMER_DIM', -- dimension name
'CUSTOMER_HIER', -- name of hierarchy
'LVL_ALL_CUSTOMERS', -- name of level
user, -- owner of dimension table
'CUSTOMER', -- name of table
'ID_COUNTRY', -- name of column
null -- name of parent column
end;
begin
cwm2_olap_table_map.map_dimtbl_hierlevel(
user, -- dimension owner
'CUSTOMER_DIM', -- dimension name
'CUSTOMER_HIER', -- name of hierarchy
'LVL_CUSTOMERS_CONTINENT', -- name of level
user, -- owner of dimension table
'CUSTOMER', -- name of table
'ID_CONTINENT', -- name of column
'ID_COUNTRY' -- name of parent column
end;
begin
cwm2_olap_table_map.map_dimtbl_hierlevel(
user, -- dimension owner
'CUSTOMER_DIM', -- dimension name
'CUSTOMER_HIER', -- name of hierarchy
'LVL_CUSTOMERS_COUNTRY', -- name of level
user, -- owner of dimension table
'CUSTOMER', -- name of table
'ID', -- name of column
'ID_CONTINENT' -- name of parent column
end;
-- Product
-- Hierarchies: ID_CATEGORY->ID
begin
cwm2_olap_table_map.map_dimtbl_hierlevel(
user, -- dimension owner
'PRODUCT_DIM', -- dimension name
'PRODUCT_HIER', -- name of hierarchy
'LVL_ALL_PRODUCTS', -- name of level
user, -- owner of dimension table
'PRODUCT', -- name of table
'ID_CATEGORY', -- name of column
null -- name of parent column
end;
begin
cwm2_olap_table_map.map_dimtbl_hierlevel(
user, -- dimension owner
'PRODUCT_DIM', -- dimension name
'PRODUCT_HIER', -- name of hierarchy
'LVL_PRODUCT_CATEGORY', -- name of level
user, -- owner of dimension table
'PRODUCT', -- name of table
'ID', -- name of column
'ID_CATEGORY' -- name of parent column
end;
-- Time
-- Hierarchies: YR->ID_QUARTER->ID_MONTH
begin
cwm2_olap_table_map.map_dimtbl_hierlevel(
user, -- dimension owner
'TIME_DIM', -- dimension name
'TIME_HIER', -- name of hierarchy
'LVL_YEAR', -- name of level
user, -- owner of dimension table
'SELLING_MONTH', -- name of table
'YR', -- name of column
null -- name of parent column
end;
begin
cwm2_olap_table_map.map_dimtbl_hierlevel(
user, -- dimension owner
'TIME_DIM', -- dimension name
'TIME_HIER', -- name of hierarchy
'LVL_QUARTER', -- name of level
user, -- owner of dimension table
'SELLING_MONTH', -- name of table
'ID_QUARTER', -- name of column
'YR' -- name of parent column
end;
begin
cwm2_olap_table_map.map_dimtbl_hierlevel(
user, -- dimension owner
'TIME_DIM', -- dimension name
'TIME_HIER', -- name of hierarchy
'LVL_MONTH', -- name of level
user, -- owner of dimension table
'SELLING_MONTH', -- name of table
'ID_MONTH', -- name of column
'ID_QUARTER' -- name of parent column
end;
/* creating cube */
begin
cwm2_olap_cube.create_cube(
user, -- cube owner
'Test_Cube', -- name of cube
'Test Cube', -- display name
'Test Cube', -- short description
'Test Cube' -- description
end;
/* mapping ... */
begin
cwm2_olap_table_map.map_dimtbl_hierlevelattr (
user, -- dimension owner
'TIME_DIM', -- name of dimension
'End Date', -- name of dimension attribute
'TIME_HIER', -- name of hierarchy
'LVL_MONTH', -- name of level
'End Date', -- name of level attribute
user, -- owner of table
'SELLING_MONTH', -- name of table
'END_OF_MONTH' -- name of column
end;
begin
cwm2_olap_table_map.map_dimtbl_hierlevelattr (
user, -- dimension owner
'TIME_DIM', -- name of dimension
'End Date', -- name of dimension attribute
'TIME_HIER', -- name of hierarchy
'LVL_QUARTER', -- name of level
'End Date', -- name of level attribute
user, -- owner of table
'SELLING_MONTH', -- name of table
'END_OF_QUARTER' -- name of column
end;
begin
cwm2_olap_table_map.map_dimtbl_hierlevelattr (
user, -- dimension owner
'TIME_DIM', -- name of dimension
'End Date', -- name of dimension attribute
'TIME_HIER', -- name of hierarchy
'LVL_YEAR', -- name of level
'End Date', -- name of level attribute
user, -- owner of table
'SELLING_MONTH', -- name of table
'END_OF_YEAR' -- name of column
end;
/* adding dimension to cube */
begin
cwm2_olap_cube.add_dimension_to_cube (
user, -- owner of cube
'Test_Cube', -- name of cube
user, -- owner of dimension
'CUSTOMER_DIM' -- name of dimension
end;
begin
cwm2_olap_cube.add_dimension_to_cube (
user, -- owner of cube
'Test_Cube', -- name of cube
user, -- owner of dimension
'PRODUCT_DIM' -- name of dimension
end;
begin
cwm2_olap_cube.add_dimension_to_cube (
user, -- owner of cube
'Test_Cube', -- name of cube
user, -- owner of dimension
'TIME_DIM' -- name of dimension
end;
/* creating the measure */
begin
cwm2_olap_measure.create_measure (
user, -- owner of cube
'Test_Cube', -- name of cube
'sold items', -- name of measure
'sold items', -- display name
'sold items', -- short description
'sold items' -- description
end;
/* Creating the join relationship between the fact table and the dimension tables */
begin
cwm2_olap_table_map.map_facttbl_levelkey (
user, -- owner of cube
'Test_Cube', -- name of cube
user, -- owner of fact table
'ITEM_SOLD', -- name of fact table
'LOWESTLEVEL', -- storetype
'DIM:' || user || '.CUSTOMER_DIM/HIER:CUSTOMER_HIER/LVL:LVL_CUSTOMERS_COUNTRY/COL:ID_CUSTOMER;' ||
'DIM:' || user || '.PRODUCT_DIM/HIER:PRODUCT_HIER/LVL:LVL_PRODUCT_CATEGORY/COL:ID_PRODUCT;' ||
'DIM:' || user || '.TIME_DIM/HIER:TIME_HIER/LVL:LVL_MONTH/COL:ID_MONTH;'
end;
/* measure? */
begin
cwm2_olap_table_map.map_facttbl_measure (
user, -- owner of cube
'Test_Cube', -- name of cube
'sold items', -- name of measure
user, -- owner of fact table
'ITEM_SOLD', -- name of fact table
'QTY', -- name of column
'DIM:' || user || '.CUSTOMER_DIM/HIER:CUSTOMER_HIER/LVL:LVL_CUSTOMERS_COUNTRY/COL:ID_CUSTOMER;' ||
'DIM:' || user || '.PRODUCT_DIM/HIER:PRODUCT_HIER/LVL:LVL_PRODUCT_CATEGORY/COL:ID_PRODUCT;' ||
'DIM:' || user || '.TIME_DIM/HIER:TIME_HIER/LVL:LVL_MONTH/COL:ID_MONTH;'
end;
/* validating the cube */
begin
cwm2_olap_validate.validate_cube (
user, -- owner of cube
'Test_Cube' -- name of cube
end;
encapsulate cwm2 apis into objects (IT WAS NOT WORK)
--base class
create or replace type BaseClass as object (
objUser varchar2(255),
objName varchar2(255),
constructor function BaseClass(objUser varchar2, objName varchar2) return self as result,
member function getName return varchar2
INSTANTIABLE NOT FINAL;
--dimension facade
create or replace type DimensionFacade under BaseClass (
hierName varchar2(255),
constructor function DimensionFacade(objUser varchar2, objName varchar2) return self as result,
member procedure setHierarchy(hierName varchar2),
member function addLevel(levelName varchar2, parentLevel varchar2) return boolean,
member function addAttribute(attrName varchar2, levelName varchar2) return boolean,
member function addAttribute(attrName varchar2) return boolean,
member function mapLevel2FactTable(levelName varchar2, tableName varchar2, colName varchar2, parentCol varchar2) return boolean,
member function mapAttribute2DimTable(levelName varchar2, attrName varchar2, dimTable varchar2, colName varchar2) return boolean
INSTANTIABLE FINAL;
--cube facade
create or replace type CubeFacade under BaseClass (
measureName varchar2(255),
constructor function CubeFacade(objUser varchar2, objName varchar2) return self as result,
member procedure addDimension(dimName varchar2),
member procedure setMeasure(measureName varchar2),
member function mapMeasure2FactTable(tableName varchar2, colName varchar2, mapStr varchar2) return boolean
INSTANTIABLE FINAL;
object implementation
prepared: 2006-12-12
author: copper
--base class
create or replace type body BaseClass as
constructor function BaseClass(objUser varchar2, objName varchar2) return self as result
is
begin
self.objUser := objUser;
self.objName := objName;
return;
end;
member function getName return varchar2
is
begin
return self.objUser;
end;
end;
--dimension facade
create or replace type body DimensionFacade as
constructor function DimensionFacade(objUser varchar2, objName varchar2) return self as result
is
begin
self.objUser := objUser;
self.objName := objName;
cwm2_olap_dimension.create_dimension(objUser, objName, objName||' display', objName||' plural', objName||' short des', objName||' description');
dbms_output.put_line('create dimension ok, dimension name:'||objName||',dimension user:'||objUser);
return;
end;
member procedure setHierarchy(hierName varchar2)
is
begin
self.hierName := hierName;
cwm2_olap_hierarchy.create_hierarchy (objUser, objName, hierName, hierName||' display', hierName||' short des', hierName||' description', 'UNSOLVED LEVEL-BASED');
dbms_output.put_line('set hierarchy ok, dimension name:'||objName||',dimension user:'||objUser||',hierarchy name:'||hierName);
end;
member function addLevel(levelName varchar2, parentLevel varchar2) return boolean
is
begin
cwm2_olap_level.create_level(objUser, objName, levelName, levelName||'display', levelName||' plural', levelName||' short des', levelName||' description');
cwm2_olap_level.add_level_to_hierarchy (objUser, objName, hierName, levelName, parentLevel);
dbms_output.put_line('create level and add level to hierarchy ok!');
return true;
end;
member function addAttribute(attrName varchar2, levelName varchar2) return boolean
is
begin
cwm2_olap_level_attribute.create_level_attribute_2 (objUser, objName, attrName, levelName, attrName, attrName||' display', attrName||' short des', attrName||' description', 1);
return true;
end;
member function addAttribute(attrName varchar2) return boolean
is
begin
cwm2_olap_dimension_attribute.create_dimension_attribute_2 (objUser, objName, attrName, attrName||' display', attrName||' short des', attrName||' description', 1);
return true;
end;
member function mapLevel2FactTable(levelName varchar2, tableName varchar2, colName varchar2, parentCol varchar2) return boolean
is
begin
cwm2_olap_table_map.map_dimtbl_hierlevel(objUser, objName, hierName, levelName, objUser, tableName, colName, parentCol);
return true;
end;
member function mapAttribute2DimTable(levelName varchar2, attrName varchar2, dimTable varchar2, colName varchar2) return boolean
is
begin
cwm2_olap_table_map.map_dimtbl_hierlevelattr (objUser, objName, attrName, hierName, levelName, attrName, objUser, dimTable, colName);
return true;
end;
end;
--cube facade
create or replace type body CubeFacade as
constructor function CubeFacade(objUser varchar2, objName varchar2) return self as result
is
begin
self.objUser := objUser;
self.objName := objName;
cwm2_olap_cube.create_cube(objUser, objName, objName||' display', objName||' short des', objName||' description');
return;
end;
member procedure addDimension(dimName varchar2)
is
begin
cwm2_olap_cube.add_dimension_to_cube (objUser, objName, objUser, dimName);
dbms_output.put_line('ok!');
end;
member procedure setMeasure(measureName varchar2)
is
begin
self.measureName := measureName;
cwm2_olap_measure.create_measure (objUser, objName, measureName, measureName||' display', measureName||' short des', measureName||' description');
end;
member function mapMeasure2FactTable(tableName varchar2, colName varchar2, mapStr varchar2) return boolean
is
begin
cwm2_olap_table_map.map_facttbl_levelkey (objUser, objName, objUser, tableName, 'LOWESTLEVEL', mapStr);
cwm2_olap_table_map.map_facttbl_measure (objUser, objName, measureName, objUser, tableName, colName, mapStr);
return true;
end;
end;
--dimension modula using sample
create or replace package DimensionModuleSample as
procedure buildMultidimensionCube;
end;
create or replace package body DimensionModuleSample as
procedure buildMultidimensionCube
is
dimC DimensionFacade; --customer
dimP DimensionFacade; --product
dimT DimensionFacade; --time
cub CubeFacade;
ret boolean;
begin
dbms_output.put_line('start build dimension module!');
dimC := DimensionFacade(user, 'CUSTOMER_DIM');
dimP := DimensionFacade(user, 'PRODUCT_DIM');
dimT := DimensionFacade(user, 'TIME_DIM');
dimC.setHierarchy('CUSTOMER_HIER');
dimP.setHierarchy('PRODUCT_HIER');
dimT.setHierarchy('TIME_HIER');
ret := dimC.addLevel('LVL_ALL_CUSTOMERS', null);
ret := dimC.addLevel('LVL_CUSTOMERS_CONTINENT', 'LVL_ALL_CUSTOMERS');
ret := dimC.addLevel('LVL_CUSTOMERS_COUNTRY', 'LVL_CUSTOMERS_CONTINENT');
ret := dimP.addLevel('LVL_ALL_PRODUCTS', null);
ret := dimP.addLevel('LVL_PRODUCT_CATEGORY', 'LVL_ALL_PRODUCTS');
ret := dimT.addLevel('LVL_YEAR', null);
ret := dimT.addLevel('LVL_QUARTER', 'LVL_YEAR');
ret := dimT.addLevel('LVL_MONTH', 'LVL_QUARTER');
ret := dimT.addAttribute('end date');
ret := dimT.addAttribute('end date', 'LVL_YEAR');
ret := dimT.addAttribute('end date', 'LVL_QUARTER');
ret := dimT.addAttribute('end date', 'LVL_MONTH');
ret := dimC.mapLevel2FactTable('LVL_ALL_CUSTOMERS', 'CUSTOMER', 'ID', null);
ret := dimC.mapLevel2FactTable('LVL_CUSTOMERS_CONTINENT', 'CUSOMTER', 'ID_CONTINENT', 'ID');
ret := dimC.mapLevel2FactTable('LVL_CUSTOMERS_COUNTRY', 'CUSTOMER', 'ID_COUNTRY', 'ID_CONTINENT');
ret := dimP.mapLevel2FactTable('LVL_ALL_PRODUCTS', 'PRODUCT', 'ID', null);
ret := dimP.mapLevel2FactTable('LVL_PRODUCT_CATEGORY', 'PRODUCT', 'ID_CATEGORY', 'ID');
ret := dimT.mapLevel2FactTable('LVL_YEAR', 'SELLING_MONTH', 'YR', null);
ret := dimT.mapLevel2FactTable('LVL_QUARTER', 'SELLING_MONTH', 'ID_QUARTER', 'YR');
ret := dimT.mapLevel2FactTable('LVL_MONTH', 'SELLING_MONTH', 'ID_MONTH', 'ID_QUARTER');
ret := dimT.mapAttribute2DimTable('LVL_YEAR', 'END DATE', 'SELLING_MONTH', 'END_OF_YEAR');
ret := dimT.mapAttribute2DimTable('LVL_QUARTER', 'END DATE', 'SELLING_MONTH', 'END_OF_QUARTER');
ret := dimT.mapAttribute2DimTable('LVL_MONTH', 'END DATE', 'SELLING_MONTH', 'END_OF_MONTH');
cub := CubeFacade(user, 'TEST_CUBE');
cub.addDimension(dimC.getName);
cub.addDimension(dimP.getName);
cub.addDimension(dimT.getName);
cub.setMeasure('SOLID IMEMS');
ret := cub.mapMeasure2FactTable('ITEM_SOLD', 'QTY',
'DIM:' || user || '.CUSTOMER_DIM/HIER:CUSTOMER_HIER/LVL:LVL_CUSTOMERS_COUNTRY/COL:ID_CUSTOMER;' ||
'DIM:' || user || '.PRODUCT_DIM/HIER:PRODUCT_HIER/LVL:LVL_PRODUCT_CATEGORY/COL:ID_PRODUCT;' ||
'DIM:' || user || '.TIME_DIM/HIER:TIME_HIER/LVL:LVL_MONTH/COL:ID_MONTH;');
exception
when OTHERS then
dbms_output.put_line('get error!');
end;
end;
--test codes
begin
DimensionModuleSample.buildMultidimensionCube;
end;
the error information is:
14:23:05 ORA-06510: unhandled user-defined exception
14:23:05 ORA-06512: "OLAPSYS.CWM2_OLAP_UTILITY", line1660
14:23:05 ORA-01403: no data found
14:23:05 ORA-06512: "OLAPSYS.CWM2_OLAP_LEVEL", line28
14:23:05 ORA-06512: "OLAPSYS.CWM2_OLAP_LEVEL", line57
14:23:05 ORA-06512: "OLAPSYS.CWM2_OLAP_LEVEL", line456
14:23:05 ORA-06512: line2Hi,
Please see if these documents help.
Note: 367607.1 - FDPSTP Failed Due to ORA-01861: Literal Does Not Match Format String
Note: 370272.1 - not able to run the report set having unsupported date format of fnd-date4
Note: 376034.1 - How to Handle New Date Formats in SQL*Plus and PL/SQL Procedures?
Regards,
Hussein -
Using IN in a direct SQL statement.
Peter,
I tried a couple of things to no avail. The simplest
one is like this:
myType.SetValue('\'CI\',\'NG\',\'MS\'');
It works if I do
myType.SetValue('\'CI\'');
Same is valid if myType is declared as a String.
Hi,
What does the string in myType look like? You should
be careful with ' and \ as they are used by Forte. I
suggest you post a sample of the myType's value.
Regards,
Peter Sham.--- Rumen Georgiev <[email protected]> wrote:
Hi folks,
I have a problem when executing direct SELECT
statement against Oracle 7.4, something like that:
SQL SELECT ..... INTO .... FROM ..... WHERE .....
AND
TYPE IN :myType ON SESSION .......
myType is TextData containing a list of possible
values separated by commas. myType is set at run
time.
When executed through SQL*Plus the result is O.K..
When executed through Forte it doesn't return
anything. It seems that eigther Forte or Oracle
disregards the commas and treats myType as it will
with =,>,<. What makes me think so is that when
myType
holds single value it works. It fails as soon as I
concatenate one more value from the list. Same
happens
when using cursor. I didn't try it with DBSession
methods but I assume the result will be the same. I
can't use EXECUTE EMMEDIATE because I expect result
set(INTO). So far the only way I can think of is a
WHILE loop for every single value from the list.
Any ideas,comments or workarounds?
Thank's in advance.
Rumen__________________________________________________
Do You Yahoo!?
Bid and sell for free at http://auctions.yahoo.comThe primary key is only necessary for the Form (for managing updates). Maybe you can create an Interactive Report. There you can set that a row is uniquely defined by rowid.
Or define a primary key constraint on your view...
HTH
Roel
Maybe you are looking for
-
Training and Event Management: Relationships
Hi TEM Experts, What are the appropriate steps, or best practice, if the event we want to add is a one off, and wasn't really scheduled? Do we need to go through the entire PSV1, PV12, etc. process just to add a one off event so that it shows up on t
-
Cannot install WXP on my Qosmio F50-113
Hi to all (I cant speak good English) My problem is if I want to install win xp on my Qosmio F50-113 I get a blue screen. I have tried to integrate the drivers (the SATA drivers) but it could not helped me. Can anybody help me? Please (jayjay?! schre
-
Missing and Moved Page Numbers?
I'm having a problem losing folios; I have a 300 page book where all of the page numbers are centered horizontally.My editor ran a final spell-check and 'saved as,' yet in this new document, on pages where I have over-rode the Master page, the pages
-
Where is the xboxdrv configuration file?
I'm using an Xbox 360 Afterglow wired USB controller. I've got xboxdrv installed and I got it working: Left joystick: mouse Right joystick seems to do nothing D-Pad seems to do nothing A is left-click B is middle-click X is right-click Not sure what
-
T510 trackpad acting odd...
I've got a T510 and the trackpad does this strange thing where it's acting as if the button is depressed even when it's not. When you move the cursor around on the screen just by moving your finger, not touching any buttons, it will draw little boxes