Choosing particular columns using XSU PL/SQL API
Hi ya,
I have another query regarding XSU PL/SQL API please
If I dont want to choose all columns but choose particular columns
in my select clause,how shud I do this.??
I havent used XSU before,so please forgive my ignorance.
declare
queryCtx DBMS_XMLQuery.ctxType;
result CLOB;
begin
-- set the query context.
queryCtx := DBMS_XMLQuery.newContext('select CHOOSE CERTAIN COLS ONLY from <TABLE>');
result := DBMS_XMLQuery.getXML(queryCtx); -- get the result
DBMS_XMLQuery.closeContext(queryCtx); -- close the query handle;
end;
Can anyone tell me how to select particulat columnsor some one suggested(Mr Kishore) to use a view?
I dont want to use 'Select * from <Table>'
Help really appreciated.
Rgds
This is a duplicate of this posting Creating a View to check for 2 conditions.. This is a particularly heinous case because some of our finest minds have already responded in that thread.
Lose ten culture points.
Regards, APC
Similar Messages
-
Creating Views using XSU PL/SQL API.Urgent please.
Folks,
I need some help in creating a View.
I am using XSU PL/SQL to generate an XML Document.
I have a table (SDI) with 2 cols CMPY_NUM and CPTY_BORG_NUM.
If the values in these 2 cols are equal then the xml
value to be returned is 'OURS' else return 'THEIRS'.
How do I Create this View please?
The XSU PL/SQL I am using to generate the XML is:
declare
queryCtx DBMS_XMLquery.ctxType;
xmlResult CLOB;
begin
queryCtx := DBMS_XMLQuery.newContext('select CMPY_NUM,CPTY_BORG_NUM from SDI');
xmlResult := DBMS_XMLQuery.getXML(queryCtx);
DBMS_XMLQuery.closeContext(queryCtx); -- you must close the query handle..
end;
Output
<?xml version='1.0'?>
<ROWSET>
<ROW num="1">
<CMPY_NUM>1</CMPY_NUM>
<CPTY_BORG_NUM>2/CPTY_BORG_NUM>
</ROW>
<!-- additional rows ... -->
</ROWSET>
Please can any one tell me how to create a view that will be used in place
of the select statement,and returns back OURS or THEIRS
Create View XML ASThis is a duplicate of this posting Creating a View to check for 2 conditions.. This is a particularly heinous case because some of our finest minds have already responded in that thread.
Lose ten culture points.
Regards, APC -
Creating Object views using XSU PL/SQL.Please SEE.
Hi,
I am presently using XSU PL/SQL utility with Oracle 9i and using the
DBMS_XMLQuery.newContext(<My Select clause goes here>,and the
DBMS_XMLQuery.getXML()which generates an XML document.
My query is:
I have 2 tables (One master and the other detail table.).
Table : DI_Master
di_num
00001
Table: DI_Details
di_num di_act
00001 ABCD
00001 ANCF
00001 IOPP
Now the XML I'd like is :
<di_num>00001</di_num>
<di_act>
<val>ABCD</val>
<val>ANCF</val>
<val>IOPP</val>
</di_act>
Do I need to create object tables for this,insert data into object tables
and then read this table? It will become an extremely tedious process
I guess an OBJECT view can do what I want.Can anyone please tell me how
to write an object view for the 2 tables please and the get the output as
desired.?Supposing you have further
nesting of the tables.Then how will you go about doing that.You can have multiple levels of CURSOR expressions (see an example below, not a real-life example, but illustrates the point).
SQL> set long 4000
SQL> select dbms_xmlquery.getXML('select deptno,' ||
2 'cursor(select empno, cursor(select losal, hisal from salgrade) salgrades '||
3 'from emp e where e.deptno = d.deptno and rownum < 3) EMPLOYEES ' ||
4 'from dept d where d.deptno = 10')
5 FROM DUAL;
DBMS_XMLQUERY.GETXML('SELECTDEPTNO,'||'CURSOR(SELECTEMPNO,CURSOR(SELECTLOSAL,HIS
<?xml version = '1.0'?>
<ROWSET>
<ROW num="1">
<DEPTNO>10</DEPTNO>
<EMPLOYEES>
<EMPLOYEES_ROW num="1">
<EMPNO>7782</EMPNO>
<SALGRADES>
<SALGRADES_ROW num="1">
<LOSAL>700</LOSAL>
<HISAL>1200</HISAL>
</SALGRADES_ROW>
<SALGRADES_ROW num="2">
<LOSAL>1201</LOSAL>
<HISAL>1400</HISAL>
</SALGRADES_ROW>
<SALGRADES_ROW num="3">
<LOSAL>1401</LOSAL>
<HISAL>2000</HISAL>
</SALGRADES_ROW>
<SALGRADES_ROW num="4">
<LOSAL>2001</LOSAL>
<HISAL>3000</HISAL>
</SALGRADES_ROW>
<SALGRADES_ROW num="5">
<LOSAL>3001</LOSAL>
<HISAL>9999</HISAL>
</SALGRADES_ROW>
</SALGRADES>
</EMPLOYEES_ROW>
<EMPLOYEES_ROW num="2">
<EMPNO>7839</EMPNO>
<SALGRADES>
<SALGRADES_ROW num="1">
<LOSAL>700</LOSAL>
<HISAL>1200</HISAL>
</SALGRADES_ROW>
<SALGRADES_ROW num="2">
<LOSAL>1201</LOSAL>
<HISAL>1400</HISAL>
</SALGRADES_ROW>
<SALGRADES_ROW num="3">
<LOSAL>1401</LOSAL>
<HISAL>2000</HISAL>
</SALGRADES_ROW>
<SALGRADES_ROW num="4">
<LOSAL>2001</LOSAL>
<HISAL>3000</HISAL>
</SALGRADES_ROW>
<SALGRADES_ROW num="5">
<LOSAL>3001</LOSAL>
<HISAL>9999</HISAL>
</SALGRADES_ROW>
</SALGRADES>
</EMPLOYEES_ROW>
</EMPLOYEES>
</ROW>
</ROWSET>
1 row selected.
SQL>
Also,isnt it a better option to create a VIEW of the
Select clause and pass a view to the select clause? At the end of the day, you could use whatever you feel comfortable with, provided that it produces your expected output and looks clean. We are just giving you the ideas, how you implement it actually in your situation, depends upon a lot of factors, that only you know about. -
How to use DBFS PL/SQL API
Hi guys,
I'm re-posting this question to see if anyone can help me out. I am trying to use the DBFS PL/SQL API to manipulate files stored in DBFS.
Environment details:
Windows 7 or OEL 5.5 (I have tried both platforms)
Database: Oracle DB EE 11.2.0.2
IDE: SQLDeveloper on Windows 7
I have two users, DBFS_USER who owns the DBFS store and MYUSER who connects to the store to manipulate files using the DBFS PL/SQL API.
Creation scripts:
connect / as sysdba;
CREATE TABLESPACE dbfs_ts DATAFILE 'D:\oracle\oradata\orcl\dbfs01.dbf' SIZE 1M AUTOEXTEND ON NEXT 1M;
-- create users
create user dbfs_user identified by dbfs_user default tablespace dbfs_ts quota unlimited on dbfs_ts;
create myuser identified by myuser;
-- grant role
GRANT CREATE SESSION, RESOURCE, CREATE VIEW, DBFS_ROLE, CREATE TABLE TO dbfs_user;
GRANT CREATE SESSION, RESOURCE, CREATE VIEW, DBFS_ROLE, CREATE TABLE TO myuser;
-- create file system (as DBFS_USER)
connect dbfs_user/dbfs_user;
exec dbms_dbfs_sfs.createFilesystem('STAGING_AREA_FS');
exec dbms_dbfs_content.registerStore('STAGING_AREA_FS', 'posix', 'DBMS_DBFS_SFS');
exec dbms_dbfs_content.mountStore('STAGING_AREA_FS', 'staging_area');
commit;
-- export store STAGING_AREA_FS (as DBFS_USER)
exec dbms_dbfs_sfs.exportFilesystem('STAGING_AREA_FS');
-- check table names (as MYUSER)
connect myuser/myuser;
-- should see nothing (no mounts)
select * from table(dbms_dbfs_content.listMounts);
-- note down the table_name
select * from table(dbms_dbfs_sfs.listTables);
-- mount as MYUSER (example with table_name SFS$_FST_32)
exec dbms_dbfs_sfs.registerFilesystem('MYUSER_FS', 'DBFS_USER', 'SFS$_FST_32');
exec dbms_dbfs_content.registerStore('MYUSER_FS', 'posix', 'DBMS_DBFS_SFS');
exec dbms_dbfs_content.mountStore('MYUSER_FS', 'staging_area');
commit;
-- check mount (as MYUSER)
select * from table(dbms_dbfs_content.listMounts);
select pathname from dbfs_content;
CREATE STORED PROC (as MYUSER)
CREATE OR REPLACE PACKAGE MYUSER_PKG IS
Function CreateDirectory
(P_File_Path IN VARCHAR2,
P_ErrMsg OUT VARCHAR2)
return Number;
END MYUSER_PKG ;
CREATE OR REPLACE PACKAGE BODY MYUSER_PKG IS
Function CreateDirectory
(P_File_Path IN VARCHAR2,
P_ErrMsg OUT VARCHAR2)
return Number
IS
l_Return NUMBER;
l_props DBMS_DBFS_CONTENT.PROPERTIES_T;
BEGIN
l_Return := 0;
DBMS_DBFS_CONTENT.createDirectory (
path => P_File_Path,
properties => l_props);
RETURN l_Return;
EXCEPTION
WHEN OTHERS THEN
l_Return := NVL(SQLCODE, -1);
P_ErrMsg := SQLERRM;
RETURN l_Return;
END CreateDirectory;
END MYUSER_PKG ;
When compiling the package, I am getting this error:
Error(9,11): PLS-00201: identifier 'DBMS_DBFS_CONTENT' must be declared
Error(9,11): PL/SQL: Item ignored
Error(13,3): PL/SQL: Statement ignored
Error(15,19): PLS-00320: the declaration of the type of this expression is incomplete or malformed
How do I solve the problem in the error message? I'm not a DB expert. I used this reference documentation: http://download.oracle.com/docs/cd/E11882_01/appdev.112/e18294/adlob_client.htm#CIHDEJAA
Thanks in advance.
CappaYou need to grant directly the privileges from DBFS_ROLE because roles are not enabled in stored PL/SQL:
SQL> select* from v$version;
BANNER
Oracle Database 11g Enterprise Edition Release 11.2.0.2.0 - 64bit Production
PL/SQL Release 11.2.0.2.0 - Production
CORE 11.2.0.2.0 Production
TNS for Solaris: Version 11.2.0.2.0 - Production
NLSRTL Version 11.2.0.2.0 - Production
SQL> show user
USER is "SYS"
SQL>
SQL> create user myuser identified by myuser;
User created.
SQL> GRANT CREATE SESSION, RESOURCE, CREATE VIEW, DBFS_ROLE, CREATE TABLE TO myuser;
Grant succeeded.
SQL>
SQL> begin
2 for x in (select privilege, table_name
3 from dba_tab_privs
4 where grantee='DBFS_ROLE')
5 loop
6 execute immediate 'grant ' || x.privilege || ' on ' || x.table_name
7 || ' to myuser ';
8 end loop;
9 end;
10 /
begin
ERROR at line 1:
ORA-22812: cannot reference nested table column's storage table
ORA-06512: at line 6
SQL>
SQL> connect myuser/myuser
Connected.
SQL>
SQL> CREATE OR REPLACE PACKAGE MYUSER_PKG IS
2 Function CreateDirectory
3 (P_File_Path IN VARCHAR2,
4 P_ErrMsg OUT VARCHAR2)
5 return Number;
6 END MYUSER_PKG ;
7 /
Package created.
SQL> show errors
No errors.
SQL>
SQL> CREATE OR REPLACE PACKAGE BODY MYUSER_PKG IS
2 Function CreateDirectory
3 (P_File_Path IN VARCHAR2,
4 P_ErrMsg OUT VARCHAR2)
5 return Number
6 IS
7 l_Return NUMBER;
8 l_props DBMS_DBFS_CONTENT.PROPERTIES_T;
9 BEGIN
10 l_Return := 0;
11 DBMS_DBFS_CONTENT.createDirectory (
12 path => P_File_Path,
13 properties => l_props);
14 RETURN l_Return;
15 EXCEPTION
16 WHEN OTHERS THEN
17 l_Return := NVL(SQLCODE, -1);
18 P_ErrMsg := SQLERRM;
19 RETURN l_Return;
20 END CreateDirectory;
21 END MYUSER_PKG ;
22 /
Package body created.
SQL> show errors
No errors.You would need to check why some GRANT statement fails if you have other issue with other piece of code. -
Encoding and XSUtility PL/SQL API
Is it possible to specify the encoding
when generating an XML file from the database
with getXML function from the PL/SQL API?
I'm using the XSU PL/SQL API to generate
XML file. When I parse a file containing non-UTF8 characters, I get an error message:
invalid UTF8 encoding. But everything works
fine if I use the attribute
encoding='ISO8859-1' with the <?xml> tag.
However, I dont how to specify such attribute
when I generate XML from database using the getXML function.
Any ideas?Hello,
Here is the solution.
-- Create and setup MOD_ARRAY for list of modifications
emp_array := DBMS_LDAP.create_mod_array(1);
emp_vals(1) := 'access to attr=(*) by group="name=Admin,cn=Roles,cn=Groups,dc=com,dc=oracle,dc=us" BindMode=(Simple) (read,write,search,compare) ';
-- Populate MOD_ARRAY with Modifications to value of 'title' attribute
DBMS_LDAP.populate_mod_array(emp_array,DBMS_LDAP.MOD_ADD,'orclaci',emp_vals);
-- Free attribute array (emp_array)
DBMS_LDAP.free_mod_array(emp_array);
-- Unbind from ldap directory
retval := DBMS_LDAP.unbind_s(emp_session);
Cheers
HA -
PL/SQL API + Defaulting Rules in OM
Hi,
I want to default custom rule in Sales Order from whenever I select Item. After selecting item from the sales order from, it should populate Warehouse value in Shipping tab. I am using custom PL/SQL API option. I wrote one function and kept in package. I was disabled all defaulting rules. Now If I select Item in sales order form, I am not getting warehouse value.
The steps are:
Step 1. Select Warehouse attribute and define defaulting rule
Application: Order Management
Entry: Order Line
Select Attribute as Warehouse
Click on Defaulting Rules
Step 2: Define Defaulting Sourcing Rule
Select Source type as PL/SQL API.
In the Defaulting Source/Value field give Package Name and Function Name.
Open Catalog Groups window from the below path: Setup Items Catalog Groups
Specify Name and Description for Catalog Group
Click on Details button.
Step 3: Create Catalog Group
Step 4: Specify Descriptive Elements for the Item Catalog Group
Step 5: Code preparation
-- My Custom Code
Create or replace FUNCTION custom_default_rule
RETURN VARCHAR2
AS
l_line_type_rec oe_order_cache.line_type_rec_type;
CURSOR cus_l
IS
SELECT a.organization_code, b.element_name, b.element_value
FROM mtl_parameters a,
mtl_descr_element_values b,
mtl_system_items_b c
WHERE b.inventory_item_id = c.inventory_item_id
AND a.organization_id = c.organization_id
AND a.organization_id = c.organization_id
AND c.inventory_item_id = 12924
GROUP BY a.organization_code, b.element_name, b.element_value
ORDER BY a.organization_code, b.element_name, b.element_value;
BEGIN
l_line_type_rec := oe_order_cache.load_line_type
(ont_line_def_hdlr.g_record.line_type_id);
FOR cur_rec IN cus_l
LOOP
IF cur_rec.element_name IN
('Frequency',
'Emission Norms',
'Voltage',
'Duty Rating',
'Phase',
'Product'
AND cur_rec.element_value IN
('50', '', '230', 'Medium', 'Single', 'QSK60')
THEN
RETURN cur_rec.organization_code;
ELSIF cur_rec.element_name IN
('Frequency',
'Emission Norms',
'Voltage',
'Duty Rating',
'Phase',
'Product'
AND cur_rec.element_value IN
('50', '', '230', 'Medium', 'Three', 'QSK15')
THEN
RETURN cur_rec.organization_code;
ELSIF cur_rec.element_name IN
('Frequency',
'Emission Norms',
'Voltage',
'Duty Rating',
'Phase',
'Productfamily'
AND cur_rec.element_value IN
('50', '', '230', 'Medium', 'Single', 'DQK50')
THEN
RETURN cur_rec.organization_code;
END IF;
END LOOP;
EXCEPTION
WHEN OTHERS
THEN
IF oe_msg_pub.check_msg_level (oe_msg_pub.g_msg_lvl_unexp_error)
THEN
oe_msg_pub.add_exc_msg ('OE_Default_PVT', 'CUSTOM_DEFAULT_RULE');
END IF;
RAISE fnd_api.g_exc_unexpected_error;
END custom_default_rule;
Step 6: Create a Sales Order (Order Returns Sales Orders)
Select Customer and Order Type and select Line Items Tab.
Select Item from the Ordered Item Field. Press Tab.
After pressing tab in the Shipping Tab Warehouse value Should be populated. But it is not working.
Can anyone guide me in this.
It is very urgent.
If possible, Please send u r details to my official id: [email protected]
Thanks in Advance,
sateeshSateesh,
This is working fine for me here:
CREATE OR REPLACE PACKAGE xx_def_wh
AS
FUNCTION custom_default_rule (p_database_object_name IN VARCHAR2, p_attribute_code IN VARCHAR2)
RETURN NUMBER;
END;
CREATE OR REPLACE PACKAGE BODY xx_def_wh
AS
FUNCTION custom_default_rule (p_database_object_name IN VARCHAR2, p_attribute_code IN VARCHAR2)
RETURN NUMBER
AS
l_line_type_rec oe_order_cache.line_type_rec_type;
l_item_id NUMBER;
CURSOR cus_l(p_item_id in number)
IS
SELECT a.organization_id, b.element_name, b.element_value
FROM mtl_parameters a, mtl_descr_element_values b, mtl_system_items_b c
WHERE b.inventory_item_id = c.inventory_item_id
AND a.organization_id = c.organization_id
AND a.organization_id = c.organization_id
AND c.inventory_item_id = p_item_id
and a.organization_id<>a.master_organization_id
ORDER BY a.organization_id;
BEGIN
l_line_type_rec := oe_order_cache.load_line_type (ont_line_def_hdlr.g_record.line_type_id);
l_item_id:= ONT_LINE_DEF_HDLR.g_record.inventory_item_id;
FOR cur_rec IN cus_l(l_item_id)
LOOP
IF cur_rec.element_name IN ('Frequency', 'Emission Norms', 'Voltage', 'Duty Rating', 'Phase', 'Product')
AND cur_rec.element_value IN ('50', '', '230', 'Medium', 'Single', 'QSK60')
THEN
RETURN cur_rec.organization_id;
ELSIF cur_rec.element_name IN ('Frequency', 'Emission Norms', 'Voltage', 'Duty Rating', 'Phase', 'Product')
AND cur_rec.element_value IN ('50', '', '230', 'Medium', 'Three', 'QSK15')
THEN
RETURN cur_rec.organization_id;
ELSIF cur_rec.element_name IN ('Frequency', 'Emission Norms', 'Voltage', 'Duty Rating', 'Phase', 'Productfamily')
AND cur_rec.element_value IN ('50', '', '230', 'Medium', 'Single', 'DQK50')
THEN
RETURN cur_rec.organization_id;
END IF;
END LOOP;
EXCEPTION
WHEN OTHERS
THEN
IF oe_msg_pub.check_msg_level (oe_msg_pub.g_msg_lvl_unexp_error)
THEN
oe_msg_pub.add_exc_msg ('OE_Default_PVT', 'CUSTOM_DEFAULT_RULE');
END IF;
RAISE fnd_api.g_exc_unexpected_error;
END custom_default_rule;
END;
Thanks
Nagamohan -
Resolve column names in a sql Query
Hi Folks,
I’m upgrading an application and there are database columns that have major changes that could affect production reports. I would like to survey v$SQL for a few days to see if these columns are affected. Here’s the problem.
Looking at a SQL query to determine which columns are used is not nearly as easy as it sounds. Are there any oracle functions or 3rd party tools that can be used to list the columns used by a sql query? (this gets extremely tricky when subqueries become involved)
For instance.
select
name, b.dep_id, employee_id
From emp a
Inner join v_department b on a.dep_id=b.dep_id
Columns used:+
Emp.name+
Departments.dep_id (under the view)+
Emp.employee_id+
Emp.dep_id (from the join)+If you're on > 10g, you can use dbms_xplan with "all" option.
It shows "column projection information" which is exactly what you want.
UKJA@ukja102> set serveroutput on
UKJA@ukja102>
UKJA@ukja102> drop table t1 purge;
Table dropped.
Elapsed: 00:00:00.03
UKJA@ukja102> create table t1(c1 int, c2 int);
Table created.
Elapsed: 00:00:00.03
UKJA@ukja102>
UKJA@ukja102> explain plan for
2 select
3 t1.c1, t1.c2, v.cnt
4 from t1,
5 (select /*+ no_merge */ c1, count(*) as cnt
6 from t1
7 group by c1) v
8 where
9 t1.c1 = v.c1
10 ;
Explained.
Elapsed: 00:00:00.01
UKJA@ukja102>
UKJA@ukja102> @plan_all
UKJA@ukja102> select * from table(dbms_xplan.display(null,null,'all'))
2 /
PLAN_TABLE_OUTPUT
Plan hash value: 536125944
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
| 0 | SELECT STATEMENT | | 1 | 52 | 6 (34)| 00:00:01 |
|* 1 | HASH JOIN | | 1 | 52 | 6 (34)| 00:00:01 |
| 2 | TABLE ACCESS FULL | T1 | 1 | 26 | 2 (0)| 00:00:01 |
| 3 | VIEW | | 1 | 26 | 3 (34)| 00:00:01 |
| 4 | HASH GROUP BY | | 1 | 13 | 3 (34)| 00:00:01 |
| 5 | TABLE ACCESS FULL| T1 | 1 | 13 | 2 (0)| 00:00:01 |
Query Block Name / Object Alias (identified by operation id):
1 - SEL$1
2 - SEL$1 / T1@SEL$1
3 - SEL$2 / V@SEL$1
4 - SEL$2
5 - SEL$2 / T1@SEL$2
Predicate Information (identified by operation id):
1 - access("T1"."C1"="V"."C1")
Column Projection Information (identified by operation id):
1 - (#keys=1) "T1"."C1"[NUMBER,22], "T1"."C2"[NUMBER,22],
"V"."CNT"[NUMBER,22]
2 - "T1"."C1"[NUMBER,22], "T1"."C2"[NUMBER,22]
3 - "V"."C1"[NUMBER,22], "V"."CNT"[NUMBER,22]
4 - (#keys=1) "C1"[NUMBER,22], COUNT(*)[22]
5 - "C1"[NUMBER,22]
Note
- dynamic sampling used for this statement
40 rows selected.
Elapsed: 00:00:00.01
UKJA@ukja102>
UKJA@ukja102>
UKJA@ukja102> @end
UKJA@ukja102> set echo offDion Cho -
How to update a column using hibernate
how to update a particular column using hibernate..
iam using oracle databaseI think you didn't get the point. This is a generic Java forum... not a Hibernate forum.
-
Problem inserting value in CLOB column from an XML file using XSU
Hi,
When I try to insert CLOB value into Oracle9i database from an XML document using XSU, I get an exception as below.
09:37:32,392 ERROR [STDERR] oracle.xml.sql.OracleXMLSQLException: 'java.sql.SQLException: ORA-03237: Initial Extent of specified size cannot be allocated
ORA-06512: at "SYS.DBMS_LOB", line 395
ORA-06512: at line 1
' encountered during processing ROW element 0. All prior XML row changes were rolled back. in the XML document.
All Element tags in XML doc. is mapped to columns in the database. One of the table columns is CLOB. That is the one that gives the above exception. Here is the xml...
ID - is autogenerated value.
<?xml version="1.0" ?>
<ROWSET>
<ROW num="1">
<ID></ID>
<SEQ>
GCATAGTTGTTATGAAGAAATGGAAGAAAAATGCACTCAAAGTTGGGCTGTCAGGCTGTCTGGGGCTGAATTCTGGTGTGACAGTGTGATGAAGCCATCTTTGAGCCTAAATTTGATAATGAGCCAGTCATGATCTGGTTGTGATTACTATAACAAGATTAAATCTGAATAAGAGAGCCACAACTTCTTTAAAGACAGATTGTCAAGTCATTACATGGAAGAGGGAGATTGCTCCTTTGTAAATCAGGCTGTCAGGCCAACTGAATGAAGGACGTCATTGTACAGTAACCTGATGAAGATCAGATCAACCGCTCACCTCGCCG
</SEQ>
</ROW>
</ROWSET>
Can anyone identify what's the problem.. and suggest a solution for this..?
Thanks in advance..
VijiWould you please specify the XDK verison and database version?
-
I have a region on a page that contains content items. These are PDF files that were uploaded. I want to know how I can programmatically change the description.
I have been looking at both set_attributes() and modify_item_post_upload() functions in the API. Is this my best option, or is there an alternative.
I have been leaning towards calling modify_item_post_upload(), but have a question on the parameters.
I can get p_master_item_id, but what is p_item_id?
I would like to call the method like this:
declare
l_masterid number;
l_display_name varchar2(100);
begin
l_masterid := <some number);
l_display_name := 'New Name for item';
modify_item_post_upload(
p_master_item_id => l_masterid,
p_display_name => l_display_name
end;
So questions are:
1. What modifications do I need for a simple call to change an items name?
2. What additional functions/procedures do I need to call so the display gets updated with the new information? Do I have to clear the cache suing wxutils, or can I just call wwpro_api_invalidation.execute_cache_invalidation; ?
If you want the "rest of the story" - I created a web front end in JDeveloper that allows specific end users to login, upload files, and delete items for a specific portal page containing content items. One of the common mistakes is a misspelling of the display name by the end user. So instead of deleting an item, then re-adding an item, the end user would like to edit the display name for just the item that has the misspelling. I have set this up in JDeveloper with an edit screen that contains just the display name. Now I need a function/procedure that I can call from the application module that will update just the display name for this particular item. I have already coded an ADF model that uses the search_item and converts the results into a result_set, and use that to create a View Object in the ADF for JDeveloper to use. Now to finish this user request, I just need to figure out the PL/SQL API part for modifying a display name. The item still needs to keep it's reference to the uploaded PDF file.
Thanks, KenVery nice! I like the code example. In looking at needing to change only the title of the item, I created a procedure that calls set_attribute. Here is the code:
create or replace
procedure update_newslinearchive_item (p_masterid in number, p_displayname in varchar2) as
cursor items_cur(p_id IN NUMBER) is
select * from wwsbr_all_items
where masterid = p_id
and caid = <pagegroup>
and active = 1
and is_current_version = 1
and language = wwctx_api.get_nls_language;
items_rec wwsbr_all_items%rowtype;
begin
dbms_output.put_line('masterid = ' || to_char(p_masterid));
dbms_output.put_line('display_name = ' || p_displayname);
-- Login to the portal for access to function calls
wwctx_api.set_context('<username>','<password>');
-- Verify that the item to be deleted is in the items table
open items_cur(p_masterid);
fetch items_cur into items_rec;
if items_cur%found then
dbms_output.put_line('record found');
wwsbr_api.set_attribute(
p_site_id => items_rec.caid,
p_thing_id => items_rec.id,
p_attribute_site_id => wwsbr_api.SHARED_OBJECTS,
p_attribute_id => wwsbr_api.ATTRIBUTE_TITLE,
p_attribute_value => p_displayname
wwpro_api_invalidation.execute_cache_invalidation;
dbms_output.put_line('Clearing Cache');
-- Now clear the web-cache
wxvutil.invalidate_reset;
wxvutil.invalidate_uri('<server:port/path/to/page>,0,null);
wxvutil.invalidate_exec('<server>',4001,'<webcache password>');
else
dbms_output.put_line('record NOT found');
end if;
close items_cur;
exception
when others then
dbms_output.put_line('SQLCODE = ' || SQLCODE);
dbms_output.put_line('SQLERRM = ' || SUBSTR(SQLERRM,1,200));
if items_cur%isopen then
close items_cur;
end if;
end update_newslinearchive_item;
Thank you for the example for modify_item_post_upload!
Ken -
How to test if there are duplicate values in a column using PL/SQL
Hello,
I want to be able to test if there are duplicate values (VARCHAR2) in a particular column of the database using PL/SQL.
Thanks
DouglasIf I have understood your requirement, then you are asking for a query like following.
Select column_name from Tbl_name
group by column_name
having count(*) > 1; -
XDK APIs (C/C++/Java) and tools can also be used with MS SQL Server
I want to know if XDK APIs (Java or C/C++ APIs especially) and tools can be used with MS SQL Server or not?
I want to write a simple application that updates XML ( acordXML used for insurance) document into SQL Server tables. Of course I am assuming to transform into appropriate XSU APIs format.No. Use SQLXML instead on a SQL Server.
-
How to use the EBS PL/SQL API from outside PL/SQL
Hi,
our attempts to call the stored procedures/functions of the EBS PL/SQL API via JDBC revealed the following issues:
1. Logical values cannot be exchanged through boolean parameters as the OCI has no notion of this type. Instead we need to write PL/SQL wrappers converting boolean to integer and vice versa. Is that true or are we missing something?
2. Complex values cannot be exchanged through record types as only PL/SQL code has a notion of this type. Instead we need to write PL/SQL wrappers converting record values to object type values. Is that true or are we missing something?
3. Types must be defined outside of packages, i.e. in the schema, for whatever reason. Instead we need to write PL/SQL wrappers converting values of types defined in packages to values of types defined in the schema. Is that true or are we missing something?
4. It is possible to let functions return tables so the results can be queried using SELECT * FROM TABLE. Such functions are called "table functions". Is there something similar for the other direction, i.e. is it possible to call a stored procedure and pass in a table value through an sql INSERT statement?
5. Do we really have to write all those wrapper routines on our own or is there a PL/SQL library providing such? If not, is there some kind of code generation facility that can generate such wrappers?
Thanks and Regards,
KonradHi Helios,
I belive its better to move your issue on Forum Home » Database » SQL and PL/SQL which you can get more quick responseYou are probably right! I was thinking about a different forum but I did not see this one. I just posted the question there...
Still, if somebody has an idea here as well, just let me know ;-)
Konrad -
Function or pseudo-column 'DECODE' may be used inside a SQL statement only
Hi everyone!
I got the error in the subject concernig the follow piece of sql code
+ v_str_sql_body :=
v_str_sql_body || ' and cod_entita ='
|| decode(cur.cod_entita_a,str_all,cur_ent.cod_entita,cur.cod_entita_a);
execute immediate v_str_sql_body; +
I can't understand what's the problem with it.
Can anyone help me to find the error?
Thank you in advance!
Samuel
Edited by: 996508 on 27-mar-2013 5.29Hi, Samuel,
Welcome to the forum!
996508 wrote:
Hi everyone!
I got the error in the subject concernig the follow piece of sql code
+ v_str_sql_body :=
v_str_sql_body || ' and cod_entita ='
|| decode(cur.cod_entita_a,str_all,cur_ent.cod_entita,cur.cod_entita_a);
execute immediate v_str_sql_body; +
I can't understand what's the problem with it.Sorry, I can't understand what you're trying to do.
Whenever you have a problem, post a complete script that people can run to re-create the problem and test their ideas. Include your complete PL/SQL code (if the problem involves PL/SQL) including code to call your procedure, a little sample data (CREATE TABLE and INSERT statements) for any tables involved, and the results you want the given sample data.
Always say which version of Oracle you have (e.g., 11.2.0.3.0).
See the forum FAQ {message:id=9360003}
Can anyone help me to find the error?As the error message says, you can only use DECODE in a SQL statement. That is:
v_str_body := v_str_body
|| ' and cod_entita = '
|| DECODE (...);is always an error, no matter what ... stands for.
Perhaps you meant to have the DECODE inside the string literal.
If not, then (depending on your version) you can use CASE instead of DECODE:
v_str_body := v_str_body
|| ' and cod_entita = '
|| CASE cur.cod_entita_a
WHEN str_all THEN cur_ent.cod_entita
ELSE cur.cod_entita_a
END;Anything that DECODE can do, CASE can do, too.
DECODE is sometimes a little simpler than CASE to use, but only a little. It is never faster than CASE.
CASE is sometimes much, much simpler to use than DECODE, and sometimes much faster, too.
I won't say never use DECODE; but I will say rarely use DECODE. Use CASE instead, unless you have a specific reason why DECODE is better in that particular situation.
In PL/SQL, you can also use IF ... THEN ... ELSE in places where you might want to use DECODE or CASE.
For example:
v_str_body := v_str_body
|| ' and cod_entita = ';
IF cur.cod_entita_a = str_all
THEN
v_str_body := v_str_body
|| cur_ent.cod_entita;
ELSE
v_str_body := v_str_body
|| cur.cod_entita_a;
END IF;Edited by: Frank Kulash on Mar 27, 2013 5:59 PM
Added IF ... THEN ... ELSE example. -
SQL LOADER: how to load CLOB column using stored function
Hi,
I am a newbie of sql loader. Everything seems to be fine until I hit a
road block - the CLOB column type. I want to load data into the clob
column using a stored function. I need to do some manipulation on the
data before it gets saved to that column. But I got this error when I
run the sql loader.
SQL*Loader-309: No SQL string allowed as part of "DATA" field
specification
DATA is my CLOB type column.
here is the content of the control file:
LOAD DATA
INFILE 'test.csv'
BADFILE 'test.bad'
DISCARDFILE 'test.dsc'
REPLACE
INTO TABLE test_table
FIELDS TERMINATED BY ','
OPTIONALLY ENCLOSED BY '"'
TRAILING NULLCOLS
codeid BOUNDFILLER,
reason BOUNDFILLER,
Checkstamp "to_date(:CHECKSTAMP, 'mm/dd/yyyy')",
"DATA" "GetContent(:codeid, :reason)"
All references are suggesting to use a file to load data on
CLOB column but I want to use a function in which it generates
the content to be saved into the column.
Any help is greatly appreciated.
Thanks,
Baldwin
MISICompany*** Duplicate Post ... Please Ignore ***
Maybe you are looking for
-
Slow Performance During Folder Selection in Miggui
I am trying to migrate some 30,000 folders from an NSS volume on NW 6.5 SP5 server to an NSS volume on a server running OES2 SP3 on SLES 10 SP4. Using the miggui from the OES server, I can authenticate to both servers, and select File System as the s
-
My volume control isn't working....
Ok, so I've had my ipod for years now, and its been fondly loved. Its been working fine up until this point. Out of the blue, the volume control doesn't want to work. Right now its at 100% volume, and it sounds like its only at 50% volume. Help?
-
Can't get mail set up w/ gmail
I have followed all the suggestions on gmail for setting up mail on my mac but it's awful. First, I can't send anything even though the smtp setting is correct; then it continues to download 4000+ messages even after they were downloaded once and del
-
I have setup a FMS (Windows 2008) in my classroom and would like to transfer files via DW to it from home. I'm currently using VPN, but it's too slow and DW freezes often while trying to upload files. My IT guy says he can open port 22 for me once I
-
My HD is not been identified. What can I do?
My external is not been identified by Macbook. How can I fix it?