PLSQL XMLDOM is limited to "VARCHAR2"
Dear Colleagues,
I just wanted to make you aware that seems
to me that the PLSQL XML parser version 1.0.2
be "VARCHAR2" biased. What I would like to know is why is that, and which implications
would there be (somewhere elses perhaps) if
one would provide as well a "CLOB" version of the xmldom PLSQL wrappers.
The problem is in plxmlparser_v1_0_2/lib/xmldocumentcover.sql
(kkarun, are you there ? )
there, you can read that the PLSQL wrapper
of the underlying java classes are all using
VARCHAR2 and not CLOB as object type.
I am trying out now to write my own PLSQL
wrappers for the entire xmldom package so that CLOBs be allowed as underlying data types instead of VARCHAR2 for the createTextNode wrapper.
I have tested, infact, and java.lang.String
which is used "for doing the job" has no limit (beyond the amount of total memory given to the JVM and then the maximal 512MB
memory that at all can be allocated to the heap ) on how big a String can be.
Therefore, I feel that the problem be simply due to the PLSQL wrappers of the xmldom which
are set to VARCHAR2 instead of CLOB or BLOB.
I would appreciate as well your point of view
and perhaps infos on why it has been done only in that way.
Seems to me (looking in the PLSQL code) that
the first author of the plxmlparser was Steve
Muench, while the latest developer was "KKARUN".
It would be great if any of them could answer...
null
Dear Mr. Muench,
I am delighted of the attention you have given to my request for help.
What I am trying to do is simply to generate XML from PLSQL, whereby the text contained in the nodes be greater than 4000 characters.
For that reason, the underlying table stores the specific node data as a CLOB.
Therefore, in short, the answer is "case b":
I am trying to create a text node with more than 4000 characters in it.
Looking forward your reply
regards and thanks
Dr. Toldo
p.s. I have created a modified version of the
plsqlparser which has CLOB instead of VARCHAR2 however it still crashes as soon as
it executes since tries to use the java.lang.String and instead should use the org.oracle.CLOB data type ...
p.p.s. The project which makes use of the
above is called "OraPIM" and I presented last
week at the Open Day of the PIM project http://esubmission.eudra.org/pim/openday/slides/toldo2.ppt
at the European Agency for evaluation of Medicinal products(http://www.emea.eudra.org/)
It has been taken very well by the audience and OraPIM is the first "phase2"
implementation ever done. Soon in production (but for that I need the PLSQL to be able
to createTextNode with 4k>32k>... data !
Similar Messages
-
Xmldom, xslprocessor package and namespace
Hello,
First as I'm a newbie, is there a complete documentation on XML DB for developpers in oracle.com ?
Now my problem : I'm using in PLSQL xmldom, xslprocessor package with XPATH method to retrieve some information.
I have tested the code and it works except when I have this in the XML file :
xmlns="x-schema:OpenShipments.xdr"
THIS IS THE CODE I USE ( xmldom, xslprocessor are encapsulated ):
FUNCTION Extract_Info( p_file_path IN VARCHAR2 -- path of the file, sample : /u01/E11T/e11tappl/als/11.5.0/
,p_file_name IN VARCHAR2 -- name of the file : sample UPS_1.xml
,p_nodelist IN VARCHAR2 -- list of XML nodes such as '/OpenShipments/OpenShipment/Receiver'
,p_node_attribute IN VARCHAR2 -- the node or attribute to analyse, sample for UPS : AddressLine1
,p_position IN NUMBER -- if 1 the first value retrieved is given, if 2 the second, if 3 ....
,p_message OUT VARCHAR2 -- error message
,p_res OUT VARCHAR2 -- error code 'S' if success, 'E' if error
RETURN VARCHAR2
IS
l_return VARCHAR2(2000);
BEGIN
DECLARE
doc_out xmldom.domdocument;
file_in VARCHAR2(150):=p_file_path || p_file_name; ---
l_nodelist xmldom.domnodelist;
l_node xmldom.domnode;
l NUMBER;
l_message VARCHAR2(2000):=NULL;
l_res VARCHAR2(1):='S';
BEGIN
ALS_XML_PK.parse_document (file_in,doc_out);
l_nodelist:=ALS_XML_PK.selected_nodes (doc_out,p_nodelist);
l_node := xmldom.item (l_nodelist,p_position-1);
l_return:=xslprocessor.valueof (l_node,p_node_attribute);
-- to check number of nodes
-- l:=xmldom.getlength(l_nodelist);
--dbms_output.put_line('nombre de node ' || xmldom.getlength(l_nodelist));
--dbms_output.put_line('valeur ' || NVL(l_return,'IS NULL !!'));
EXCEPTION
WHEN xmldom.index_size_err
THEN
l_res:='E';
l_message:='INDEX SIZE error';
--raise_application_error (-20120, 'INDEX SIZE error');
WHEN xmldom.domstring_size_err
THEN
l_res:='E';
l_message:='String SIZE error';
--raise_application_error (-20120, 'String SIZE error');
WHEN xmldom.hierarchy_request_err
THEN
l_res:='E';
l_message:='Hierarchy request error';
--raise_application_error (-20120,'Hierarchy request error');
WHEN xmldom.wrong_document_err
THEN
l_res:='E';
l_message:='Wrong doc error';
--raise_application_error (-20120, 'Wrong doc error');
WHEN xmldom.invalid_character_err
THEN
l_res:='E';
l_message:='Invalid CHAR error';
--raise_application_error (-20120, 'Invalid CHAR error');
WHEN xmldom.no_data_allowed_err
THEN
l_res:='E';
l_message:='Nod data allowed error';
--raise_application_error (-20120,'Nod data allowed error');
WHEN xmldom.no_modification_allowed_err
THEN
l_res:='E';
l_message:='No MOD allowed error';
--raise_application_error (-20120,'No MOD allowed error');
WHEN xmldom.not_found_err
THEN
l_res:='E';
l_message:='NOT FOUND error';
--raise_application_error (-20120, 'NOT FOUND error');
WHEN xmldom.not_supported_err
THEN
l_res:='E';
l_message:='NOT supported error';
--raise_application_error (-20120,'NOT supported error');
WHEN xmldom.inuse_attribute_err
THEN
l_res:='E';
l_message:='IN USE attr error';
--raise_application_error (-20120, 'IN USE attr error');
END;
-- return value extracted
RETURN l_return;
END Extract_Info;
---> error is with namespace :
ORA-20100: Error occurred while parsing: Permission denied
Message was edited by:
ROMEO_GSQL> set serveroutput on
SQL> declare
2 xmldoc1 xmltype := xmltype (
3 '<OpenShipments>
4 <OpenShipment ProcessStatus="TESTONS">
5 <Receiver>
6 <CompanyName>DUMMY</CompanyName>
7 <ContactPerson>000000</ContactPerson>
8 <AddressLine1>DUMM</AddressLine1>
9 <AddressLine2>DUMDUM</AddressLine2>
10 <AddressLine3/>
11 <City>PROUT</City>
12 <CountryCode>BE</CountryCode>
13 <PostalCode>1111</PostalCode>
14 <Residential>0</Residential>
15 <CustomerIDNumber>0</CustomerIDNumber>
16 <Phone>0</Phone>
17 <TaxIDNumber>0</TaxIDNumber>
18 <LocationID/>
19 <UpsAccountNumber>0</UpsAccountNumber>
20 <RecordOwner>0</RecordOwner>
21 </Receiver>
22 <Shipment>
23 <ServiceLevel>1</ServiceLevel>
24 <PackageType/>
25 <NumberOfPackages>1</NumberOfPackages>
26 <ShipmentActualWeight>1</ShipmentActualWeight>
27 <DescriptionOfGoods/>
28 <Reference1/>
29 <Reference2/>
30 <DocumentOnly>1</DocumentOnly>
31 <GoodsNotInFreeCirculation>1</GoodsNotInFreeCirculation>
32 <BillingOption>1</BillingOption>
33 <DeclareValue>
34 <Amount>1</Amount>
35 </DeclareValue>
36 </Shipment>
37 </OpenShipment>
38 </OpenShipments>');
39
40 xmldoc2 xmltype := xmltype (
41 '<OpenShipments xmlns="x-schema:OpenShipments.xdr">
42 <OpenShipment ProcessStatus="TESTONS">
43 <Receiver>
44 <CompanyName>DUMMY</CompanyName>
45 <ContactPerson>000000</ContactPerson>
46 <AddressLine1>DUMM</AddressLine1>
47 <AddressLine2>DUMDUM</AddressLine2>
48 <AddressLine3/>
49 <City>PROUT</City>
50 <CountryCode>BE</CountryCode>
51 <PostalCode>1111</PostalCode>
52 <Residential>0</Residential>
53 <CustomerIDNumber>0</CustomerIDNumber>
54 <Phone>0</Phone>
55 <TaxIDNumber>0</TaxIDNumber>
56 <LocationID/>
57 <UpsAccountNumber>0</UpsAccountNumber>
58 <RecordOwner>0</RecordOwner>
59 </Receiver>
60 <Shipment>
61 <ServiceLevel>1</ServiceLevel>
62 <PackageType/>
63 <NumberOfPackages>1</NumberOfPackages>
64 <ShipmentActualWeight>1</ShipmentActualWeight>
65 <DescriptionOfGoods/>
66 <Reference1/>
67 <Reference2/>
68 <DocumentOnly>1</DocumentOnly>
69 <GoodsNotInFreeCirculation>1</GoodsNotInFreeCirculation>
70 <BillingOption>1</BillingOption>
71 <DeclareValue>
72 <Amount>1</Amount>
73 </DeclareValue>
74 </Shipment>
75 </OpenShipment>
76 </OpenShipments>');
77
78 DOC DBMS_XMLDOM.DOMDOCUMENT;
79 NL DBMS_XMLDOM.DOMNODELIST;
80 begin
81
82 DOC := DBMS_XMLDOM.newDOMDocument(xmldoc1);
83 NL := DBMS_XSLPROCESSOR.selectNodes(dbms_xmldom.makeNode(DOC),'/OpenShipments/OpenShipment/Receiver');
84 dbms_output.put_line('NodeList.length() = ' || DBMS_XMLDOM.GETLENGTH(NL));
85
86 DOC := DBMS_XMLDOM.newDOMDocument(xmldoc2);
87 NL := DBMS_XSLPROCESSOR.selectNodes(dbms_xmldom.makeNode(DOC),'/OpenShipments/OpenShipment/Receiver');
88 dbms_output.put_line('NodeList.length() = ' || DBMS_XMLDOM.GETLENGTH(NL));
89
90 NL := DBMS_XSLPROCESSOR.selectNodes(dbms_xmldom.makeNode(DOC),'/OpenShipments/OpenShipment/Receiver','xmlns="x-schema:OpenShipments.
xdr"');
91 dbms_output.put_line('NodeList.length() = ' || DBMS_XMLDOM.GETLENGTH(NL));
92
93 end;
94
95 /
NodeList.length() = 1
NodeList.length() = 0
NodeList.length() = 1
PL/SQL procedure successfully completed.
Elapsed: 00:00:00.12
SQL>The doc does not show that SELECTNODES takes a third argument, which is the namespace prefix mappings for the document. However a describe of the package does show that there is a third agument. A doc bug has been filed. -
Xmldom.getnodevalue return only 4K !??
Hello,
xmldom.getnodevalue PLSQL function could return a varchar2(32000) value, but we get 4097 bytes max. !!
what's wrong ?
thanksThe problem is in plxmlparser_v1_0_2/lib/xmldocumentcover.sql
(kkarun, are you there ? )
there, you can read that the PLSQL wrapper
of the underlying java classes are all using
VARCHAR2 and not CLOB as object type.
Since VARCHAR2 in PLSQL has the notorious 4K limit, then ... this is what you get.
I am trying out now to write my own PLSQL
wrappers for the entire xmldom package so that CLOBs be allowed as underlying data types.
I have tested, infact, and java.lang.String
which is used "for doing the job" has no limit (beyond the amount of total memory given to the JVM and then the maximal 512MB
memory that at all can be allocated to the heap ) on how big a String can be.
Therefore, I feel that the problem be simply due to the PLSQL wrappers of the xmldom which
are set to VARCHAR2 instead of CLOB or BLOB.
I would appreciate as well your point of view
null -
Creating XML File Using xmldom Package
How can I create an XML file from scratch using the PL/SQL xmldom package?
I want to create an XML file using the xmldom package instead of building the individual tags as strings of VARCHAR2 character data. There is quite a bit of documentation regarding manipulating input XML files using DOM -- but not for creating XML files from scratch given known "tagnames" (<lastName>) and retrieved database "values" ("Smith").
<person>
<lastName>Smith</lastName>
</person>
Is there any documentation that you can recommend?
Thank you.Here is an example.
The create_file procedure creates the file.
The other procedures are generic procs that can be used with any XML.
PROCEDURE create_file_with_root(po_xmldoc OUT xmldom.DOMDocument,
pi_root_tag IN VARCHAR2,
po_root_element OUT xmldom.domelement,
po_root_node OUT xmldom.domnode,
pi_doctype_url IN VARCHAR2) IS
xmldoc xmldom.DOMDocument;
root xmldom.domnode;
root_node xmldom.domnode;
root_element xmldom.domelement;
record_node xmldom.domnode;
newelenode xmldom.DOMNode;
BEGIN
xmldoc := xmldom.newDOMDocument;
xmldom.setVersion(xmldoc, '1.0');
xmldom.setDoctype(xmldoc, pi_root_tag, pi_doctype_url,'');
-- Create the root --
root := xmldom.makeNode(xmldoc);
-- Create the root element in the file --
create_element_and_append(xmldoc, pi_root_tag, root, root_element, root_node);
po_xmldoc := xmldoc;
po_root_node := root_node;
po_root_element := root_element;
END create_file_with_root;
PROCEDURE create_element_and_append(pi_xmldoc IN OUT xmldom.DOMDocument,
pi_element_name IN VARCHAR2,
pi_parent_node IN xmldom.domnode,
po_new_element OUT xmldom.domelement,
po_new_node OUT xmldom.domnode) IS
element xmldom.domelement;
child_node xmldom.domnode;
newelenode xmldom.DOMNode;
BEGIN
element := xmldom.createElement(pi_xmldoc, pi_element_name);
child_node := xmldom.makeNode(element);
-- Append the new node to the parent --
newelenode := xmldom.appendchild(pi_parent_node, child_node);
po_new_node := child_node;
po_new_element := element;
END create_element_and_append;
FUNCTION create_text_element(pio_xmldoc IN OUT xmldom.DOMDocument, pi_element_name IN VARCHAR2,
pi_element_data IN VARCHAR2, pi_parent_node IN xmldom.domnode) RETURN xmldom.domnode IS
parent_node xmldom.domnode;
child_node xmldom.domnode;
child_element xmldom.domelement;
newelenode xmldom.DOMNode;
textele xmldom.DOMText;
compnode xmldom.DOMNode;
BEGIN
create_element_and_append(pio_xmldoc, pi_element_name, pi_parent_node, child_element, child_node);
parent_node := child_node;
-- Create a text node --
textele := xmldom.createTextNode(pio_xmldoc, pi_element_data);
child_node := xmldom.makeNode(textele);
-- Link the text node to the new node --
compnode := xmldom.appendChild(parent_node, child_node);
RETURN newelenode;
END create_text_element;
PROCEDURE create_file IS
xmldoc xmldom.DOMDocument;
root_node xmldom.domnode;
xml_doctype xmldom.DOMDocumentType;
root_element xmldom.domelement;
record_element xmldom.domelement;
record_node xmldom.domnode;
parent_node xmldom.domnode;
child_node xmldom.domnode;
newelenode xmldom.DOMNode;
textele xmldom.DOMText;
compnode xmldom.DOMNode;
BEGIN
xmldoc := xmldom.newDOMDocument;
xmldom.setVersion(xmldoc, '1.0');
create_file_with_root(xmldoc, 'root', root_element, root_node, 'test.dtd');
xmldom.setAttribute(root_element, 'interface_type', 'EXCHANGE_RATES');
-- Create the record element in the file --
create_element_and_append(xmldoc, 'record', root_node, record_element, record_node);
parent_node := create_text_element(xmldoc, 'title', 'Mr', record_node);
parent_node := create_text_element(xmldoc, 'name', 'Joe', record_node);
parent_node := create_text_element(xmldoc,'surname', 'Blogs', record_node);
-- Create the record element in the file --
create_element_and_append(xmldoc, 'record', root_node, record_element, record_node);
parent_node := create_text_element(xmldoc, 'title', 'Mrs', record_node);
parent_node := create_text_element(xmldoc, 'name', 'A', record_node);
parent_node := create_text_element(xmldoc, 'surname', 'B', record_node);
-- write the newly created dom document into the buffer assuming it is less than 32K
xmldom.writeTofile(xmldoc, 'c:\laiki\willow_data\test.xml');
EXCEPTION
WHEN xmldom.INDEX_SIZE_ERR THEN
RAISE_APPLICATION_ERROR(-20120, 'Index Size error');
WHEN xmldom.DOMSTRING_SIZE_ERR THEN
RAISE_APPLICATION_ERROR(-20120, 'String Size error');
WHEN xmldom.HIERARCHY_REQUEST_ERR THEN
RAISE_APPLICATION_ERROR(-20120, 'Hierarchy request error');
WHEN xmldom.WRONG_DOCUMENT_ERR THEN
RAISE_APPLICATION_ERROR(-20120, 'Wrong doc error');
WHEN xmldom.INVALID_CHARACTER_ERR THEN
RAISE_APPLICATION_ERROR(-20120, 'Invalid Char error');
WHEN xmldom.NO_DATA_ALLOWED_ERR THEN
RAISE_APPLICATION_ERROR(-20120, 'Nod data allowed error');
WHEN xmldom.NO_MODIFICATION_ALLOWED_ERR THEN
RAISE_APPLICATION_ERROR(-20120, 'No mod allowed error');
WHEN xmldom.NOT_FOUND_ERR THEN
RAISE_APPLICATION_ERROR(-20120, 'Not found error');
WHEN xmldom.NOT_SUPPORTED_ERR THEN
RAISE_APPLICATION_ERROR(-20120, 'Not supported error');
WHEN xmldom.INUSE_ATTRIBUTE_ERR THEN
RAISE_APPLICATION_ERROR(-20120, 'In use attr error');
WHEN OTHERS THEN
dbms_output.put_line('exception occured' || SQLCODE || SUBSTR(SQLERRM, 1, 100));
END create_file; -
Is there any way to read Processing instruction content with XMLDOM
I am having problem to read the content of PRocessing instructions with PLSQL XMLDOM.
Would appriciate if someone could help. with code sample.DOM doesn't have any direct way to select nodes. Processing-Instructions are child nodes to the corresponding node. If you know the tree structure you can traverse the tree and goto the particular PI node.
The easiest way is to XPath expressions. The following example retrieves all the Processing Instructions in the document.
XSLProcessor.selectNodes(document, '//processing-instruction()') -
Alternative for varchar2 bcoz limitaion?
Hi,
I have developed a screen that is used to print an SQL output to forms and export the result in excel.
In this module i am just sending the sql, based on the report selection from a list box. The selection list has become too long. I am planning to generate the list based on user level permissions. To do this I have to store the SQL in a table as different rows. There seems to be a limitation of varchar2(4000) for storing an SQL. Is there an alternative ? Is it possible using BLOB data type ? If yes, how do I store and retrieve data in BLOB data type ?
kanishHi Kanish,
As Navnit told you can use the DBMS_LOB package to store lengthy data into the CLOB.
I have tried a small example, I think this may help you.
<pre style="border: 1px dashed rgb(153, 153, 153); padding: 5px; overflow: auto; font-family: Andale Mono,Lucida Console,Monaco,fixed,monospace; color: rgb(0, 0, 0); background-color: rgb(238, 238, 238); font-size: 12px; line-height: 14px; width: 100%;">
Create a table lob_contain
(ID NUMBER,
lob_col CLOB default empty_clob());
</pre>
Creating a block to write to the LOB
<pre style="border: 1px dashed rgb(153, 153, 153); padding: 5px; overflow: auto; font-family: Andale Mono,Lucida Console,Monaco,fixed,monospace; color: rgb(0, 0, 0); background-color: rgb(238, 238, 238); font-size: 12px; line-height: 14px; width: 100%;">
Declare
lob_locator CLOB;
text varchar2(200) := 'Resume NAme - G.Subramanian KAushik City - Chennai
Location - triplicane Occupation - Software engineer Hobbies - Reading astrology
books,nemerology, Playing video games';
amount number;
offset integer;
Begin
-- Setting the amount to be written
amount := length(text);
-- Lock the record in the table lob_contain to get a expicit lock over the record
Select lob_ptr into lob_locator from lob_contain where id = 1 FOR UPDATE;
--Setting the Offset
offset := DBMS_LOB.GETLENGTH(lob_locator)+2;
--Write the text to the CLOB table
DBMS_LOB.WRITE(lob_locator,amount,offset,text);
COMMIT;
END;
</pre>
You can read the data entered into a CLOB similiar to a VARCHAR2 column
Kindly mark it , if it helps Thanks :-)
Edited by: Subramanian Kaushik Gurumoorthy on May 6, 2009 6:28 PM -
Editing a Package - Dynamic Page
I am a developer in Portal. I created a Dynamic page. Unfortunately there is only one way that a query could be displayed, Tabular and with colors by default. The problem comes when you want to display the fields in a diferent order and also format the HTML table where the records are being displayed. So I try to go to the "Database Objects" section and it only lets me edit the package if is less than 30K. Is there a way to raise this quota or just erase it? Does it make a diference if it gets raised to say..... 1MB?
I know that I can always go to the SQL file and twig it there, but is there a way to do it through Portal?
Any suggestions or comments are welcomed!Hi,
The value in the textarea can go up to 32767 bytes. This is a limitation of varchar2 in plsql. If the package exceeds this
then you will have to open it as a SQL file.
Thanks,
Sharmila -
Large text return is truncated. ??
When reading the value of a node containing large amounts of text, the value is truncated to 4097 characters. I have tried using both of these methods of reading the node:
xmldom.getNodeValue(dn_child)
xslprocessor.valueOf(dn_curGBentry, 'COMMENT')
The source XML contains all of the message, yet when I use a length function on the above I get a value of 4097. No errors occur. The process seems to run as normal. But it truncates the message for some reason.
I recently discovered that the database was installed with a page size of 4k. Would that have anything to do with it? If so, how do I get around this issue? Can I read the Value of the node in chunks of 4k?Your document is truncated because of limits of VARCHAR2.
Would you please try the following procedure:
PROCEDURE writeToClob(n DOMNode, cl IN OUT CLOB); -
ORA-06502: PL/SQL: numeric or value error: Bulk bind: Error in define
Hi All,
Getting aforesaid error while executing a procedure.
I have a procedure which takes 7 paramneters and have 13 IN OUT parameters. all the IN OUT parameters are PLSQL tables of number and varchar2.
I Have checked there are no not null columns this procedure is just seelcting these values and assigning it to plsql table.
Regards
ManishThanks for the reply.
This is the procedure which returns the list of projects
PROCEDURE DS$2342_PROC
(P_PROJECT_ID_ARR IN DS$REF.TT_PRO_ID
,P_PAGE_NO IN NUMBER
,P_RECORDS_PER_PAGE IN NUMBER
,P_USER_ID IN USERS.ID%TYPE
,P_SORT_ORDER IN VARCHAR2
,P_PSE_ID IN PORTAL_SERVICES.ID%TYPE
,P_LAST_ACCESSED_DATE IN VARCHAR2
,O_PRO_ALL_ID_ARRAY IN OUT DS$REF.TT_PRO_ID
,O_PRO_ID_ARRAY IN OUT DS$REF.TT_PRO_ID
,O_NAME_ARRAY IN OUT DS$REF.TT_VARCHAR2
,O_TYPE_OF_WORK_ARRAY IN OUT DS$REF.TT_VARCHAR2
,O_STAGE_ARRAY IN OUT DS$REF.TT_VARCHAR2
,O_LOC_ARRAY IN OUT DS$REF.TT_VARCHAR2
,O_CURRENCY_ARRAY IN OUT DS$REF.TT_VARCHAR2
,O_VALUE_ARRAY IN OUT DS$REF.TT_NUMBER
,O_DISPLAY_VALUE_ARRAY IN OUT DS$REF.TT_VARCHAR2
,O_LATEST_UPDATED_DATE_ARRAY IN OUT DS$REF.TT_VARCHAR2
,O_FLAG_ARRAY IN OUT DS$REF.TT_VARCHAR2
,O_LOCATION IN OUT DS$REF.TT_VARCHAR2
IS
BEGIN
DECLARE
List of parameters
1.p_project_id_arr Projects id.
2.p_page_no Page number.
3.p_records_per_page Records per page.
4.p_user_id User id.
5.p_sort_order Sorting by column.
6.p_pse_id Portal service id.
7.p_last_accessed_date User last accessed date
Output parameters
1. o_pro_all_id_array Project id array
2. o_pro_id_array Project id array as per records to be displayed
3. o_name_array Project title array
4. o_type_of_work_array Project type of work array
5. o_stage_array Project stage array
6. o_loc_array Project location array
7. o_currency_array Project currency array
8. o_value_array Project values array
9. o_display_value_array Project display values array
10. o_latest_updated_date_array Project latest updated date
11. o_flag_array Flags for new and updated watch icon, project notes, download leads
12. o_location Location
v_status CONSTANT EXTRACT_BATCH_HEADERS.STATUS%TYPE := 'OPN';
CURSOR c_psc(qp_pse_id PORTAL_SERVICES.ID%TYPE) IS
SELECT DISTINCT psc.LOCATION_REPORTING_LEVEL
FROM PORTAL_SCS psc
WHERE psc.START_DATE <= SYSDATE
AND ( psc.END_DATE IS NULL
OR psc.END_DATE > SYSDATE )
AND psc.LOCATION_REPORTING_LEVEL IS NOT NULL
AND psc.PSE_ID = qp_pse_id;
CURSOR c_projects_name_order_asc IS
SELECT pro.ID id
FROM PROJECTS pro,
TMP_PROJECTS tmp
WHERE pro.ID = tmp.PRO_ID
ORDER BY pro.NAME;
CURSOR c_projects_name_order_desc IS
SELECT pro.ID id
FROM PROJECTS pro,
TMP_PROJECTS tmp
WHERE pro.ID = tmp.PRO_ID
ORDER BY pro.NAME DESC;
CURSOR c_projects_work_order_asc IS
SELECT pro.ID id
FROM PROJECTS pro,
TMP_PROJECTS tmp
WHERE pro.ID = tmp.PRO_ID
ORDER BY TYPE_OF_WORK;
CURSOR c_projects_work_order_desc IS
SELECT pro.ID id
FROM PROJECTS pro,
TMP_PROJECTS tmp
WHERE pro.ID = tmp.PRO_ID
ORDER BY TYPE_OF_WORK DESC;
CURSOR c_projects_stage_order_asc IS
SELECT pro.ID id
FROM PROJECTS pro,
TMP_PROJECTS tmp
WHERE pro.ID = tmp.PRO_ID
ORDER BY pro.STAGE;
CURSOR c_projects_stage_order_desc IS
SELECT pro.ID id
FROM PROJECTS pro,
TMP_PROJECTS tmp
WHERE pro.ID = tmp.PRO_ID
ORDER BY pro.STAGE DESC;
/* Cursor changed by Tushar on 08/02/2005 */
CURSOR c_projects_loc_order_asc (cp_location PORTAL_SCS.LOCATION_REPORTING_LEVEL%TYPE) IS
SELECT pro.ID id,
DECODE(cp_location,'T',NVL(pro.ADDRESS_LINE_3,pro.ADDRESS_LINE_4)
,'C',pro.ADDRESS_LINE_4) location
FROM PROJECTS pro,
TMP_PROJECTS tmp
WHERE pro.ID = tmp.PRO_ID
-- ORDER BY DECODE(cp_location,'T',NVL(pro.ADDRESS_LINE_3,pro.ADDRESS_LINE_4)
-- ,'C',pro.ADDRESS_LINE_4),
ORDER BY DECODE(cp_location
,'T',NVL(pro.ADDRESS_LINE_3,pro.ADDRESS_LINE_4)
,'C',pro.ADDRESS_LINE_4)||', '||
SUBSTR(POST_CODE,1,DECODE(LTRIM(INSTR(POST_CODE,' ')),0,
LENGTH(POST_CODE),LTRIM(INSTR(POST_CODE,' ')))),
TRUNC(pro.LATEST_UPDATED_DATE) DESC,
pro.VALUE DESC,
pro.ID DESC;
/* Cursor changed by Tushar on 08/02/2005 */
CURSOR c_projects_loc_order_desc (cp_location PORTAL_SCS.LOCATION_REPORTING_LEVEL%TYPE) IS
SELECT pro.ID id,
DECODE(cp_location,'T',NVL(pro.ADDRESS_LINE_3,pro.ADDRESS_LINE_4)
,'C',pro.ADDRESS_LINE_4) location
FROM PROJECTS pro,
TMP_PROJECTS tmp
WHERE pro.ID = tmp.PRO_ID
-- ORDER BY DECODE(cp_location,'T',NVL(pro.ADDRESS_LINE_3,pro.ADDRESS_LINE_4)
-- ,'C',pro.ADDRESS_LINE_4),
ORDER BY DECODE(cp_location
,'T',NVL(pro.ADDRESS_LINE_3,pro.ADDRESS_LINE_4)
,'C',pro.ADDRESS_LINE_4)||', '||
SUBSTR(POST_CODE,1,DECODE(LTRIM(INSTR(POST_CODE,' ')),0,
LENGTH(POST_CODE),LTRIM(INSTR(POST_CODE,' ')))) DESC,
TRUNC(pro.LATEST_UPDATED_DATE) DESC,
pro.VALUE DESC,
pro.ID DESC;
/* Cursor changed by Tushar on 08/02/2005 */
CURSOR c_projects_value_order_asc(cp_location PORTAL_SCS.LOCATION_REPORTING_LEVEL%TYPE) IS
SELECT pro.ID id,
DECODE(cp_location,'T',NVL(pro.ADDRESS_LINE_3,pro.ADDRESS_LINE_4)
,'C',pro.ADDRESS_LINE_4) location
FROM PROJECTS pro,
TMP_PROJECTS tmp
WHERE pro.ID = tmp.PRO_ID
ORDER BY pro.VALUE,
TRUNC(pro.LATEST_UPDATED_DATE),
-- DECODE(cp_location,'T',NVL(pro.ADDRESS_LINE_3,pro.ADDRESS_LINE_4)
-- ,'C',pro.ADDRESS_LINE_4),
DECODE(cp_location
,'T',NVL(pro.ADDRESS_LINE_3,pro.ADDRESS_LINE_4)
,'C',pro.ADDRESS_LINE_4)||', '||
SUBSTR(POST_CODE,1,DECODE(LTRIM(INSTR(POST_CODE,' ')),0,
LENGTH(POST_CODE),LTRIM(INSTR(POST_CODE,' ')))),
pro.ID DESC;
/* Cursor changed by Tushar on 08/02/2005 */
CURSOR c_projects_value_order_desc(cp_location PORTAL_SCS.LOCATION_REPORTING_LEVEL%TYPE) IS
SELECT pro.ID id,
DECODE(cp_location,'T',NVL(pro.ADDRESS_LINE_3,pro.ADDRESS_LINE_4)
,'C',pro.ADDRESS_LINE_4) location
FROM PROJECTS pro,
TMP_PROJECTS tmp
WHERE pro.ID = tmp.PRO_ID
ORDER BY pro.VALUE DESC,
TRUNC(pro.LATEST_UPDATED_DATE) DESC,
-- DECODE(cp_location,'T',NVL(pro.ADDRESS_LINE_3,pro.ADDRESS_LINE_4)
-- ,'C',pro.ADDRESS_LINE_4),
DECODE(cp_location
,'T',NVL(pro.ADDRESS_LINE_3,pro.ADDRESS_LINE_4)
,'C',pro.ADDRESS_LINE_4)||', '||
SUBSTR(POST_CODE,1,DECODE(LTRIM(INSTR(POST_CODE,' ')),0,
LENGTH(POST_CODE),LTRIM(INSTR(POST_CODE,' ')))),
pro.ID DESC;
/* Cursor changed by Tushar on 08/02/2005 */
CURSOR c_projects_lud_order_asc(cp_location PORTAL_SCS.LOCATION_REPORTING_LEVEL%TYPE) IS
SELECT pro.ID id,
DECODE(cp_location,'T',NVL(pro.ADDRESS_LINE_3,pro.ADDRESS_LINE_4)
,'C',pro.ADDRESS_LINE_4) location
FROM PROJECTS pro,
TMP_PROJECTS tmp
WHERE pro.ID = tmp.PRO_ID
ORDER BY TRUNC(pro.LATEST_UPDATED_DATE),
pro.VALUE DESC,
-- DECODE(cp_location,'T',NVL(pro.ADDRESS_LINE_3,pro.ADDRESS_LINE_4)
-- ,'C',pro.ADDRESS_LINE_4),
DECODE(cp_location
,'T',NVL(pro.ADDRESS_LINE_3,pro.ADDRESS_LINE_4)
,'C',pro.ADDRESS_LINE_4)||', '||
SUBSTR(POST_CODE,1,DECODE(LTRIM(INSTR(POST_CODE,' ')),0,
LENGTH(POST_CODE),LTRIM(INSTR(POST_CODE,' ')))),
pro.ID DESC;
/* Cursor changed by Tushar on 08/02/2005 */
CURSOR c_projects_lud_order_desc(cp_location PORTAL_SCS.LOCATION_REPORTING_LEVEL%TYPE) IS
SELECT pro.ID id,
DECODE(cp_location,'T',NVL(pro.ADDRESS_LINE_3,pro.ADDRESS_LINE_4)
,'C',pro.ADDRESS_LINE_4) location
FROM PROJECTS pro,
TMP_PROJECTS tmp
WHERE pro.ID = tmp.PRO_ID
ORDER BY TRUNC(pro.LATEST_UPDATED_DATE) DESC,
pro.VALUE DESC,
-- DECODE(cp_location,'T',NVL(pro.ADDRESS_LINE_3,pro.ADDRESS_LINE_4)
-- ,'C',pro.ADDRESS_LINE_4),
DECODE(cp_location
,'T',NVL(pro.ADDRESS_LINE_3,pro.ADDRESS_LINE_4)
,'C',pro.ADDRESS_LINE_4)||', '||
SUBSTR(POST_CODE,1,DECODE(LTRIM(INSTR(POST_CODE,' ')),0,
LENGTH(POST_CODE),LTRIM(INSTR(POST_CODE,' ')))),
pro.ID DESC;
/*Cursors for project details depending on order by clause */
/* Cursor for order by name ascending */
CURSOR c_pro_sum_name_asc(cp_pse_id PORTAL_SERVICES.ID%TYPE,
cp_user_id USERS.ID%TYPE,
cp_status EXTRACT_BATCH_HEADERS.STATUS%TYPE,
cp_loc_lvl PORTAL_SCS.LOCATION_REPORTING_LEVEL%TYPE,
cp_last_accessed_date USERS.LAST_ACCESSED_DATE%TYPE ) IS
SELECT pro.ID id,
pro.NAME name,
pro.TYPE_OF_WORK type_of_work,
pro.STAGE stage,
DECODE(cp_loc_lvl
,'T',NVL(pro.ADDRESS_LINE_3,pro.ADDRESS_LINE_4)
,'C',pro.ADDRESS_LINE_4)||', '||
SUBSTR(POST_CODE,1,DECODE(LTRIM(INSTR(POST_CODE,' ')),0,
LENGTH(POST_CODE),LTRIM(INSTR(POST_CODE,' ')))) location,
pro.Currency currency,
pro.VALUE value,
pro.DISPLAY_VALUE display_value,
TO_CHAR(pro.LATEST_UPDATED_DATE,'DD/MM/YYYY') latest_updated_date,
DECODE(pro.LATEST_UPDATED_DATE, pro.CREATED_DATE,
'true','false')
||'~'||DECODE(SIGN(cp_last_accessed_date -
TRUNC(pro.LATEST_UPDATED_DATE)
),0,'true'
,-1,'true'
,1,'false')
||'~'||DECODE(wrt_rec.wrt_pro_id,NULL,'false','true')
||'~'||DECODE(pne_rec.pne_pro_id,NULL,'false','true')
||'~'||DECODE(ebr_rec.ebr_status,cp_status,'true','false') flags
FROM PROJECTS pro,
TMP_PROJECTS tmp,
(SELECT wrt.PRO_ID wrt_pro_id
FROM WATCH_REQUESTS wrt,
TMP_PROJECTS tmp_sub
WHERE wrt.VIEWED_DATE IS NULL
AND wrt.PSR_PSN_PSE_ID = cp_pse_id
AND wrt.PSR_USR_ID = cp_user_id
AND tmp_sub.PRO_ID = wrt.PRO_ID
GROUP BY wrt.PRO_ID) wrt_rec,
(SELECT pne.PRO_ID pne_pro_id
FROM PROJECT_NOTES pne,
TMP_PROJECTS tmp_pne
WHERE pne.USR_ID = cp_user_id
AND tmp_pne.PRO_ID = pne.PRO_ID) pne_rec,
(SELECT ebr.STATUS ebr_status,
ebp.PRO_ID ebp_pro_id
FROM EXTRACT_BATCH_HEADERS ebr,
EXTRACT_BATCH_PROJECTS ebp,
TMP_PROJECTS tmp_ebr
WHERE ebr.ID = ebp.EBR_ID
AND ebp.PRO_ID = tmp_ebr.PRO_ID
AND ebr.USR_ID = cp_user_id
AND ebr.STATUS = cp_status) ebr_rec
WHERE pro.ID = tmp.PRO_ID
AND pro.ID = wrt_rec.wrt_pro_id(+)
AND pro.ID = pne_rec.pne_pro_id(+)
AND pro.ID = ebr_rec.ebp_pro_id(+)
ORDER BY pro.NAME;
/* Cursor for order by name descending */
CURSOR c_pro_sum_name_dsc(cp_pse_id PORTAL_SERVICES.ID%TYPE,
cp_user_id USERS.ID%TYPE,
cp_status EXTRACT_BATCH_HEADERS.STATUS%TYPE,
cp_loc_lvl PORTAL_SCS.LOCATION_REPORTING_LEVEL%TYPE,
cp_last_accessed_date USERS.LAST_ACCESSED_DATE%TYPE ) IS
SELECT pro.ID id,
pro.NAME name,
pro.TYPE_OF_WORK type_of_work,
pro.STAGE stage,
DECODE(cp_loc_lvl
,'T',NVL(pro.ADDRESS_LINE_3,pro.ADDRESS_LINE_4)
,'C',pro.ADDRESS_LINE_4)||', '||
SUBSTR(POST_CODE,1,DECODE(LTRIM(INSTR(POST_CODE,' ')),0,
LENGTH(POST_CODE),LTRIM(INSTR(POST_CODE,' ')))) location,
pro.Currency currency,
pro.VALUE value,
pro.DISPLAY_VALUE display_value,
TO_CHAR(pro.LATEST_UPDATED_DATE,'DD/MM/YYYY') latest_updated_date,
DECODE(pro.LATEST_UPDATED_DATE, pro.CREATED_DATE,
'true','false')
||'~'||DECODE(SIGN(cp_last_accessed_date -
TRUNC(pro.LATEST_UPDATED_DATE)
),0,'true'
,-1,'true'
,1,'false')
||'~'||DECODE(wrt_rec.wrt_pro_id,NULL,'false','true')
||'~'||DECODE(pne_rec.pne_pro_id,NULL,'false','true')
||'~'||DECODE(ebr_rec.ebr_status,cp_status,'true','false') flags
FROM PROJECTS pro,
TMP_PROJECTS tmp,
(SELECT wrt.PRO_ID wrt_pro_id
FROM WATCH_REQUESTS wrt,
TMP_PROJECTS tmp_sub
WHERE wrt.VIEWED_DATE IS NULL
AND wrt.PSR_PSN_PSE_ID = cp_pse_id
AND wrt.PSR_USR_ID = cp_user_id
AND tmp_sub.PRO_ID = wrt.PRO_ID
GROUP BY wrt.PRO_ID) wrt_rec,
(SELECT pne.PRO_ID pne_pro_id
FROM PROJECT_NOTES pne,
TMP_PROJECTS tmp_pne
WHERE pne.USR_ID = cp_user_id
AND tmp_pne.PRO_ID = pne.PRO_ID) pne_rec,
(SELECT ebr.STATUS ebr_status,
ebp.PRO_ID ebp_pro_id
FROM EXTRACT_BATCH_HEADERS ebr,
EXTRACT_BATCH_PROJECTS ebp,
TMP_PROJECTS tmp_ebr
WHERE ebr.ID = ebp.EBR_ID
AND ebp.PRO_ID = tmp_ebr.PRO_ID
AND ebr.USR_ID = cp_user_id
AND ebr.STATUS = cp_status) ebr_rec
WHERE pro.ID = tmp.PRO_ID
AND pro.ID = wrt_rec.wrt_pro_id(+)
AND pro.ID = pne_rec.pne_pro_id(+)
AND pro.ID = ebr_rec.ebp_pro_id(+)
ORDER BY pro.NAME DESC;
/* Cursor for order by TYPE_OF_WORK asc*/
CURSOR c_pro_sum_work_asc(cp_pse_id PORTAL_SERVICES.ID%TYPE,
cp_user_id USERS.ID%TYPE,
cp_status EXTRACT_BATCH_HEADERS.STATUS%TYPE,
cp_loc_lvl PORTAL_SCS.LOCATION_REPORTING_LEVEL%TYPE,
cp_last_accessed_date USERS.LAST_ACCESSED_DATE%TYPE ) IS
SELECT pro.ID id,
pro.NAME name,
pro.TYPE_OF_WORK type_of_work,
pro.STAGE stage,
DECODE(cp_loc_lvl
,'T',NVL(pro.ADDRESS_LINE_3,pro.ADDRESS_LINE_4)
,'C',pro.ADDRESS_LINE_4)||', '||
SUBSTR(POST_CODE,1,DECODE(LTRIM(INSTR(POST_CODE,' ')),0,
LENGTH(POST_CODE),LTRIM(INSTR(POST_CODE,' ')))) location,
pro.Currency currency,
pro.VALUE value,
pro.DISPLAY_VALUE display_value,
TO_CHAR(pro.LATEST_UPDATED_DATE,'DD/MM/YYYY') latest_updated_date,
DECODE(pro.LATEST_UPDATED_DATE, pro.CREATED_DATE,
'true','false')
||'~'||DECODE(SIGN(cp_last_accessed_date -
TRUNC(pro.LATEST_UPDATED_DATE)
),0,'true'
,-1,'true'
,1,'false')
||'~'||DECODE(wrt_rec.wrt_pro_id,NULL,'false','true')
||'~'||DECODE(pne_rec.pne_pro_id,NULL,'false','true')
||'~'||DECODE(ebr_rec.ebr_status,cp_status,'true','false') flags
FROM PROJECTS pro,
TMP_PROJECTS tmp,
(SELECT wrt.PRO_ID wrt_pro_id
FROM WATCH_REQUESTS wrt,
TMP_PROJECTS tmp_sub
WHERE wrt.VIEWED_DATE IS NULL
AND wrt.PSR_PSN_PSE_ID = cp_pse_id
AND wrt.PSR_USR_ID = cp_user_id
AND tmp_sub.PRO_ID = wrt.PRO_ID
GROUP BY wrt.PRO_ID) wrt_rec,
(SELECT pne.PRO_ID pne_pro_id
FROM PROJECT_NOTES pne,
TMP_PROJECTS tmp_pne
WHERE pne.USR_ID = cp_user_id
AND tmp_pne.PRO_ID = pne.PRO_ID) pne_rec,
(SELECT ebr.STATUS ebr_status,
ebp.PRO_ID ebp_pro_id
FROM EXTRACT_BATCH_HEADERS ebr,
EXTRACT_BATCH_PROJECTS ebp,
TMP_PROJECTS tmp_ebr
WHERE ebr.ID = ebp.EBR_ID
AND ebp.PRO_ID = tmp_ebr.PRO_ID
AND ebr.USR_ID = cp_user_id
AND ebr.STATUS = cp_status) ebr_rec
WHERE pro.ID = tmp.PRO_ID
AND pro.ID = wrt_rec.wrt_pro_id(+)
AND pro.ID = pne_rec.pne_pro_id(+)
AND pro.ID = ebr_rec.ebp_pro_id(+)
ORDER BY pro.TYPE_OF_WORK;
/* Cursor for order by TYPE_OF_WORK descending */
CURSOR c_pro_sum_work_dsc(cp_pse_id PORTAL_SERVICES.ID%TYPE,
cp_user_id USERS.ID%TYPE,
cp_status EXTRACT_BATCH_HEADERS.STATUS%TYPE,
cp_loc_lvl PORTAL_SCS.LOCATION_REPORTING_LEVEL%TYPE,
cp_last_accessed_date USERS.LAST_ACCESSED_DATE%TYPE ) IS
SELECT pro.ID id,
pro.NAME name,
pro.TYPE_OF_WORK type_of_work,
pro.STAGE stage,
DECODE(cp_loc_lvl
,'T',NVL(pro.ADDRESS_LINE_3,pro.ADDRESS_LINE_4)
,'C',pro.ADDRESS_LINE_4)||', '||
SUBSTR(POST_CODE,1,DECODE(LTRIM(INSTR(POST_CODE,' ')),0,
LENGTH(POST_CODE),LTRIM(INSTR(POST_CODE,' ')))) location,
pro.Currency currency,
pro.VALUE value,
pro.DISPLAY_VALUE display_value,
TO_CHAR(pro.LATEST_UPDATED_DATE,'DD/MM/YYYY') latest_updated_date,
DECODE(pro.LATEST_UPDATED_DATE, pro.CREATED_DATE,
'true','false')
||'~'||DECODE(SIGN(cp_last_accessed_date -
TRUNC(pro.LATEST_UPDATED_DATE)
),0,'true'
,-1,'true'
,1,'false')
||'~'||DECODE(wrt_rec.wrt_pro_id,NULL,'false','true')
||'~'||DECODE(pne_rec.pne_pro_id,NULL,'false','true')
||'~'||DECODE(ebr_rec.ebr_status,cp_status,'true','false') flags
FROM PROJECTS pro,
TMP_PROJECTS tmp,
(SELECT wrt.PRO_ID wrt_pro_id
FROM WATCH_REQUESTS wrt,
TMP_PROJECTS tmp_sub
WHERE wrt.VIEWED_DATE IS NULL
AND wrt.PSR_PSN_PSE_ID = cp_pse_id
AND wrt.PSR_USR_ID = cp_user_id
AND tmp_sub.PRO_ID = wrt.PRO_ID
GROUP BY wrt.PRO_ID) wrt_rec,
(SELECT pne.PRO_ID pne_pro_id
FROM PROJECT_NOTES pne,
TMP_PROJECTS tmp_pne
WHERE pne.USR_ID = cp_user_id
AND tmp_pne.PRO_ID = pne.PRO_ID) pne_rec,
(SELECT ebr.STATUS ebr_status,
ebp.PRO_ID ebp_pro_id
FROM EXTRACT_BATCH_HEADERS ebr,
EXTRACT_BATCH_PROJECTS ebp,
TMP_PROJECTS tmp_ebr
WHERE ebr.ID = ebp.EBR_ID
AND ebp.PRO_ID = tmp_ebr.PRO_ID
AND ebr.USR_ID = cp_user_id
AND ebr.STATUS = cp_status) ebr_rec
WHERE pro.ID = tmp.PRO_ID
AND pro.ID = wrt_rec.wrt_pro_id(+)
AND pro.ID = pne_rec.pne_pro_id(+)
AND pro.ID = ebr_rec.ebp_pro_id(+)
ORDER BY pro.TYPE_OF_WORK DESC;
/* Cursor for order by STAGE asc*/
CURSOR c_pro_sum_stage_asc(cp_pse_id PORTAL_SERVICES.ID%TYPE,
cp_user_id USERS.ID%TYPE,
cp_status EXTRACT_BATCH_HEADERS.STATUS%TYPE,
cp_loc_lvl PORTAL_SCS.LOCATION_REPORTING_LEVEL%TYPE,
cp_last_accessed_date USERS.LAST_ACCESSED_DATE%TYPE ) IS
SELECT pro.ID id,
pro.NAME name,
pro.TYPE_OF_WORK type_of_work,
pro.STAGE stage,
DECODE(cp_loc_lvl
,'T',NVL(pro.ADDRESS_LINE_3,pro.ADDRESS_LINE_4)
,'C',pro.ADDRESS_LINE_4)||', '||
SUBSTR(POST_CODE,1,DECODE(LTRIM(INSTR(POST_CODE,' ')),0,
LENGTH(POST_CODE),LTRIM(INSTR(POST_CODE,' ')))) location,
pro.Currency currency,
pro.VALUE value,
pro.DISPLAY_VALUE display_value,
TO_CHAR(pro.LATEST_UPDATED_DATE,'DD/MM/YYYY') latest_updated_date,
DECODE(pro.LATEST_UPDATED_DATE, pro.CREATED_DATE,
'true','false')
||'~'||DECODE(SIGN(cp_last_accessed_date -
TRUNC(pro.LATEST_UPDATED_DATE)
),0,'true'
,-1,'true'
,1,'false')
||'~'||DECODE(wrt_rec.wrt_pro_id,NULL,'false','true')
||'~'||DECODE(pne_rec.pne_pro_id,NULL,'false','true')
||'~'||DECODE(ebr_rec.ebr_status,cp_status,'true','false') flags
FROM PROJECTS pro,
TMP_PROJECTS tmp,
(SELECT wrt.PRO_ID wrt_pro_id
FROM WATCH_REQUESTS wrt,
TMP_PROJECTS tmp_sub
WHERE wrt.VIEWED_DATE IS NULL
AND wrt.PSR_PSN_PSE_ID = cp_pse_id
AND wrt.PSR_USR_ID = cp_user_id
AND tmp_sub.PRO_ID = wrt.PRO_ID
GROUP BY wrt.PRO_ID) wrt_rec,
(SELECT pne.PRO_ID pne_pro_id
FROM PROJECT_NOTES pne,
TMP_PROJECTS tmp_pne
WHERE pne.USR_ID = cp_user_id
AND tmp_pne.PRO_ID = pne.PRO_ID) pne_rec,
(SELECT ebr.STATUS ebr_status,
ebp.PRO_ID ebp_pro_id
FROM EXTRACT_BATCH_HEADERS ebr,
EXTRACT_BATCH_PROJECTS ebp,
TMP_PROJECTS tmp_ebr
WHERE ebr.ID = ebp.EBR_ID
AND ebp.PRO_ID = tmp_ebr.PRO_ID
AND ebr.USR_ID = cp_user_id
AND ebr.STATUS = cp_status) ebr_rec
WHERE pro.ID = tmp.PRO_ID
AND pro.ID = wrt_rec.wrt_pro_id(+)
AND pro.ID = pne_rec.pne_pro_id(+)
AND pro.ID = ebr_rec.ebp_pro_id(+)
ORDER BY pro.STAGE;
/* Cursor for order by STAGE descending */
CURSOR c_pro_sum_stage_dsc(cp_pse_id PORTAL_SERVICES.ID%TYPE,
cp_user_id USERS.ID%TYPE,
cp_status EXTRACT_BATCH_HEADERS.STATUS%TYPE,
cp_loc_lvl PORTAL_SCS.LOCATION_REPORTING_LEVEL%TYPE,
cp_last_accessed_date USERS.LAST_ACCESSED_DATE%TYPE ) IS
SELECT pro.ID id,
pro.NAME name,
pro.TYPE_OF_WORK type_of_work,
pro.STAGE stage,
DECODE(cp_loc_lvl
,'T',NVL(pro.ADDRESS_LINE_3,pro.ADDRESS_LINE_4)
,'C',pro.ADDRESS_LINE_4)||', '||
SUBSTR(POST_CODE,1,DECODE(LTRIM(INSTR(POST_CODE,' ')),0,
LENGTH(POST_CODE),LTRIM(INSTR(POST_CODE,' ')))) location,
pro.Currency currency,
pro.VALUE value,
pro.DISPLAY_VALUE display_value,
TO_CHAR(pro.LATEST_UPDATED_DATE,'DD/MM/YYYY') latest_updated_date,
DECODE(pro.LATEST_UPDATED_DATE, pro.CREATED_DATE,
'true','false')
||'~'||DECODE(SIGN(cp_last_accessed_date -
TRUNC(pro.LATEST_UPDATED_DATE)
),0,'true'
,-1,'true'
,1,'false')
||'~'||DECODE(wrt_rec.wrt_pro_id,NULL,'false','true')
||'~'||DECODE(pne_rec.pne_pro_id,NULL,'false','true')
||'~'||DECODE(ebr_rec.ebr_status,cp_status,'true','false') flags
FROM PROJECTS pro,
TMP_PROJECTS tmp,
(SELECT wrt.PRO_ID wrt_pro_id
FROM WATCH_REQUESTS wrt,
TMP_PROJECTS tmp_sub
WHERE wrt.VIEWED_DATE IS NULL
AND wrt.PSR_PSN_PSE_ID = cp_pse_id
AND wrt.PSR_USR_ID = cp_user_id
AND tmp_sub.PRO_ID = wrt.PRO_ID
GROUP BY wrt.PRO_ID) wrt_rec,
(SELECT pne.PRO_ID pne_pro_id
FROM PROJECT_NOTES pne,
TMP_PROJECTS tmp_pne
WHERE pne.USR_ID = cp_user_id
AND tmp_pne.PRO_ID = pne.PRO_ID) pne_rec,
(SELECT ebr.STATUS ebr_status,
ebp.PRO_ID ebp_pro_id
FROM EXTRACT_BATCH_HEADERS ebr,
EXTRACT_BATCH_PROJECTS ebp,
TMP_PROJECTS tmp_ebr
WHERE ebr.ID = ebp.EBR_ID
AND ebp.PRO_ID = tmp_ebr.PRO_ID
AND ebr.USR_ID = cp_user_id
AND ebr.STATUS = cp_status) ebr_rec
WHERE pro.ID = tmp.PRO_ID
AND pro.ID = wrt_rec.wrt_pro_id(+)
AND pro.ID = pne_rec.pne_pro_id(+)
AND pro.ID = ebr_rec.ebp_pro_id(+)
ORDER BY pro.STAGE DESC;
/* Cursor for order by LOCATION asc*/
CURSOR c_pro_sum_loc_asc(cp_pse_id PORTAL_SERVICES.ID%TYPE,
cp_user_id USERS.ID%TYPE,
cp_status EXTRACT_BATCH_HEADERS.STATUS%TYPE,
cp_loc_lvl PORTAL_SCS.LOCATION_REPORTING_LEVEL%TYPE,
cp_last_accessed_date USERS.LAST_ACCESSED_DATE%TYPE ) IS
SELECT pro.ID id,
pro.NAME name,
pro.TYPE_OF_WORK type_of_work,
pro.STAGE stage,
DECODE(cp_loc_lvl
,'T',NVL(pro.ADDRESS_LINE_3,pro.ADDRESS_LINE_4)
,'C',pro.ADDRESS_LINE_4)||', '||
SUBSTR(POST_CODE,1,DECODE(LTRIM(INSTR(POST_CODE,' ')),0,
LENGTH(POST_CODE),LTRIM(INSTR(POST_CODE,' ')))) location,
pro.Currency currency,
pro.VALUE value,
pro.DISPLAY_VALUE display_value,
TO_CHAR(pro.LATEST_UPDATED_DATE,'DD/MM/YYYY') latest_updated_date,
DECODE(pro.LATEST_UPDATED_DATE, pro.CREATED_DATE,
'true','false')
||'~'||DECODE(SIGN(cp_last_accessed_date -
TRUNC(pro.LATEST_UPDATED_DATE)
),0,'true'
,-1,'true'
,1,'false')
||'~'||DECODE(wrt_rec.wrt_pro_id,NULL,'false','true')
||'~'||DECODE(pne_rec.pne_pro_id,NULL,'false','true')
||'~'||DECODE(ebr_rec.ebr_status,cp_status,'true','false') flags
FROM PROJECTS pro,
TMP_PROJECTS tmp,
(SELECT wrt.PRO_ID wrt_pro_id
FROM WATCH_REQUESTS wrt,
TMP_PROJECTS tmp_sub
WHERE wrt.VIEWED_DATE IS NULL
AND wrt.PSR_PSN_PSE_ID = cp_pse_id
AND wrt.PSR_USR_ID = cp_user_id
AND tmp_sub.PRO_ID = wrt.PRO_ID
GROUP BY wrt.PRO_ID) wrt_rec,
(SELECT pne.PRO_ID pne_pro_id
FROM PROJECT_NOTES pne,
TMP_PROJECTS tmp_pne
WHERE pne.USR_ID = cp_user_id
AND tmp_pne.PRO_ID = pne.PRO_ID) pne_rec,
(SELECT ebr.STATUS ebr_status,
ebp.PRO_ID ebp_pro_id
FROM EXTRACT_BATCH_HEADERS ebr,
EXTRACT_BATCH_PROJECTS ebp,
TMP_PROJECTS tmp_ebr
WHERE ebr.ID = ebp.EBR_ID
AND ebp.PRO_ID = tmp_ebr.PRO_ID
AND ebr.USR_ID = cp_user_id
AND ebr.STATUS = cp_status) ebr_rec
WHERE pro.ID = tmp.PRO_ID
AND pro.ID = wrt_rec.wrt_pro_id(+)
AND pro.ID = pne_rec.pne_pro_id(+)
AND pro.ID = ebr_rec.ebp_pro_id(+)
-- ORDER BY DECODE(cp_loc_lvl
-- ,'T',NVL(pro.ADDRESS_LINE_3,pro.ADDRESS_LINE_4)
-- ,'C',pro.ADDRESS_LINE_4),
ORDER BY DECODE(cp_loc_lvl
,'T',NVL(pro.ADDRESS_LINE_3,pro.ADDRESS_LINE_4)
,'C',pro.ADDRESS_LINE_4)||', '||
SUBSTR(POST_CODE,1,DECODE(LTRIM(INSTR(POST_CODE,' ')),0,
LENGTH(POST_CODE),LTRIM(INSTR(POST_CODE,' ')))),
TRUNC(pro.LATEST_UPDATED_DATE)DESC,
pro.VALUE DESC,
pro.ID DESC;
/* Cursor for order by LOCATION descending */
CURSOR c_pro_sum_loc_dsc(cp_pse_id PORTAL_SERVICES.ID%TYPE,
cp_user_id USERS.ID%TYPE,
cp_status EXTRACT_BATCH_HEADERS.STATUS%TYPE,
cp_loc_lvl PORTAL_SCS.LOCATION_REPORTING_LEVEL%TYPE,
cp_last_accessed_date USERS.LAST_ACCESSED_DATE%TYPE ) IS
SELECT pro.ID id,
pro.NAME name,
pro.TYPE_OF_WORK type_of_work,
pro.STAGE stage,
DECODE(cp_loc_lvl
,'T',NVL(pro.ADDRESS_LINE_3,pro.ADDRESS_LINE_4)
,'C',pro.ADDRESS_LINE_4)||', '||
SUBSTR(POST_CODE,1,DECODE(LTRIM(INSTR(POST_CODE,' ')),0,
LENGTH(POST_CODE),LTRIM(INSTR(POST_CODE,' ')))) location,
pro.Currency currency,
pro.VALUE value,
pro.DISPLAY_VALUE display_value,
TO_CHAR(pro.LATEST_UPDATED_DATE,'DD/MM/YYYY') latest_updated_date,
DECODE(pro.LATEST_UPDATED_DATE, pro.CREATED_DATE,
'true','false')
||'~'||DECODE(SIGN(cp_last_accessed_date -
TRUNC(pro.LATEST_UPDATED_DATE)
),0,'true'
,-1,'true'
,1,'false')
||'~'||DECODE(wrt_rec.wrt_pro_id,NULL,'false','true')
||'~'||DECODE(pne_rec.pne_pro_id,NULL,'false','true')
||'~'||DECODE(ebr_rec.ebr_status,cp_status,'true','false') flags
FROM PROJECTS pro,
TMP_PROJECTS tmp,
(SELECT wrt.PRO_ID wrt_pro_id
FROM WATCH_REQUESTS wrt,
TMP_PROJECTS tmp_sub
WHERE wrt.VIEWED_DATE IS NULL
AND wrt.PSR_PSN_PSE_ID = cp_pse_id
AND wrt.PSR_USR_ID = cp_user_id
AND tmp_sub.PRO_ID = wrt.PRO_ID
GROUP BY wrt.PRO_ID) wrt_rec,
(SELECT pne.PRO_ID pne_pro_id
FROM PROJECT_NOTES pne,
TMP_PROJECTS tmp_pne
WHERE pne.USR_ID = cp_user_id
AND tmp_pne.PRO_ID = pne.PRO_ID) pne_rec,
(SELECT ebr.STATUS ebr_status,
ebp.PRO_ID ebp_pro_id
FROM EXTRACT_BATCH_HEADERS ebr,
EXTRACT_BATCH_PROJECTS ebp,
TMP_PROJECTS tmp_ebr
WHERE ebr.ID = ebp.EBR_ID
AND ebp.PRO_ID = tmp_ebr.PRO_ID
AND ebr.USR_ID = cp_user_id
AND ebr.STATUS = cp_status) ebr_rec
WHERE pro.ID = tmp.PRO_ID
AND pro.ID = wrt_rec.wrt_pro_id(+)
AND pro.ID = pne_rec.pne_pro_id(+)
AND pro.ID = ebr_rec.ebp_pro_id(+)
-- ORDER BY DECODE(cp_loc_lvl
-- ,'T',NVL(pro.ADDRESS_LINE_3,pro.ADDRESS_LINE_4)
-- ,'C',pro.ADDRESS_LINE_4) DESC,
ORDER BY DECODE(cp_loc_lvl
,'T',NVL(pro.ADDRESS_LINE_3,pro.ADDRESS_LINE_4)
,'C',pro.ADDRESS_LINE_4)||', '||
SUBSTR(POST_CODE,1,DECODE(LTRIM(INSTR(POST_CODE,' ')),0,
LENGTH(POST_CODE),LTRIM(INSTR(POST_CODE,' ')))) DESC,
TRUNC(pro.LATEST_UPDATED_DATE) DESC,
pro.VALUE DESC,
pro.ID DESC;
/* Cursor for order by VALUE asc*/
CURSOR c_pro_sum_val_asc(cp_pse_id PORTAL_SERVICES.ID%TYPE,
cp_user_id USERS.ID%TYPE,
cp_status EXTRACT_BATCH_HEADERS.STATUS%TYPE,
cp_loc_lvl PORTAL_SCS.LOCATION_REPORTING_LEVEL%TYPE,
cp_last_accessed_date USERS.LAST_ACCESSED_DATE%TYPE ) IS
SELECT pro.ID id,
pro.NAME name,
pro.TYPE_OF_WORK type_of_work,
pro.STAGE stage,
DECODE(cp_loc_lvl
,'T',NVL(pro.ADDRESS_LINE_3,pro.ADDRESS_LINE_4)
,'C',pro.ADDRESS_LINE_4)||', '||
SUBSTR(POST_CODE,1,DECODE(LTRIM(INSTR(POST_CODE,' ')),0,
LENGTH(POST_CODE),LTRIM(INSTR(POST_CODE,' ')))) location,
pro.Currency currency,
pro.VALUE value,
pro.DISPLAY_VALUE display_value,
TO_CHAR(pro.LATEST_UPDATED_DATE,'DD/MM/YYYY') latest_updated_date,
DECODE(pro.LATEST_UPDATED_DATE, pro.CREATED_DATE,
'true','false')
||'~'||DECODE(SIGN(cp_last_accessed_date -
TRUNC(pro.LATEST_UPDATED_DATE)
),0,'true'
,-1,'true'
,1,'false')
||'~'||DECODE(wrt_rec.wrt_pro_id,NULL,'false','true')
||'~'||DECODE(pne_rec.pne_pro_id,NULL,'false','true')
||'~'||DECODE(ebr_rec.ebr_status,cp_status,'true','false') flags
FROM PROJECTS pro,
TMP_PROJECTS tmp,
(SELECT wrt.PRO_ID wrt_pro_id
FROM WATCH_REQUESTS wrt,
TMP_PROJECTS tmp_sub
WHERE wrt.VIEWED_DATE IS NULL
AND wrt.PSR_PSN_PSE_ID = cp_pse_id
AND wrt.PSR_USR_ID = cp_user_id
AND tmp_sub.PRO_ID = wrt.PRO_ID
GROUP BY wrt.PRO_ID) wrt_rec,
(SELECT pne.PRO_ID pne_pro_id
FROM PROJECT_NOTES pne,
TMP_PROJECTS tmp_pne
WHERE pne.USR_ID = cp_user_id
AND tmp_pne.PRO_ID = pne.PRO_ID) pne_rec,
(SELECT ebr.STATUS ebr_status,
ebp.PRO_ID ebp_pro_id
FROM EXTRACT_BATCH_HEADERS ebr,
EXTRACT_BATCH_PROJECTS ebp,
TMP_PROJECTS tmp_ebr
WHERE ebr.ID = ebp.EBR_ID
AND ebp.PRO_ID = tmp_ebr.PRO_ID
AND ebr.USR_ID = cp_user_id
AND ebr.STATUS = cp_status) ebr_rec
WHERE pro.ID = tmp.PRO_ID
AND pro.ID = wrt_rec.wrt_pro_id(+)
AND pro.ID = pne_rec.pne_pro_id(+)
AND pro.ID = ebr_rec.ebp_pro_id(+)
ORDER BY pro.VALUE,
TRUNC(pro.LATEST_UPDATED_DATE),
-- DECODE(cp_loc_lvl
-- ,'T',NVL(pro.ADDRESS_LINE_3,pro.ADDRESS_LINE_4)
-- ,'C',pro.ADDRESS_LINE_4),
DECODE(cp_loc_lvl
,'T',NVL(pro.ADDRESS_LINE_3,pro.ADDRESS_LINE_4)
,'C',pro.ADDRESS_LINE_4)||', '||
SUBSTR(POST_CODE,1,DECODE(LTRIM(INSTR(POST_CODE,' ')),0,
LENGTH(POST_CODE),LTRIM(INSTR(POST_CODE,' ')))),
pro.ID DESC;
/* Cursor for order by VALUE descending */
CURSOR c_pro_sum_val_dsc(cp_pse_id PORTAL_SERVICES.ID%TYPE,
cp_user_id USERS.ID%TYPE,
cp_status EXTRACT_BATCH_HEADERS.STATUS%TYPE,
cp_loc_lvl PORTAL_SCS.LOCATION_REPORTING_LEVEL%TYPE,
cp_last_accessed_date USERS.LAST_ACCESSED_DATE%TYPE ) IS
SELECT pro.ID id,
pro.NAME name,
pro.TYPE_OF_WORK type_of_work,
pro.STAGE stage,
DECODE(cp_loc_lvl
,'T',NVL(pro.ADDRESS_LINE_3,pro.ADDRESS_LINE_4)
,'C',pro.ADDRESS_LINE_4)||', '||
SUBSTR(POST_CODE,1,DECODE(LTRIM(INSTR(POST_CODE,' ')),0,
LENGTH(POST_CODE),LTRIM(INSTR(POST_CODE,' ')))) location,
pro.Currency currency,
pro.VALUE value,
pro.DISPLAY_VALUE display_value,
TO_CHAR(pro.LATEST_UPDATED_DATE,'DD/MM/YYYY') latest_updated_date,
DECODE(pro.LATEST_UPDATED_DATE, pro.CREATED_DATE,
'true','false')
||'~'||DECODE(SIGN(cp_last_accessed_date -
TRUNC(pro.LATEST_UPDATED_DATE)
),0,'true'
,-1,'true'
,1,'false')
||'~'||DECODE(wrt_rec.wrt_pro_id,NULL,'false','true')
||'~'||DECODE(pne_rec.pne_pro_id,NULL,'false','true')
||'~'||DECODE(ebr_rec.ebr_status,cp_status,'true','false') flags
FROM PROJECTS pro,
TMP_PROJECTS tmp,
(SELECT wrt.PRO_ID wrt_pro_id
FROM WATCH_REQUESTS wrt,
TMP_PROJECTS tmp_sub
WHERE wrt.VIEWED_DATE IS NULL
AND wrt.PSR_PSN_PSE_ID = cp_pse_id
AND wrt.PSR_USR_ID = cp_user_id
AND tmp_sub.PRO_ID = wrt.PRO_ID
GROUP BY wrt.PRO_ID) wrt_rec,
(SELECT pne.PRO_ID pne_pro_id
FROM PROJECT_NOTES pne,
TMP_PROJECTS tmp_pne
WHERE pne.USR_ID = cp_user_id
AND tmp_pne.PRO_ID = pne.PRO_ID) pne_rec,
(SELECT ebr.STATUS ebr_status,
ebp.PRO_ID ebp_pro_id
FROM EXTRACT_BATCH_HEADERS ebr,
EXTRACT_BATCH_PROJECTS ebp,
TMP_PROJECTS tmp_ebr
WHERE ebr.ID = ebp.EBR_ID
AND ebp.PRO_ID = tmp_ebr.PRO_ID
AND ebr.USR_ID = cp_user_id
AND ebr.STATUS = cp_status) ebr_rec
WHERE pro.ID = tmp.PRO_ID
AND pro.ID = wrt_rec.wrt_pro_id(+)
AND pro.ID = pne_rec.pne_pro_id(+)
AND pro.ID = ebr_rec.ebp_pro_id(+)
ORDER BY pro.VALUE DESC,
TRUNC(pro.LATEST_UPDATED_DATE) DESC,
-- DECODE(cp_loc_lvl
-- ,'T',NVL(pro.ADDRESS_LINE_3,pro.ADDRESS_LINE_4)
-- ,'C',pro.ADDRESS_LINE_4),
DECODE(cp_loc_lvl
,'T',NVL(pro.ADDRESS_LINE_3,pro.ADDRESS_LINE_4)
,'C',pro.ADDRESS_LINE_4)||', '||
SUBSTR(POST_CODE,1,DECODE(LTRIM(INSTR(POST_CODE,' ')),0,
LENGTH(POST_CODE),LTRIM(INSTR(POST_CODE,' ')))),
pro.ID DESC;
/* Cursor for order by LATEST_UPDATED_DATE asc*/
CURSOR c_pro_sum_lud_asc(cp_pse_id PORTAL_SERVICES.ID%TYPE,
cp_user_id USERS.ID%TYPE,
cp_status EXTRACT_BATCH_HEADERS.STATUS%TYPE,
cp_loc_lvl PORTAL_SCS.LOCATION_REPORTING_LEVEL%TYPE,
cp_last_accessed_date USERS.LAST_ACCESSED_DATE%TYPE ) IS
SELECT pro.ID id,
pro.NAME name,
pro.TYPE_OF_WORK type_of_work,
pro.STAGE stage,
DECODE(cp_loc_lvl
,'T',NVL(pro.ADDRESS_LINE_3,pro.ADDRESS_LINE_4)
,'C',pro.ADDRESS_LINE_4)||', '||
SUBSTR(POST_CODE,1,DECODE(LTRIM(INSTR(POST_CODE,' ')),0,
LENGTH(POST_CODE),LTRIM(INSTR(POST_CODE,' ')))) location,
pro.Currency currency,
pro.VALUE value,
pro.DISPLAY_VALUE display_value,
TO_CHAR(pro.LATEST_UPDATED_DATE,'DD/MM/YYYY') latest_updated_date,
DECODE(pro.LATEST_UPDATED_DATE, pro.CREATED_DATE,
'true','false')
||'~'||DECODE(SIGN(cp_last_accessed_date -
TRUNC(pro.LATEST_UPDATED_DATE)
),0,'true'
,-1,'true'
,1,'false')
||'~'||DECODE(wrt_rec.wrt_pro_id,NULL,'false','true')
||'~'||DECODE(pne_rec.pne_pro_id,NULL,'false','true')
||'~'||DECODE(ebr_rec.ebr_status,cp_status,'true','false') flags
FROM PROJECTS pro,
TMP_PROJECTS tmp,
(SELECT wrt.PRO_ID wrt_pro_id
FROM WATCH_REQUESTS wrt,
TMP_PROJECTS tmp_sub
WHERE wrt.VIEWED_DATE IS NULL
AND wrt.PSR_PSN_PSE_ID = cp_pse_id
AND wrt.PSR_USR_ID = cp_user_id
AND tmp_sub.PRO_ID = wrt.PRO_ID
GROUP BY wrt.PRO_ID) wrt_rec,
(SELECT pne.PRO_ID pne_pro_id
FROM PROJECT_NOTES pne,
TMP_PROJECTS tmp_pne
WHERE pne.USR_ID = cp_user_id
AND tmp_pne.PRO_ID = pne.PRO_ID) pne_rec,
(SELECT ebr.STATUS ebr_status,
ebp.PRO_ID ebp_pro_id
FROM EXTRACT_BATCH_HEADERS ebr,
EXTRACT_BATCH_PROJECTS ebp,
TMP_PROJECTS tmp_ebr
WHERE ebr.ID = ebp.EBR_ID
AND ebp.PRO_ID = tmp_ebr.PRO_ID
AND ebr.USR_ID = cp_user_id
AND ebr.STATUS = cp_status) ebr_rec
WHERE pro.ID = tmp.PRO_ID
AND pro.ID = wrt_rec.wrt_pro_id(+)
AND pro.ID = pne_rec.pne_pro_id(+)
AND pro.ID = ebr_rec.ebp_pro_id(+)
ORDER BY TRUNC(pro.LATEST_UPDATED_DATE),
pro.VALUE DESC,
-- DECODE(cp_loc_lvl
-- ,'T',NVL(pro.ADDRESS_LINE_3,pro.ADDRESS_LINE_4)
-- ,'C',pro.ADDRESS_LINE_4),
DECODE(cp_loc_lvl
,'T',NVL(pro.ADDRESS_LINE_3,pro.ADDRESS_LINE_4)
,'C',pro.ADDRESS_LINE_4)||', '||
SUBSTR(POST_CODE,1,DECODE(LTRIM(INSTR(POST_CODE,' ')),0,
LENGTH(POST_CODE),LTRIM(INSTR(POST_CODE,' ')))),
pro.ID DESC;
/* Cursor for order by LATEST_UPDATED_DATE descending*/
CURSOR c_pro_sum_lud_dsc(cp_pse_id PORTAL_SERVICES.ID%TYPE,
cp_user_id USERS.ID%TYPE,
cp_status EXTRACT_BATCH_HEADERS.STATUS%TYPE,
cp_loc_lvl PORTAL_SCS.LOCATION_REPORTING_LEVEL%TYPE,
cp_last_accessed_date USERS.LAST_ACCESSED_DATE%TYPE ) IS
SELECT pro.ID id,
pro.NAME name,
pro.TYPE_OF_WORK type_of_work,
pro.STAGE stage,
DECODE(cp_loc_lvl
,'T',NVL(pro.ADDRESS_LINE_3,pro.ADDRESS_LINE_4)
,'C',pro.ADDRESS_LINE_4)||', '||
SUBSTR(POST_CODE,1,DECODE(LTRIM(INSTR(POST_CODE,' ')),0,
LENGTH(POST_CODE),LTRIM(INSTR(POST_CODE,' ')))) location,
pro.Currency currency,
pro.VALUE value,
pro.DISPLAY_VALUE display_value,
TO_CHAR(pro.LATEST_UPDATED_DATE,'DD/MM/YYYY') latest_updated_date,
DECODE(pro.LATEST_UPDATED_DATE, pro.CREATED_DATE,
'true','false')
||'~'||DECODE(SIGN(cp_last_accessed_date -
TRUNC(pro.LATEST_UPDATED_DATE)
),0,'true'
,-1,'true'
,1,'false')
||'~'||DECODE(wrt_rec.wrt_pro_id,NULL,'false','true')
||'~'||DECODE(pne_rec.pne_pro_id,NULL,'false','true')
||'~'||DECODE(ebr_rec.ebr_status,cp_status,'true','false') flags
FROM PROJECTS pro,
TMP_PROJECTS tmp,
(SELECT wrt.PRO_ID wrt_pro_id
FROM WATCH_REQUESTS wrt,
TMP_PROJECTS tmp_sub
WHERE wrt.VIEWED_DATE IS NULL
AND wrt.PSR_PSN_PSE_ID = cp_pse_id
AND wrt.PSR_USR_ID = cp_user_id
AND tmp_sub.PRO_ID = wrt.PRO_ID
GROUP BY wrt.PRO_ID) wrt_rec,
(SELECT pne.PRO_ID pne_pro_id
FROM PROJECT_NOTES pne,
TMP_PROJECTS tmp_pne
WHERE pne.USR_ID = cp_user_id
AND tmp_pne.PRO_ID = pne.PRO_ID) pne_rec,
(SELECT ebr.STATUS ebr_status,
ebp.PRO_ID ebp_pro_id
FROM EXTRACT_BATCH_HEADERS ebr,
EXTRACT_BATCH_PROJECTS ebp,
TMP_PROJECTS tmp_ebr
WHERE ebr.ID = ebp.EBR_ID
AND ebp.PRO_ID = tmp_ebr.PRO_ID
AND ebr.USR_ID = cp_user_id
AND ebr.STATUS = cp_status) ebr_rec
WHERE pro.ID = tmp.PRO_ID
AND pro.ID = wrt_rec.wrt_pro_id(+)
AND pro.ID = pne_rec.pne_pro_id(+)
AND pro.ID = ebr_rec.ebp_pro_id(+)
ORDER BY TRUNC(pro.LATEST_UPDATED_DATE) DESC,
pro.VALUE DESC,
-- DECODE(cp_loc_lvl
-- ,'T',NVL(pro.ADDRESS_LINE_3,pro.ADDRESS_LINE_4)
-- ,'C',pro.ADDRESS_LINE_4),
DECODE(cp_loc_lvl
,'T',NVL(pro.ADDRESS_LINE_3,pro.ADDRESS_LINE_4)
,'C',pro.ADDRESS_LINE_4)||', '||
SUBSTR(POST_CODE,1,DECODE(LTRIM(INSTR(POST_CODE,' ')),0,
LENGTH(POST_CODE),LTRIM(INSTR(POST_CODE,' ')))),
pro.ID DESC;
/* Local Variables */
v_tt_pro_id DS$REF.TT_PRO_ID;
v_first PROJECTS.ID%TYPE := p_project_id_arr.FIRST;
v_last PROJECTS.ID%TYPE := 0;
v_project_id_count PROJECTS.ID%TYPE := p_project_id_arr.COUNT;
v_page_count PROJECTS.ID%TYPE := 0;
v_delimter CONSTANT VARCHAR2(1) := '|';
v_sort_no NUMBER;
v_sort_order VARCHAR2(4);
v_sort_by_column VARCHAR2(30);
v_last_accessed_date USERS.LAST_ACCESSED_DATE%TYPE;
v_loc_level PORTAL_SCS.LOCATION_REPORTING_LEVEL%TYPE;
/* Variables for Error handling */
v_location ERROR_LOGS.LOCATION%TYPE := ' :: 0';
v_module CONSTANT VARCHAR2(25) := 'DS$234.DS$2342_PROC';
e_user_defined_excep EXCEPTION;
PRAGMA EXCEPTION_INIT (e_user_defined_excep, -20001);
/* Variables for Timestamp logging */
v_tpg_id NUMBER;
v_start_time NUMBER;
v_tt_location DS$REF.TT_VARCHAR2;
BEGIN
v_location := ' :: 1';
/*Dynamically change the sort area size to 64 mb */
EXECUTE IMMEDIATE 'ALTER SESSION SET SORT_AREA_SIZE = 67108864';
v_location := ' :: 1a';
-- Call to timestamp log procedure for logging start time.
DS$226.DS$2261_PROC(p_usr_id => p_user_id,
p_module_name => v_module,
p_call_by_module => 'ds_projectlist_bl.jsp',
p_caller_module => NULL,
o_tpg_id => v_tpg_id,
o_start_time => v_start_time);
v_location := ' 1a';
v_last_accessed_date :=TRUNC(TO_DATE(p_last_accessed_date,'DD MON YYYY HH24:MI:SS'));
v_location := ' 2';
v_sort_no := SUBSTR(p_sort_order,
1,
INSTR(p_sort_order, v_delimter,1) - 1
v_sort_order := SUBSTR(p_sort_order,
INSTR(p_sort_order,v_delimter,1)+ 1
v_page_count := CEIL(((p_project_id_arr.COUNT)/p_records_per_page));
v_location := ' 3';
FOR j IN 1..v_page_count
LOOP
v_location := ' 4';
v_first := v_first;
v_last := v_first + (p_records_per_page - 1);
IF (v_last >= v_project_id_count)
THEN
v_last := v_project_id_count;
ELSE
v_last := v_first + (p_records_per_page - 1);
END IF;
IF (j = p_page_no)
THEN
v_location := ' 5';
EXIT;
END IF;
v_location := ' 6';
v_first := v_last + 1;
v_location := ' 7';
END LOOP;
v_location := ' 8';
FORALL i IN v_first..v_last
INSERT INTO TMP_PROJECTS VALUES(p_project_id_arr(i));
FORALL i IN p_project_id_arr.FIRST..p_project_id_arr.LAST
INSERT INTO TMP_PROJECTS VALUES(p_project_id_arr(i));
v_location := ' 9';
OPEN c_psc(p_pse_id);
LOOP
FETCH c_psc INTO v_loc_level;
EXIT WHEN c_psc%NOTFOUND;
IF c_psc%ROWCOUNT > 1
THEN
v_location := ' 10';
CLOSE c_psc;
RAISE_APPLICATION_ERROR(-20001,'PLS-00234201');
END IF;
END LOOP;
CLOSE c_psc;
v_location := ' 11';
IF v_loc_level IS NULL
THEN
v_location := ' 12';
RAISE_APPLICATION_ERROR(-20001,'PLS-00234202');
END IF;
IF (v_sort_no = 1)
THEN
v_location := ' 13';
IF (v_sort_order ='ASC' )
THEN
v_location := ' 14';
IF c_projects_name_order_asc%ISOPEN
THEN
CLOSE c_projects_name_order_asc;
END IF;
OPEN c_projects_name_order_asc;
v_location := ' 15';
FETCH c_projects_name_order_asc BULK COLLECT INTO v_tt_pro_id;
v_location := ' 16';
CLOSE c_projects_name_order_asc;
/* Assign the Sorted project ids to O/P parameter O_PRO_ALL_ID_ARRAY for fast scan */
v_location := ' 17';
o_pro_all_id_array := v_tt_pro_id;
/* Delete records from temporary table TMP_PROJECTS */
v_location := ' 18';
DELETE FROM TMP_PROJECTS;
/* Insert records into TMP_PROJECTS as per the page number (p_page_no) */
v_location := ' 19';
FORALL i IN v_first..v_last
INSERT INTO TMP_PROJECTS VALUES(v_tt_pro_id(i));
v_location := ' 20';
OPEN c_pro_sum_name_asc(p_pse_id,p_user_id,v_status,v_loc_level,v_last_accessed_date);
v_location := ' 21';
FETCH c_pro_sum_name_asc BULK COLLECT INTO o_pro_id_array,
o_name_array,
o_type_of_work_array,
o_stage_array,
o_loc_array,
o_currency_array,
o_value_array,
o_display_value_array,
o_latest_updated_date_array,
o_flag_array;
CLOSE c_pro_sum_name_asc;
ELSE
v_location := ' 22';
IF c_projects_name_order_desc%ISOPEN
THEN
CLOSE c_projects_name_order_desc;
END IF;
OPEN c_projects_name_order_desc;
v_location := ' 23';
FETCH c_projects_name_order_desc BULK COLLECT INTO v_tt_pro_id;
CLOSE c_projects_name_order_desc;
/* Assign the Sorted project ids to O/P parameter O_PRO_ALL_ID_ARRAY for fast scan */
v_location := ' 24';
o_pro_all_id_array := v_tt_pro_id;
/*Delete records from temporary table TMP_PROJECTS */
v_location := ' 25';
DELETE FROM TMP_PROJECTS;
/* Insert records into TMP_PROJECTS as per the page number (p_page_no) */
v_location := ' 26';
FORALL i IN v_first..v_last
INSERT INTO TMP_PROJECTS VALUES(v_tt_pro_id(i));
v_location := ' 27';
OPEN c_pro_sum_name_dsc(p_pse_id,p_user_id,v_status,v_loc_level,v_last_accessed_date);
v_location := ' 28';
FETCH c_pro_sum_name_dsc BULK COLLECT INTO o_pro_id_array,
o_name_array,
o_type_of_work_array,
o_stage_array,
o_loc_array,
o_currency_array,
o_value_array,
o_display_value_array,
o_latest_updated_date_array,
o_flag_array;
CLOSE c_pro_sum_name_dsc;
END IF;
ELSIF (v_sort_no = 2)
THEN
v_location := ' 29';
IF (v_sort_order ='ASC' )
THEN
v_location := ' 30';
IF c_projects_work_order_asc%ISOPEN
THEN
CLOSE c_projects_work_order_asc;
END IF;
OPEN c_projects_work_order_asc;
v_location := ' 31';
FETCH c_projects_work_order_asc BULK COLLECT INTO v_tt_pro_id;
CLOSE c_projects_work_order_asc;
/* Assign the Sorted project ids to O/P parameter O_PRO_ALL_ID_ARRAY for fast scan */
v_location := ' 32';
o_pro_all_id_array := v_tt_pro_id;
/* Delete records from temporary table TMP_PROJECTS */
DELETE FROM TMP_PROJECTS;
/* Insert records into TMP_PROJECTS as per the page number (p_page_no) */
v_location := ' 33';
FORALL i IN v_first..v_last
INSERT INTO TMP_PROJECTS VALUES(v_tt_pro_id(i));
v_location := ' 34';
OPEN c_pro_sum_work_asc(p_pse_id,p_user_id,v_status,v_loc_level,v_last_accessed_date);
v_location := ' 35';
FETCH c_pro_sum_work_asc BULK COLLECT INTO o_pro_id_array,
o_name_array,
o_type_of_work_array,
o_stage_array,
o_loc_array,
o_currency_array,
o_value_array,
o_display_value_array,
o_latest_updated_date_array,
o_flag_array;
CLOSE c_pro_sum_work_asc;
ELSE
v_location := ' 36';
IF c_projects_work_order_desc%ISOPEN
THEN
CLOSE c_projects_work_order_desc;
END IF;
OPEN c_projects_work_order_desc;
v_location := ' 37';
FETCH c_projects_work_order_desc BULK COLLECT INTO v_tt_pro_id;
CLOSE c_projects_work_order_desc;
/* Assign the Sorted project ids to O/P parameter O_PRO_ALL_ID_ARRAY for fast scan */
v_location := ' 38';
o_pro_all_id_array := v_tt_pro_id;
/* Delete records from temporary table TMP_PROJECTS */
v_location := ' 39';
DELETE FROM TMP_PROJECTS;
/* Insert records into TMP_PROJECTS as per the page number (p_page_no) */
v_location := ' 40';
FORALL i IN v_first..v_last
INSERT INTO TMP_PROJECTS VALUES(v_tt_pro_id(i));
v_location := ' 41';
OPEN c_pro_sum_work_dsc(p_pse_id,p_user_id,v_status,v_loc_level,v_last_accessed_date);
v_location := ' 42';
FETCH c_pro_sum_work_dsc BULK COLLECT INTO o_pro_id_array,
o_name_array,
o_type_of_work_array,
o_stage_array,
o_loc_array,
o_currency_array,
o_value_array,
o_display_value_array,
o_latest_updated_date_array,
o_flag_array;
CLOSE c_pro_sum_work_dsc;
END IF;
ELSIF (v_sort_no = 3)
THEN
v_location := ' 43';
IF (v_sort_order ='ASC' )
THEN
v_location := ' 44';
IF c_projects_stage_order_asc%ISOPEN
THEN
CLOSE c_projects_stage_order_asc;
END IF;
OPEN c_projects_stage_order_asc;
v_location := ' 45';
FETCH c_projects_stage_order_asc BULK COLLECT INTO v_tt_pro_id;
CLOSE c_projects_stage_order_asc;
/* Assign the Sorted project ids to O/P parameter O_PRO_ALL_ID_ARRAY for fast scan */
v_location := ' 46';
o_pro_all_id_array := v_tt_pro_id;
/* Delete records from temporary table TMP_PROJECTS */
v_location := ' 47';
DELETE FROM TMP_PROJECTS;
/* Insert records into TMP_PROJECTS as per the page number (p_page_no) */
v_location := ' 48';
FORALL i IN v_first..v_last
INSERT INTO TMP_PROJECTS VALUES(v_tt_pro_id(i));
v_location := ' 49';
OPEN c_pro_sum_stage_asc(p_pse_id,p_user_id,v_status,v_loc_level,v_last_accessed_date);
v_location := ' 50';
FETCH c_pro_sum_stage_asc BULK COLLECT INTO o_pro_id_array,
o_name_array,
o_type_of_work_array,
o_stage_array,
o_loc_array,
o_currency_array,
o_value_array,
o_display_value_array,
o_latest_updated_date_array,
o_flag_array;
CLOSE c_pro_sum_stage_asc;
ELSE
v_location := ' 51';
IF c_projects_stage_order_desc%ISOPEN
THEN
CLOSE c_projects_stage_order_desc;
END IF;
OPEN c_projects_stage_order_desc;
v_location := ' 52';
FETCH c_projects_stage_order_desc BULK COLLECT INTO v_tt_pro_id;
CLOSE c_projects_stage_order_desc;
/* Assign the Sorted project ids to O/P parameter O_PRO_ALL_ID_ARRAY for fast scan */
v_location := ' 53';
o_pro_all_id_array := v_tt_pro_id;
/* Delete records from temporary table TMP_PROJECTS */
v_location := ' 54';
DELETE FROM TMP_PROJECTS;
/* Insert records into TMP_PROJECTS as per the page number (p_page_no) */
v_location := ' 55';
FORALL i IN v_first..v_last
INSERT INTO TMP_PROJECTS VALUES(v_tt_pro_id(i));
v_location := ' 56';
OPEN c_pro_sum_stage_dsc(p_pse_id,p_user_id,v_status,v_loc_level,v_last_accessed_date);
v_location := ' 57';
FETCH c_pro_sum_stage_dsc BULK COLLECT INTO o_pro_id_array,
o_name_array,
o_type_of_work_array,
o_stage_array,
o_loc_array,
o_currency_array,
o_value_array,
o_display_value_array,
o_latest_updated_date_array,
o_flag_array;
CLOSE c_pro_sum_stage_dsc;
END IF;
ELSIF (v_sort_no = 4)
THEN
v_location := ' 58';
IF (v_sort_order ='ASC' )
THEN
IF c_projects_loc_order_asc%ISOPEN
THEN
CLOSE c_projects_loc_order_asc;
END IF;
OPEN c_projects_loc_order_asc(v_loc_level);
v_location := ' 59';
FETCH c_projects_loc_order_asc BULK COLLECT INTO v_tt_pro_id,v_tt_location;
CLOSE c_projects_loc_order_asc;
/* Assign the Sorted project ids to O/P parameter O_PRO_ALL_ID_ARRAY,O_LOCATION for fast scan */
v_location := ' 60';
o_pro_all_id_array := v_tt_pro_id;
o_location := v_tt_location;
/* Delete records from temporary table TMP_PROJECTS */
v_location := ' 61';
DELETE FROM TMP_PROJECTS;
/* Insert records into TMP_PROJECTS as per the page number (p_page_no) */
v_location := ' 62';
FORALL i IN v_first..v_last
INSERT INTO TMP_PROJECTS VALUES(v_tt_pro_id(i));
v_location := ' 63';
OPEN c_pro_sum_loc_asc(p_pse_id,p_user_id,v_status,v_loc_level,v_last_accessed_date);
v_location := ' 64';
FETCH c_pro_sum_loc_asc BULK COLLECT INTO o_pro_id_array,
o_name_array,
o_type_of_work_array,
o_stage_array,
o_loc_array,
o_currency_array,
o_value_array,
o_display_value_array,
o_latest_updated_date_array,
o_flag_array;
CLOSE c_pro_sum_loc_asc;
ELSE
v_location := ' 65';
IF c_projects_loc_order_desc%ISOPEN
THEN
CLOSE c_projects_loc_order_desc;
END IF;
OPEN c_projects_loc_order_desc (v_loc_level);
v_location := ' 66';
FETCH c_projects_loc_order_desc BULK COLLECT INTO v_tt_pro_id,v_tt_location;
CLOSE c_projects_loc_order_desc;
/* Assign the Sorted project ids to O/P parameter O_PRO_ALL_ID_ARRAY,O_LOCATION for fast scan */
v_location := ' 67';
o_pro_all_id_array := v_tt_pro_id;
o_location := v_tt_location;
/* Delete records from temporary table TMP_PROJECTS */
DELETE FROM TMP_PROJECTS;
/* Insert records into TMP_PROJECTS as per the page number (p_page_no) */
v_location := ' 68';
FORALL i IN v_first..v_last
INSERT INTO TMP_PROJECTS VALUES(v_tt_pro_id(i));
v_location := ' 69';
OPEN c_pro_sum_loc_dsc(p_pse_id,p_user_id,v_status,v_loc_level,v_last_accessed_date);
v_location := ' 70';
FETCH c_pro_sum_loc_dsc BULK COLLECT INTO o_pro_id_array,
o_name_array,
o_type_of_work_array,
o_stage_array,
o_loc_array,
o_currency_array,
o_value_array,
o_display_value_array,
o_latest_updated_date_array,
o_flag_array;
CLOSE c_pro_sum_loc_dsc;
END IF;
ELSIF (v_sort_no = 5)
THEN
v_location := ' 71';
IF (v_sort_order ='ASC' )
THEN
v_location := ' 72';
IF c_projects_value_order_asc%ISOPEN
THEN
CLOSE c_projects_value_order_asc;
END IF;
OPEN c_projects_value_order_asc(v_loc_level);
v_location := ' 73';
FETCH c_projects_value_order_asc BULK COLLECT INTO v_tt_pro_id,v_tt_location;
CLOSE c_projects_value_order_asc;
/* Assign the Sorted project ids to O/P parameter O_PRO_ALL_ID_ARRAY for fast scan */
v_location := ' 74';
o_pro_all_id_array := v_tt_pro_id;
o_location := v_tt_location;
/* Delete records from temporary table TMP_PROJECTS */
DELETE FROM TMP_PROJECTS;
/* Insert records into TMP_PROJECTS as per the page number (p_page_no) */
v_location := ' 75';
FORALL i IN v_first..v_last
INSERT INTO TMP_PROJECTS VALUES(v_tt_pro_id(i));
v_location := ' 76';
OPEN c_pro_sum_val_asc(p_pse_id,p_user_id,v_status,v_loc_level,v_last_accessed_date);
v_location := ' 77';
FETCH c_pro_sum_val_asc BULK COLLECT INTO o_pro_id_array,
o_name_array,
o_type_of_work_array,
o_stage_array,
o_loc_array,
o_currency_array,
o_value_array,
o_display_value_array,
o_latest_updated_date_array,
o_flag_array;
CLOSE c_pro_sum_val_asc;
ELSE
v_location := ' 78';
IF c_projects_value_order_desc%ISOPEN
THEN
CLOSE c_projects_value_order_desc;
END IF;
OPEN c_projects_value_order_desc(v_loc_level);
v_location := ' 79';
FETCH c_projects_value_order_desc BULK COLLECT INTO v_tt_pro_id,v_tt_location;
CLOSE c_projects_value_order_desc;
/* Assign the Sorted project ids to O/P parameter O_PRO_ALL_ID_ARRAY for fast scan */
v_location := ' 80';
o_pro_all_id_array := v_tt_pro_id;
o_location := v_tt_location;
/* Delete records from temporary table TMP_PROJECTS */
DELETE FROM TMP_PROJECTS;
/* Insert records into TMP_PROJECTS as per the page number (p_page_no) */
v_location := ' 81';
FORALL i IN v_first..v_last
INSERT INTO TMP_PROJECTS VALUES(v_tt_pro_id(i));
v_location := ' 82';
OPEN c_pro_sum_val_dsc(p_pse_id,p_user_id,v_status,v_loc_level,v_last_accessed_date);
FETCH c_pro_sum_val_dsc BULK COLLECT INTO o_pro_id_array,
o_name_array,
o_type_of_work_array,
o_stage_array,
o_loc_array,
o_currency_array,
o_value_array,
o_display_value_array,
o_latest_updated_date_array,
o_flag_array;
CLOSE c_pro_sum_val_dsc;
END IF;
ELSIF (v_sort_no = 6)
THEN
v_location := ' 83';
IF (v_sort_order ='ASC' )
THEN
v_location := ' 84';
IF c_projects_lud_order_asc%ISOPEN
THEN
CLOSE c_projects_lud_order_asc;
END IF;
OPEN c_projects_lud_order_asc(v_loc_level);
v_location := ' 85';
FETCH c_projects_lud_order_asc BULK COLLECT INTO v_tt_pro_id,v_tt_location;
CLOSE c_projects_lud_order_asc;
/* Assign the Sorted project ids to O/P parameter O_PRO_ALL_ID_ARRAY for fast scan */
v_location := ' 86';
o_pro_all_id_array := v_tt_pro_id;
o_location := v_tt_location;
/* Delete records from temporary table TMP_PROJECTS */
DELETE FROM TMP_PROJECTS;
/* Insert records into TMP_PROJECTS as per the page number (p_page_no) */
v_location := ' 87';
FORALL i IN v_first..v_last
INSERT INTO TMP_PROJECTS VALUES(v_tt_pro_id(i));
v_location := ' 88';
OPEN c_pro_sum_lud_asc(p_pse_id,p_user_id,v_status,v_loc_level,v_last_accessed_date);
FETCH c_pro_sum_lud_asc BULK COLLECT INTO o_pro_id_array,
o_name_array,
o_type_of_work_array,
o_stage_array,
o_loc_array,
o_currency_array,
o_value_array,
o_display_value_array,
o_latest_updated_date_array,
o_flag_array;
CLOSE c_pro_sum_lud_asc;
ELSE
v_location := ' 89';
IF c_projects_lud_order_desc%ISOPEN
THEN
CLOSE c_projects_lud_order_desc;
END IF;
OPEN c_projects_lud_order_desc(v_loc_level);
v_location := ' 90';
FETCH c_projects_lud_order_desc BULK COLLECT INTO v_tt_pro_id,v_tt_location;
CLOSE c_projects_lud_order_desc;
/* Assign the Sorted project ids to O/P parameter O_PRO_ALL_ID_ARRAY for fast scan */
v_location := ' 91';
o_pro_all_id_array := v_tt_pro_id;
o_location := v_tt_location;
/* Delete records from temporary table TMP_PROJECTS */
DELETE FROM TMP_PROJECTS;
/* Insert records into TMP_PROJECTS as per the page number (p_page_no) */
v_location := ' 92';
-- FORALL i IN p_project_id_arr.FIRST..p_project_id_arr.LAST
-- FORALL i IN v_first..v_last
FORALL i IN v_first..v_last
INSERT INTO TMP_PROJECTS VALUES(v_tt_pro_id(i));
FORALL i IN p_project_id_arr.FIRST..p_project_id_arr.LAST
INSERT INTO TUSH2 VALUES(v_tt_pro_id(i));
v_location := ' 93';
OPEN c_pro_sum_lud_dsc(p_pse_id,p_user_id,v_status,v_loc_level,v_last_accessed_date);
FETCH c_pro_sum_lud_dsc BULK COLLECT INTO o_pro_id_array,
o_name_array,
o_type_of_work_array,
o_stage_array,
o_loc_array,
o_currency_array,
o_value_array,
o_display_value_array,
o_latest_updated_date_array,
o_flag_array;
CLOSE c_pro_sum_lud_dsc;
END IF;
END IF;
v_location := ' 94';
-- Call to Timestamp Logs for logging end_time.
DS$226.DS$2262_PROC(p_usr_id => p_user_id,
p_tpg_id => v_tpg_id,
p_start_time => v_start_time);
v_location := ' 95';
EXCEPTION
WHEN e_user_defined_excep
THEN
ds$221.ds$2211_proc(p_module_type => 'PLS',
p_err_type => 'R',
p_location => v_module ||'::'|| v_location,
p_java_error_stack => NULL,
p_user_id => p_user_id);
RAISE;
WHEN OTHERS
THEN
ds$221.ds$2211_proc(p_module_type => 'PLS',
p_err_type => 'R',
p_location => v_module || v_location,
p_java_error_stack => NULL,
p_user_id => p_user_id);
RAISE;
END;
END; -
Xmlns attribute in 8.1.7
I am trying to process an XML file with the Oracle 8.1.7 PL/SQL XDK. I'm using Steve's helper programs from the XML book. The problem is that the document in question uses XML Schema. My script chokes whenever I attempt anything with this file. After a lot of investigation I have established that it's the xmlns attibute that it doesn't like (see testcase below).
Given that I can't upgrade to 9i just yet is there anything I can do to get this code working?
Cheers In Advance, APC
This doesn't can't find my attribute...
SQL> DECLARE
2 xdoc xmldom.DOMDocument;
3 l_file varchar2(32000) := '<MYROOT xmlnsBOB="http://www.somewhere.co.uk"> '
4 || ' <MYTAG>stuff</MYTAG> '
5 || '</MYROOT>';
6 lv_file_ref varchar2(240);
7 parser xmlparser.Parser;
8 BEGIN
9 parser := xmlparser.newParser;
10 xmlparser.setValidationMode(parser, FALSE);
11 xmlparser.parseBuffer(parser,l_file);
12 xdoc := xmlparser.getDocument(parser);
13 xmlparser.freeParser(parser);
14 lv_file_ref := xpath.valueOf(xdoc, '/MYROOT/MYTAG');
15 dbms_output.put_line('!'||lv_file_ref||'!');
16* END;
PL/SQL procedure successfully completed.
but runs okay if I rename the xmlns attribute...
SQL> DECLARE
2 xdoc xmldom.DOMDocument;
3 l_file varchar2(32000) := '<MYROOT xmlnsBOB="http://www.somewhere.co.uk"> '
4 || ' <MYTAG>stuff</MYTAG> '
5 || '</MYROOT>';
6 lv_file_ref varchar2(240);
7 parser xmlparser.Parser;
8 BEGIN
9 parser := xmlparser.newParser;
10 xmlparser.setValidationMode(parser, FALSE);
11 xmlparser.parseBuffer(parser,l_file);
12 xdoc := xmlparser.getDocument(parser);
13 xmlparser.freeParser(parser);
14 lv_file_ref := xpath.valueOf(xdoc, '/MYROOT/MYTAG');
15 dbms_output.put_line('!'||lv_file_ref||'!');
16* END;
!stuff!
PL/SQL procedure successfully completed.
SQL>I am trying to process an XML file with the Oracle 8.1.7 PL/SQL XDK. I'm using Steve's helper programs from the XML book. The problem is that the document in question uses XML Schema. My script chokes whenever I attempt anything with this file. After a lot of investigation I have established that it's the xmlns attibute that it doesn't like (see testcase below).
Given that I can't upgrade to 9i just yet is there anything I can do to get this code working?
Cheers In Advance, APC
This doesn't can't find my attribute...
SQL> DECLARE
2 xdoc xmldom.DOMDocument;
3 l_file varchar2(32000) := '<MYROOT xmlnsBOB="http://www.somewhere.co.uk"> '
4 || ' <MYTAG>stuff</MYTAG> '
5 || '</MYROOT>';
6 lv_file_ref varchar2(240);
7 parser xmlparser.Parser;
8 BEGIN
9 parser := xmlparser.newParser;
10 xmlparser.setValidationMode(parser, FALSE);
11 xmlparser.parseBuffer(parser,l_file);
12 xdoc := xmlparser.getDocument(parser);
13 xmlparser.freeParser(parser);
14 lv_file_ref := xpath.valueOf(xdoc, '/MYROOT/MYTAG');
15 dbms_output.put_line('!'||lv_file_ref||'!');
16* END;
PL/SQL procedure successfully completed.
but runs okay if I rename the xmlns attribute...
SQL> DECLARE
2 xdoc xmldom.DOMDocument;
3 l_file varchar2(32000) := '<MYROOT xmlnsBOB="http://www.somewhere.co.uk"> '
4 || ' <MYTAG>stuff</MYTAG> '
5 || '</MYROOT>';
6 lv_file_ref varchar2(240);
7 parser xmlparser.Parser;
8 BEGIN
9 parser := xmlparser.newParser;
10 xmlparser.setValidationMode(parser, FALSE);
11 xmlparser.parseBuffer(parser,l_file);
12 xdoc := xmlparser.getDocument(parser);
13 xmlparser.freeParser(parser);
14 lv_file_ref := xpath.valueOf(xdoc, '/MYROOT/MYTAG');
15 dbms_output.put_line('!'||lv_file_ref||'!');
16* END;
!stuff!
PL/SQL procedure successfully completed.
SQL> -
A question about 'long' dataType in NT platform
Why the maximum of the 'long' dataType in NT
paltform is only 4k? I looked up some Oracle
reference books which told me the maximum must be 2G.
My Oracle version is 8.0.5.0.0
Thanks for your advice if you can help me to solve this question.Hi,
how did you figure out, the size of long?
In PLSQL the maximum for a varchar2 is 4k.
You have to use varchar2 to retrieve the long content. But look at dbms_sql, there are procedures to extract portions of long columns.
HTH
Detlev
null -
to_date('03-23-2010','mm-dd-yyyy')
to_date('2008-06-08','yyyy-mm-dd')
DBMS_OUTPUT.PUT_LINE(' 4th Where clause: ' || WHERE_CLAUSE);
HKey_Local Machine -> Software -> Microsoft -> MSLicensing
topas
Removing batch of Files in linux:
=====================================
find . -name "*.arc" -mtime +20 -exec rm -f {} \;
find . -name "*.dbf" -mtime +60 -exec mv {} /backup/Arch_Bkp_02May11/ \;
ALTER DATABASE
SET STANDBY DATABASE TO MAXIMIZE {AVAILABILITY | PERFORMANCE | PROTECTION};
================================================================================
Find top N records:
===================
select * from (select ename from emp order by sal)
where rownum <=n;
Find top Nth record: (n=0 for 1st highest)
=========================================
select * from emp a
where (n =
(select count(distinct b.sal) from emp b
where b.sal > a.sal));
Query for Listing last n records from the table
=================================================
select * from (select * from emp order by rownum desc) where rownum<4
HOW TO tablespace wise and file wise info
============================
col file_name for a45
col tablespace_name for a15
set linesize 132
select a.tablespace_name,a.file_name,a.AUTOEXTENSIBLE,----a.status,
round(a.bytes/1024/1024,2) Total_MB,
round(sum(b.bytes)/1024/1024,2) Free_MB,
round((a.bytes/1024/1024 - sum(b.bytes)/1024/1024),2) Used_MB
from dba_data_files a,dba_free_space b
where a.file_id=b.file_id
and a.tablespace_name=b.tablespace_name
group by a.tablespace_name,b.file_id,a.file_name,a.bytes,a.AUTOEXTENSIBLE--,a.status
order by tablespace_name;
col tablespace_name for a15
SELECT tablespace_name,ts_#,num_files,sum_free_mbytes,count_blocks,max_mbytes,
sum_alloc_mbytes,DECODE(sum_alloc_mbytes,0,0,100 * sum_free_mbytes /sum_alloc_mbytes ) AS pct_free
FROM (SELECT v.name AS tablespace_name,ts# AS ts_#,
NVL(SUM(bytes)/1048576,0) AS sum_alloc_mbytes,
NVL(COUNT(file_name),0) AS num_files
FROM dba_data_files f,v$tablespace v
WHERE v.name = f.tablespace_name (+)
GROUP BY v.name,ts#),
(SELECT v.name AS fs_ts_name,ts#,NVL(MAX(bytes)/1048576,0) AS max_mbytes,
NVL(COUNT(BLOCKS) ,0) AS count_blocks,
NVL(SUM(bytes)/1048576,0) AS sum_free_mbytes
FROM dba_free_space f,v$tablespace v
WHERE v.name = f.tablespace_name(+)
GROUP BY v.name,ts#)
WHERE tablespace_name = fs_ts_name
ORDER BY tablespace_name;
==================================
col file_name for a45
col tablespace_name for a15
set linesize 132
select a.tablespace_name,a.file_name,a.AUTOEXTENSIBLE,----a.status,
round(a.bytes/1024/1024,2) Total_MB,
round(sum(b.bytes)/1024/1024,2) Free_MB,
round((a.bytes/1024/1024 - sum(b.bytes)/1024/1024),2) Used_MB
from dba_data_files a,dba_free_space b
where a.file_id=b.file_id
and a.tablespace_name=b.tablespace_name
group by a.tablespace_name,b.file_id,a.file_name,a.bytes,a.AUTOEXTENSIBLE--,a.status
order by file_name;
=============================================================
HOW TO FIND CHILD TABLES
===========================================
col column_name for a30
col owner for a10
set linesize 132
select --a.table_name parent_table,
b.owner,
b.table_name child_table
, a.constraint_name , b.constraint_name
from dba_constraints a ,dba_constraints b
where a.owner='LEIQA20091118'
and a.constraint_name = b.r_constraint_name
--and b.constraint_type = 'R'
and a.constraint_type IN ('P','U')
and a.table_name =upper('&tabname');
List foreign keys and referenced table and columns:
======================================================
SELECT DECODE(c.status,'ENABLED','C','c') t,
SUBSTR(c.constraint_name,1,31) relation,
SUBSTR(cc.column_name,1,24) columnname,
SUBSTR(p.table_name,1,20) tablename
FROM user_cons_columns cc, user_constraints p,
user_constraints c
WHERE c.table_name = upper('&table_name')
AND c.constraint_type = 'R'
AND p.constraint_name = c.r_constraint_name
AND cc.constraint_name = c.constraint_name
AND cc.table_name = c.table_name
UNION ALL
SELECT DECODE(c.status,'ENABLED','P','p') t,
SUBSTR(c.constraint_name,1,31) relation,
SUBSTR(cc.column_name,1,24) columnname,
SUBSTR(c.table_name,1,20) tablename
FROM user_cons_columns cc, user_constraints p,
user_constraints c
WHERE p.table_name = upper('PERSON')
AND p.constraint_type in ('P','U')
AND c.r_constraint_name = p.constraint_name
AND c.constraint_type = 'R'
AND cc.constraint_name = c.constraint_name
AND cc.table_name = c.table_name
ORDER BY 1, 4, 2, 3
List a child table's referential constraints and their associated parent table:
==============================================================
SELECT t.owner CHILD_OWNER,
t.table_name CHILD_TABLE,
t.constraint_name FOREIGN_KEY_NAME,
r.owner PARENT_OWNER,
r.table_name PARENT_TABLE,
r.constraint_name PARENT_CONSTRAINT
FROM user_constraints t, user_constraints r
WHERE t.r_constraint_name = r.constraint_name
AND t.r_owner = r.owner
AND t.constraint_type='R'
AND t.table_name = <child_table_name>;
parent tables:
================
select constraint_name,constraint_type,r_constraint_name
from dba_constraints
where table_name ='TM_PAY_BILL'
and constraint_type in ('R');
select CONSTRAINT_NAME,TABLE_NAME,COLUMN_NAME from user_cons_columns where table_name='FS_FR_TERMINALLOCATION';
select a.OWNER,a.TABLE_NAME,a.CONSTRAINT_NAME,a.CONSTRAINT_TYPE
,b.COLUMN_NAME,b.POSITION
from dba_constraints a,dba_cons_columns b
where a.CONSTRAINT_NAME=b.CONSTRAINT_NAME
and a.TABLE_NAME=b.TABLE_NAME
and a.table_name=upper('TM_GEN_INSTRUCTION')
and a.constraint_type in ('P','U');
select constraint_name,constraint_type,r_constraint_name
from dba_constraints
where table_name ='TM_PAY_BILL'
and constraint_type in ('R');
===============================================
HOW TO FIND INDEXES
=====================================
col column_name for a30
col owner for a25
select a.owner,a.index_name, --a.table_name,a.tablespace_name,
b.column_name,b.column_position
from dba_indexes a,dba_ind_columns b
where a.owner='SCE'
and a.index_name=b.index_name
and a.table_name = upper('&tabname')
order by a.index_name,b.column_position;
col column_name for a40
col index_owner for a15
select index_owner,index_name,column_name,
column_position from dba_ind_columns
where table_owner= upper('VISILOGQA19') and table_name ='TBLTRANSACTIONGROUPMAIN';
-- check for index on FK
===============================
set linesize 121
col status format a6
col columns format a30 word_wrapped
col table_name format a30 word_wrapped
SELECT DECODE(b.table_name, NULL, 'Not Indexed', 'Indexed' ) STATUS, a.table_name, a.columns, b.columns from (
SELECT SUBSTR(a.table_name,1,30) table_name,
SUBSTR(a.constraint_name,1,30) constraint_name, MAX(DECODE(position, 1,
SUBSTR(column_name,1,30),NULL)) || MAX(DECODE(position, 2,', '|| SUBSTR(column_name,1,30),NULL)) || max(DECODE(position, 3,', '|| SUBSTR(column_name,1,30),NULL)) || max(DECODE(position, 4,', '|| SUBSTR(column_name,1,30),NULL)) || max(DECODE(position, 5,', '|| SUBSTR(column_name,1,30),NULL)) || max(DECODE(position, 6,', '|| SUBSTR(column_name,1,30),NULL)) || max(DECODE(position, 7,', '|| SUBSTR(column_name,1,30),NULL)) || max(DECODE(position, 8,', '|| SUBSTR(column_name,1,30),NULL)) || max(DECODE(position, 9,', '|| SUBSTR(column_name,1,30),NULL)) || max(DECODE(position,10,', '|| SUBSTR(column_name,1,30),NULL)) || max(DECODE(position,11,', '|| SUBSTR(column_name,1,30),NULL)) || max(DECODE(position,12,', '|| SUBSTR(column_name,1,30),NULL)) || max(DECODE(position,13,', '|| SUBSTR(column_name,1,30),NULL)) || max(DECODE(position,14,', '|| SUBSTR(column_name,1,30),NULL)) || max(DECODE(position,15,', '|| SUBSTR(column_name,1,30),NULL)) || max(DECODE(position,16,', '|| SUBSTR(column_name,1,30),NULL)) columns
from user_cons_columns a, user_constraints b
WHERE a.constraint_name = b.constraint_name
AND constraint_type = 'R'
GROUP BY SUBSTR(a.table_name,1,30), SUBSTR(a.constraint_name,1,30) ) a, (
SELECT SUBSTR(table_name,1,30) table_name,
SUBSTR(index_name,1,30) index_name, MAX(DECODE(column_position, 1,
SUBSTR(column_name,1,30),NULL)) || MAX(DECODE(column_position, 2,', '||SUBSTR(column_name,1,30),NULL)) || max(DECODE(column_position, 3,', '||SUBSTR(column_name,1,30),NULL)) || max(DECODE(column_position, 4,', '||SUBSTR(column_name,1,30),NULL)) || max(DECODE(column_position, 5,', '||SUBSTR(column_name,1,30),NULL)) || max(DECODE(column_position, 6,', '||SUBSTR(column_name,1,30),NULL)) || max(DECODE(column_position, 7,', '||SUBSTR(column_name,1,30),NULL)) || max(DECODE(column_position, 8,', '||SUBSTR(column_name,1,30),NULL)) || max(DECODE(column_position, 9,', '||SUBSTR(column_name,1,30),NULL)) || max(DECODE(column_position,10,', '||SUBSTR(column_name,1,30),NULL)) || max(DECODE(column_position,11,', '||SUBSTR(column_name,1,30),NULL)) || max(DECODE(column_position,12,', '||SUBSTR(column_name,1,30),NULL)) || max(DECODE(column_position,13,', '||SUBSTR(column_name,1,30),NULL)) || max(DECODE(column_position,14,', '||SUBSTR(column_name,1,30),NULL)) || max(DECODE(column_position,15,', '||SUBSTR(column_name,1,30),NULL)) || max(DECODE(column_position,16,', '||SUBSTR(column_name,1,30),NULL)) columns
from user_ind_columns group by SUBSTR(table_name,1,30), SUBSTR(index_name,1,30) ) b
where a.table_name = b.table_name (+) and b.columns (+) like a.columns || '%';
==================================================
HOW TO FIND unique keys
===========================
col column_name for a30
col owner for a10
set linesize 132
select a.owner , --a.table_name,
a.constraint_name,a.constraint_type,
b.column_name,b.position
from dba_constraints a, dba_cons_columns b
where a.table_name = upper('&tabname')
and a.constraint_name = b.constraint_name
and a.constraint_type in ('P','U')
and a.owner=b.owner
order by a.owner,a.constraint_name,b.position;
==================================
HOW TO FIND ROWlocks
======================
col object_name for a30
col terminal for a20
set linesize 1000
col spid for a10
col osuser for a15
select to_char(logon_time,'DD-MON-YYYY HH24:MI:SS'),OSUSER,--owner,
s.sid, s.serial#,p.spid,
s.terminal,l.locked_mode,o.object_name,l.ORACLE_USERNAME --,o.object_type
from v$session s, dba_objects o,v$locked_object l, V$process p
where o.object_id=l.object_id
and s.sid=l.session_id
and s.paddr=p.addr
order by logon_time;
SELECT OWNER||'.'||OBJECT_NAME AS Object, OS_USER_NAME, ORACLE_USERNAME,
PROGRAM, NVL(lockwait,'ACTIVE') AS Lockwait,DECODE(LOCKED_MODE, 2,
'ROW SHARE', 3, 'ROW EXCLUSIVE', 4, 'SHARE', 5,'SHARE ROW EXCLUSIVE',
6, 'EXCLUSIVE', 'UNKNOWN') AS Locked_mode, OBJECT_TYPE, SESSION_ID, SERIAL#, c.SID
FROM SYS.V_$LOCKED_OBJECT A, SYS.ALL_OBJECTS B, SYS.V_$SESSION c
WHERE A.OBJECT_ID = B.OBJECT_ID AND C.SID = A.SESSION_ID
ORDER BY Object ASC, lockwait DESC;
SELECT DECODE(request,0,'Holder: ','Waiter: ')||sid sess,
id1, id2, lmode, request, type
FROM V$LOCK
WHERE (id1, id2, type) IN
(SELECT id1, id2, type FROM V$LOCK WHERE request>0)
ORDER BY id1, request;
find locks
=====================
set linesize 1000
SELECT --osuser,
a.username,a.serial#,a.sid,--a.terminal,
sql_text
from v$session a, v$sqltext b, V$process p
where a.sql_address =b.address
and a.paddr = p.addr
and p.spid = '&os_pid'
order by address, piece;
select sql_text
from V$sqltext_with_newlines
where address =
(select prev_sql_addr
from V$session
where username = :uname and sid = :snum) ORDER BY piece
set pagesize 50000
set linesize 30000
set long 500000
set head off
select s.username su,s.sid,s.serial#,substr(sa.sql_text,1,540) txt
from v$process p,v$session s,v$sqlarea sa
where p.addr=s.paddr
and s.username is not null
and s.sql_address=sa.address(+)
and s.sql_hash_value=sa.hash_value(+)
and spid=&SPID;
privileges
===========
select * from dba_sys_privs where grantee = 'SCE';
select * from dba_role_privs where grantee = 'SCE'
select * from dba_sys_privs where grantee in ('CONNECT','APPL_CONNECT');
Check high_water_mark_statistics
===================================
select * from DBA_HIGH_WATER_MARK_STATISTICS;
Multiple Blocksizes:
=========================
alter system set db_16k_cache_size=64m;
create tablespace index_ts datafile '/data1/index_ts01.dbf' size 10240m blocksize 16384;
11g default profiles:
========================
alter profile default limit password_lock_time unlimited;
alter profile default limit password_life_time unlimited;
alter profile default limit password_grace_time unlimited;
logfile switch over:
select GROUP#,THREAD#,SEQUENCE#,BYTES,MEMBERS,ARCHIVED,
STATUS,to_char(FIRST_TIME,'DD-MON-YYYY HH24:MI:SS') switch_time
from v$log;
Temporary tablespace usage:
============================
SELECT b.tablespace,
ROUND(((b.blocks*p.value)/1024/1024),2)||'M' "SIZE",
a.sid||','||a.serial# SID_SERIAL,
a.username,
a.program
FROM sys.v_$session a,
sys.v_$sort_usage b,
sys.v_$parameter p
WHERE p.name = 'db_block_size'
AND a.saddr = b.session_addr
ORDER BY b.tablespace, b.blocks;
SELECT A2.TABLESPACE, A2.SEGFILE#, A2.SEGBLK#, A2.BLOCKS,
A1.SID, A1.SERIAL#, A1.USERNAME, A1.OSUSER, A1.STATUS
FROM V$SESSION A1,V$SORT_USAGE A2 WHERE A1.SADDR = A2.SESSION_ADDR;
========================================
ALTER SYSTEM KILL SESSION 'SID,SERIAL#';
Inactive sessions killing:
SELECT 'ALTER SYSTEM KILL SESSION ' || '''' || SID || ',' ||
serial# || '''' || ' immediate;' text
FROM v$session
WHERE status = 'INACTIVE'
AND last_call_et > 86400
AND username IN (SELECT username FROM DBA_USERS WHERE user_id>56);
Procedure:
CREATE OR REPLACE PROCEDURE Inactive_Session_Cleanup AS
BEGIN
FOR rec_session IN (SELECT 'ALTER SYSTEM KILL SESSION ' || '''' || SID || ',' ||
serial# || '''' || ' immediate' text
FROM v$session
WHERE status = 'INACTIVE'
AND last_call_et > 43200
AND username IN (SELECT username FROM DBA_USERS WHERE user_id>60)) LOOP
EXECUTE IMMEDIATE rec_session.text;
END LOOP;
END Inactive_Session_Cleanup;
sequence using plsql
=========================
Declare
v_next NUMBER;
script varchar2(5000);
BEGIN
SELECT (MAX(et.dcs_code) + 1) INTO v_next FROM et_document_request et;
script:= 'CREATE SEQUENCE et_document_request_seq
MINVALUE 1 MAXVALUE 999999999999999999999999999 START WITH '||
v_next || ' INCREMENT BY 1 CACHE 20';
execute immediate script;
end;
===========================
Terminal wise session
select TERMINAL,count(*) from v$session
group by TERMINAL;
total sessions
select count(*) from v$session
where TERMINAL not like '%UNKNOWN%'
and TERMINAL is not null;
HOW TO FIND DUPLICATE TOKEN NUMBERS
===========================================
select count(distinct a.token_number) dup
from tm_pen_bill a,tm_pen_bill b
where a.token_number = b.token_number
and a.bill_number <> b.bill_number
and a.token_number is not null;
when Block Corruption occurs:
select * from DBA_EXTENTS
WHERE file_id = '13' AND block_id BETWEEN '44157' and '50649';
select BLOCK_ID,SEGMENT_NAME,BLOCKS from dba_extents where FILE_ID='14'
and BLOCK_ID like '%171%';
select BLOCK_ID,SEGMENT_NAME,BLOCKS from dba_extents where FILE_ID='14'
and SEGMENT_NAME = 'TEMP_TD_PAY_ALLOTMENT_NMC';
DBVERIFY:
dbv blocksize=8192 file=users01.dbf log=dbv_users01.log
==============================================================
DBMS_REPAIR:(Block Corruption)
exec dbms_repair.admin_tables(table_name=>'REPAIR_TABLE',table_type=>dbms_repair.repair_table,action=>dbms_repair.create_action,tablespace=>'USERS');
variable v_corrupt_count number;
exec dbms_repair.check_object('scott','emp',corrupt_count=>:v_corrupt_count);
print v_corrupt_count;
==============================================================
Password:
select login,substr(utl_raw.cast_to_varchar2(utl_raw.cast_to_varchar2(password)),1,30) password
from mm_gen_user where active_flag = 'Y' and user_id=64 and LOGIN='GOPAL' ;
CHARACTERSET
select * from NLS_DATABASE_PARAMETERS;
SELECT value$ FROM sys.props$ WHERE name = 'NLS_CHARACTERSET' ;
select value from nls_database_parameters where parameter='NLS_CHARACTERSET';
==========================================================
EXPLAIN PLAN TABLE QUERY
========================
EXPLAIN PLAN SET STATEMENT_ID='5'
FOR
"DML STATEMENT"
PLAN TABLE QUERY
===============================
set linesize 1000
set arraysize 1000
col OBJECT_TYPE for a20
col OPTIMIZER for a20
col object_name for a30
col options for a25
select COST,OPERATION,OPTIONS,OBJECT_TYPE,
OBJECT_NAME,OPTIMIZER
--,ID,PARENT_ID,POSITION,CARDINALITY
from plan_table
where statement_id='&statement_id';
Rman settings: disk formats
%t represents a timestamp
%s represents the backup set number
%p represents the piece number
The dbms_workload_repository.create_snapshot procedure creates a manual snapshot in the AWR as seen in this example:
EXEC dbms_workload_repository.create_snapshot;
Calculation of a table the size of the space occupied by
========================================================
select owner, table_name,
NUM_ROWS,
BLOCKS * AAA/1024/1024 "Size M",
EMPTY_BLOCKS,
LAST_ANALYZED
from dba_tables
where table_name = 'XXX';
Finding statement/s which use lots of shared pool memory:
==========================================================
SELECT substr(sql_text,1,40) "SQL", count(*) , sum(executions) "TotExecs"
FROM v$sqlarea
WHERE executions < 5
GROUP BY substr(sql_text,1,40)
HAVING count(*) > 30
ORDER BY 2;
See a table size table
=========================================
select sum (bytes) / (1024 * 1024) as "size (M)" from user_segments
where segment_name = upper ('& table_name');
See a index size table
=========================================
select sum (bytes) / (1024 * 1024) as "size (M)" from user_segments
where segment_name = upper ('& index_name');
monitoring table space I / O ratio
====================================
select B.tablespace_name name, B.file_name "file", A.phyrds pyr,
A.phyblkrd pbr, A.phywrts pyw, A.phyblkwrt pbw
from v $ filestat A, dba_data_files B
where A.file # = B.file_id
order by B.tablespace_name;
monitor the file system I / O ratio
=====================================
select substr (C.file #, 1,2) "#", substr (C.name, 1,30) "Name",
C.status, C.bytes, D.phyrds, D.phywrts
from v $ datafile C, v $ filestat D
where C.file # = D.file #;
the hit rate monitor SGA
=========================
select a.value + b.value "logical_reads", c.value "phys_reads",
round (100 * ((a.value + b.value)-c.value) / (a.value + b.value)) "BUFFER HIT RATIO"
from v $ sysstat a, v $ sysstat b, v $ sysstat c
where a.statistic # = 38 and b.statistic # = 39
and c.statistic # = 40;
monitoring SGA in the dictionary buffer hit ratio
==================================================
select parameter, gets, Getmisses, getmisses / (gets + getmisses) * 100 "miss ratio",
(1 - (sum (getmisses) / (sum (gets) + sum (getmisses ))))* 100 "Hit ratio"
from v $ rowcache
where gets + getmisses <> 0
group by parameter, gets, getmisses;
monitoring SGA shared cache hit ratio should be less than 1%
=============================================================
select sum (pins) "Total Pins", sum (reloads) "Total Reloads",
sum (reloads) / sum (pins) * 100 libcache
from v $ librarycache;
select sum (pinhits-reloads) / sum (pins) "hit radio", sum (reloads) / sum (pins) "reload percent"
from v $ librarycache;
monitoring SGA in the redo log buffer hit ratio should be less than 1%
=========================================================================
SELECT name, gets, misses, immediate_gets, immediate_misses,
Decode (gets, 0,0, misses / gets * 100) ratio1,
Decode (immediate_gets + immediate_misses, 0,0,
immediate_misses / (immediate_gets + immediate_misses) * 100) ratio2
FROM v $ latch WHERE name IN ('redo allocation', 'redo copy');
control memory and hard disk sort ratio, it is best to make it smaller than .10, an increase sort_area_size
=============================================================================================================
SELECT name, value FROM v$sysstat WHERE name IN ('sorts (memory)', 'sorts (disk)');
monitoring what the current database who are running SQL statements?
===================================================================
SELECT osuser, username, sql_text from v $ session a, v $ sqltext b
where a.sql_address = b.address order by address, piece;
monitoring the dictionary buffer?
=====================================
SELECT (SUM (PINS - RELOADS)) / SUM (PINS) "LIB CACHE" FROM V $ LIBRARYCACHE;
SELECT (SUM (GETS - GETMISSES - USAGE - FIXED)) / SUM (GETS) "ROW CACHE" FROM V $ ROWCACHE;
SELECT SUM (PINS) "EXECUTIONS", SUM (RELOADS) "CACHE MISSES WHILE EXECUTING" FROM V $ LIBRARYCACHE;
The latter divided by the former, this ratio is less than 1%, close to 0% as well.
SELECT SUM (GETS) "DICTIONARY GETS", SUM (GETMISSES) "DICTIONARY CACHE GET MISSES"
FROM V $ ROWCACHE
see the table a high degree of fragmentation?
=================================================
SELECT owner,segment_name table_name, COUNT (*) extents
FROM dba_segments WHERE owner NOT IN ('SYS', 'SYSTEM') GROUP BY owner,segment_name
HAVING COUNT (*) = (SELECT MAX (COUNT (*)) FROM dba_segments GROUP BY segment_name);
=======================================================================
Fragmentation:
=================
select table_name,round((blocks*8),2)||'kb' "size"
from user_tables
where table_name = 'BIG1';
Actual Data:
=============
select table_name,round((num_rows*avg_row_len/1024),2)||'kb' "size"
from user_tables
where table_name = 'BIG1';
The establishment of an example data dictionary view to 8I
=======================================================
$ ORACLE_HOME / RDBMS / ADMIN / CATALOG.SQL
The establishment of audit data dictionary view with an example to 8I
======================================================
$ ORACLE_HOME / RDBMS / ADMIN / CATAUDIT.SQL
To establish a snapshot view using the data dictionary to 8I Case
=====================================================
$ ORACLE_HOME / RDBMS / ADMIN / CATSNAP.SQL
The table / index moving table space
=======================================
ALTER TABLE TABLE_NAME MOVE TABLESPACE_NAME;
ALTER INDEX INDEX_NAME REBUILD TABLESPACE TABLESPACE_NAME;
How can I know the system's current SCN number?
=================================================
select max (ktuxescnw * power (2, 32) + ktuxescnb) from x$ktuxe;
Will keep a small table into the pool
======================================
alter table xxx storage (buffer_pool keep);
Check the permissions for each user
===================================
SELECT * FROM DBA_SYS_PRIVS;
=====================================================================
Tablespace auto extend check:
=================================
col file_name for a50
select FILE_NAME,TABLESPACE_NAME,AUTOEXTENSIBLE from dba_data_files
order by TABLESPACE_NAME;
COL SEGMENT_NAME FOR A30
select SEGMENT_NAME,TABLESPACE_NAME,BYTES,EXTENTS,INITIAL_EXTENT,
NEXT_EXTENT,MAX_EXTENTS,PCT_INCREASE
from user_segments
where segment_name in ('TD_PAY_CHEQUE_PREPARED','TM_PAY_BILL','TD_PAY_PAYORDER');
select TABLESPACE_NAME,INITIAL_EXTENT,NEXT_EXTENT,MAX_EXTENTS,PCT_INCREASE
from dba_tablespaces;
alter tablespace temp default storage(next 5m maxextents 20480 pctincrease 0);
ALTER TABLE TD_PAY_CHEQUE_PREPARED
default STORAGE ( NEXT 10 M maxextents 20480 pctincrease 0);
Moving table from one tablespace to another
===============================================
alter table KHAJANE.TEMP_TM_PAY_ALLOTMENT_NMC move tablespace khajane_ts;
==============================================
for moving datafiles location:
========================================
alter database rename file a to b;
======================================================================
for logfile Clearence:
select * from global_name;
col member for a50
set linesize 132
set trimspool on
select 'alter database clear logfile ' || '''' || member || '''' || ';'
from v$logfile where status ='STALE';
logfile switch over:
select GROUP#,THREAD#,SEQUENCE#,BYTES,MEMBERS,ARCHIVED,
STATUS,to_char(FIRST_TIME,'DD-MON-YYYY HH24:MI:SS') switch_time
from v$log;Answered
-
Hi,
I have some problems with running application which uses ODP to connect to Oracle in version 9.2.0.6.
There is one PLSQL packages with maybe 30 procedures. Half of this have VARCHAR2 input parameters.
In that version of Oracle there is bug - I very ofen get "Numeric or value error" during calling PLSQL.
Only one suggestion from Oracle is to upgrade into higher version. My Admin told me that upgrade is planned
but he cannot provide date. So I am going to change my code from:
PLSQL
PROCEDURE Test1( param1 IN VARCHAR2
,param2 IN VARCHAR2
,param3 IN NUMBER
,param4 OUT CLOB)
C#
OracleCommand theCommand = new OracleCommand("package.Test1");
theCommand.CommandType = CommandType.StoredProcedure;
theCommand.Parameters.Add("param1", OracleDbType.Varchar2, value1, ParameterDirection.Input);
theCommand.Parameters.Add("param2", OracleDbType.Varchar2, value2, ParameterDirection.Input);
theCommand.Parameters.Add("param3", OracleDbType.Decimal, value3, ParameterDirection.Input);
theCommand.Parameters.Add("param4", OracleDbType.clob, ParameterDirection.Output);
INTO
PLSQL
--old procedure is not changed
PROCEDURE Test1( param1 IN VARCHAR2
,param2 IN VARCHAR2
,param3 IN NUMBER
,param4 OUT CLOB)
--new procedure added with XMLType input
PROCEDURE Test1( params IN XMLType
,paramClob OUT CLOB)
IS
param_1 VARCHAR2(4000);
param_2 VARCHAR2(4000);
param_3 NUMBER;
BEGIN
SELECT ExtractValue( params, '/params/param1')
,ExtractValue( params, '/params/param2')
,ExtractValue( params, '/params/param3')
INTO param_1, param_2, param_3
FROM DUAL;
--now calling old proc
Test1(param_1, param_2, param_3, paramClob);
END Test1;
C#
OracleCommand theCommand = new OracleCommand("package.Test1");
theCommand.CommandType = CommandType.StoredProcedure;
XDocument packedParams = new XDocument
new XElement("params",
new XElement("param1", value1),
new XElement("param2", value2),
new XElement("param3", value3)
theCommand.Parameters.Add("params", OracleDbType.XMLType, packedParams , ParameterDirection.Input);
theCommand.Parameters.Add("paramClob", OracleDbType.clob, ParameterDirection.Output);
What do You think about such solution, do you have any bad experiences with using ODP/XMLType ?
Regards,
PiotrI doubt proposed change will reduce frequency of errors.
"Numeric or value error"In V9 this error cause 2 possible causes.
1) VARCHAR2 is too small
2) non-numeric value being assigned to numeric datatype.
If the root cause is #2 above, the error will continue with proposed change.
Good Luck! -
Process Flow Error: nonexistent LOB value
Hi,
I would like to send an email of all mapping statuses of the day. I created function to retrieve all messages from OWB$WB_RT_AUDIT_MESSAGE_LINES. Sometimes it works and another time it fails. After a little investigation I got the cause of this failure: length of the message exceed the limitation of VARCHAR2 (4000 bytes).
Then I created another function for testing as follows:
CREATE OR REPLACE FUNCTION FTEST_VAR RETURN CLOB IS
tmpVar CLOB;
BEGIN
tmpVar := 'test';
RETURN tmpVar;
END FTEST_VAR;
From SQLPlus I was able to query this function:
SQL>select ftest_var tst from dual;
TST
test
Then I created a process flow like this:
START1->FTEST_VAR->EMAIL->END_SUCCESS
In the process flow I created a variable EMAILBODY to bind to the output of FTEST_VAR and then bind EMAILBODY to the MESSAGE_BODY of the EMAIL.
I deployed and run the process flow. It failed with this error message:
ORA-22922: nonexistent LOB value
ORA-06512: at line 1
Could anybody please shed a light on this?
TIA
PratI am trying to setup pretty much the same type of flow to email job messages using a CLOB. Were you able to find a solution?
Thanks! -
Substr to get the date and validate
Hi all,
I had a file with name as Emp_Names20101028_123245.txt
Now i want to validate the date part ( 20101028_123245 ) in the filename having the format YYYYMMDD HH24:MM:SS.
The date format should be only in the format as shown as above.other wise it should thrown an exception in a plsql procedure.
Declare
l_filename Varchar2(30);
Begin
l_filename = 'Emp_Names20101028_123245.txt'
/* Sql statement to check the format */
Exception
When others
Dbms_output.put_line(" Invalid File date Format");
End;Edited by: Rede on Dec 1, 2010 12:41 PMHi, Rede,
Rede wrote:
Frank
Will the given mask ever contain other variable-length items, such as 'RRRR' or 'fmMONTH'?
No, The give mask is standard.It will not contain the Variable length items.
That makes things a lot simpler! If the date is always in a standard format, there's no real need to use a varaible.
Is there any other way you can determine what the date part of l_filename is? For example, does it always come after '...Names' and before '.txt'?
It will always comes after the '...Names' and before '.txt'.
I think we can use the SUBSTR function but there is an underscore (_) which is making a little complex sql statement.The underscore only has special meaning when you're using the LIKE operator, and even then, it can be escaped.
Yes, you can use SUBSTR, like this:
TO_DATE ( SUBSTR ( l_filename
, 6 + INSTR ( TRANSLATE ( UPPER (l_filename)
, '012345678'
, '999999999'
, 'NAMES99999999_999999.TXT'
, 15
, 'YYYYMMDD_HH24MISS'
REGEXP will be slower option, so i am looking to avoid REGEXP int his case.That's a good thing to keep in mind, but does it really matter in this case? Are you going to be parsing thousands of filenames at a time?
Maybe you are looking for
-
I have an issue connecting on Vodafone uk 4g network while I have no problems with other SIM cards. On Vodafone I can only get 3G even if my plan is all set up for 4g. Vodafone doesn't know what the problem is. Occasionally I do get 4g but then it di
-
Hi My shared services is starting and stopping frequently. I tried starting the service from startup menu and in the command prompt it said unable to connect the database. Reconfigure using configuration utlity. I tried the same and the configuration
-
Hi All, I have an artwork with so many PSD links. Now i converted all the psd links to EPS. i didnt change the file name. File name is same as psd only. Now i want to relink all the psd with EPS link. Manual relinking makes time consuming. Is thr an
-
Change connection Pool according to dashoard prompt.
Hi experts, I have a requirement where user will select the server name(Server1/Server2) from dashboard prompt and OBIEE should fire query on the respected server. Thanks,
-
Syncing contacts merge/delete/duplicate
Hello, I am syncing an iPad and 2 iPhones with one user on our macbook. We have roughly 1500 contacts which constantly get edited/deleted/added. Now I was told at the apple store that when syncing the newest version of the contact will be the one tha