Need to create view ( Urgent )
Hi All,
I have one requirement to create a view .Presently we are using a packaged procedure(view_test_123_pkg) to extract part numbers to write to a file using utl_file package.
Now the requirement is to create a single column view to extract part numbers exactly as package (view_test_123_pkg) is extracting .
below is the package details and view which I have created .Please help
CREATE OR REPLACE package APPS.view_test_123_pkg
as
procedure create_part_ref_proc;
end;
CREATE OR REPLACE package body APPS.view_test_123_pkg
as
procedure create_part_ref_proc
as
l_s_part varchar2(50);
L_CUST_PART varchar2(50);
l_cat varchar2(10);
l_partner_id varchar(30);
l_bare_part varchar2(50);
l_last_bare_part varchar2(50);
l_line_print varchar2(500);
l_last_s_part varchar2(50) :='newww';
l_last_c_part varchar2(50) :='newww';
l_last_cat varchar2(10) :='newww';
l_count number;
l_revision varchar2(50);
l_cust_revision varchar2(100);
l_error_code number;
l_error_text varchar2(200);
l_error_msg varchar2(1000) := '';
l_returned number := NULL;
--===================================================================
-- CURSORS TO READ TABLES
--===================================================================
Cursor part_find is
select distinct
customer_part_number,
internal_item_number,
corp_code cat,
bare_item_number,
customer_revision_number revision,
CUSTOMER_PRIORITY
from APPS.customer_part_ref a
where NVL(PUBLISH_YORN,'Y') = 'Y';
-- order by 3,2,6 desc;
BEGIN
l_count := 0;
l_last_bare_part := null;
For rec in find_part
LOOP
l_s_part := rec.internal_item_number;
L_CUST_PART := rec.customer_part_number;
l_cat := rec.cat;
l_bare_part := rec.bare_item_number;
l_revision := rec.revision;
if instr(L_CUST_PART,'~') = 0
THEN
L_COUNT := L_COUNT + 1;
IF l_last_s_part != l_s_part OR
l_last_cat != l_cat
then
IF l_count > 1
then
IF l_last_bare_part is NULL
then
l_line_print := l_line_print||'"';
end if;
l_line_print := l_line_print||l_cust_revision||'"';
write(r_file, l_line_print);
l_last_bare_part := null;
END IF;
l_line_print := L_CUST_PART||'"'||l_s_part||'"'||l_cat||'"';
l_cust_revision := l_revision;
IF l_bare_part is not NULL
THEN
dbms_output.put_line('bare part is not null');
l_line_print := l_line_print||L_BARE_PART||'"';
l_last_bare_part := l_bare_part;
END IF;
END IF;
IF l_last_s_part = l_s_part AND ----------------------need help here for the same internal_number need but diff customer_part_number need to get one string
l_last_cat = l_cat AND --------example CUst_part1 | cust_part2 | internal_part
l_last_c_part != L_CUST_PART
THEN
l_line_print := L_CUST_PART||'|'||l_line_print;
l_cust_revision := l_revision||'|'||l_cust_revision;
END IF;
IF l_last_s_part = l_s_part AND
l_last_cat = l_cat AND
l_last_bare_part is NULL AND
l_bare_part is not NULL
THEN
l_line_print := l_line_print||l_bare_part||'"';
l_last_bare_part := l_bare_part;
END IF;
l_last_c_part := L_CUST_PART;
l_last_s_part := l_s_part;
l_last_cat := l_cat;
END IF; -- End of instr('~')
END LOOP;
IF l_last_bare_part is null
THEN
l_line_print := l_line_print||'"';
dbms_output.put_line(l_line_print);
END IF;
l_line_print := l_line_print||l_cust_revision;
dbms_output.put_line('after loop');
write(r_file, l_line_print);
dbms_output.put_line(l_line_print);
EXCEPTION
WHEN OTHERS THEN
ROLLBACK;
raise_application_error(-20999,
'An unknown error has occured ');
END;
end;
view :::
create or replace view test_123_view as select distinct
case when instr(partner_part_number,'~') =0
then
case
when bare_item_number is null
then customer_part_number||'"'||internal_item_number||'"'||corp_code||'"'||bare_item_number||'"'
end
end
as part_string
from APPS.CUSTOMER_PART_REF a
where NVL(PUBLISH_YORN,'Y') = 'Y';
need to amend the if condition
IF l_last_s_part = l_s_part AND
l_last_cat = l_cat AND
L_LAST_C_PART != L_CUST_PART
THEN
to the above view
I appreciate any help .
Regards,
Gopi.ch
Hello Gopi.ch,
if it is really urgend, then you should not write so in the title of your post. This is a forum of volunteers and many of the regulars will just ask you why you think it is more important than the other questions.
Second: you post a lot of unformatted code. This makes it harder to read your question.
CREATE OR REPLACE VIEW test_123_view AS
SELECT DISTINCT
CASE WHEN INSTR(partner_part_number,'~') = 0 THEN
CASE WHEN bare_item_number IS NULL THEN
customer_part_number||'"'||internal_item_number||'"'||corp_code||'"'||bare_item_number||'"'
END
END AS part_string
FROM apps.customer_part_ref a
WHERE NVL(publish_yorn,'Y') = 'Y';
need to amend the if condition
IF l_last_s_part = l_s_part
AND l_last_cat = l_cat
AND l_last_c_part != l_cust_part
THEN
to the above view I don't want to analyze your package for you, so you might want to tell us where you want to add the condition.
Regards
Marcus
Similar Messages
-
I have table 'Table 1' with columns Attr1,Attr2,Measure 1,Measure 2.I need to create view in the repository from table with Attr1,Measure1 and new Attribute 3 with values as flag 'Y' in to it.What will be the SQL for the new view.Please provide the exact Syntax for the view.
Thanks in AdvanceHi Hsekar,
The view SQL Syntax is standard ANSI SQL. From what I understand, you have a table named "Table 1" which has four columns, "Attr1", "Attr2", "Measure 1", "Measure 2". You want to create a new measure named "Attribute 3" (I'd recommend not having spaces in your column and table names FYI).
If that's correct, then try this
1. In the physical layer, change the object type to view.
2. Put the following SQL in the box
Select "Table 1"."Attr 1","Table 1"."Measure 1", 'Y' "Attribute 3"
From "Table 1"
3. Define your columns in the object appropriately.
That should do it for you.
-Joe -
Hi Experts,
I need to create view from joining 4 Tables in SAP R/3 in SE11 Transaction. Can you please let me know step by step the procedure to create the view.
Thanks
PadmaHi Padma,
Welcome to SDN . Please use the below link to get the information about view
Re: how to create a view?
But please search SDN before posting and post the message in the correct forum ( ABAP) to get the faster response.
Thanks & Regards,
Raja -
Do I need to create a view for this?
Hi Ihave got 2 tables emp and project
In emp tabe:
emp_no
family name
given name
In porgect table:
emp_no
status(assigned,unassigned)
start_date
end_date
emp_no Family_name given_name
1 Smith John
In project table same employee can have many assigement eg
emp_no status start_date end_date
1 assigned 01-may-08 01-july-08
1 assigned 01-sep-08 01-july-09
1 unassigned 01-july-09 01-oct-09
In the form:
there are 2 querable fields "project ends between field1(date) and field2(date)" which is used to
retrive records which have end date between field1 and field2.
The following fields are needed to get from database:
emp.family_name emp.given_name project.start_date project.end_date No.of time assigned
Requirements:
1. project.start_date and project.end_date must be the latest project_end_date for the same emp
so in the above sample date
2. No. of time assigned is a count of total of number records which have status='assign'
So for the given sample data the record expected after query would be(field1=01-jun-08 field2=02-july-09)
emp.family_name emp.given_name project.start_date project.end_date No.of time assigned
Smith John 01-sep-08 01-july-09 2
What is the best approach to get:
1 The lastest project(latest end_date) for the emp
2. get No.of time assigned.
Do I need to create a view for this? If yes, any sample sql code this this?
Thanks for your helpHi W1zard,
Thanks for your reply. Could you clarify the following points for me:
1.) you could create a master block basing on your emp table and a detail block basing on your project table with the relation over emp_no. set the default_where clause of your detail block programmatically using
set_block_property('project', default_where, 'status = ''assigned'' and <your_date_criteria>');
Q1: where I pit this code? in pre-query trigger in detail block?
2.) Of course you could create a view to join both of your tables if you don't want to use master detail blocks; Also do the join over emp_no
create or replace force view v_emp as
select emp.family_name, emp.given_name, project.start_date, project.end_date
from emp, project
where emp.emp_no = project.emp_no
Q2 As I mentioned before, there are multipal entries for the same emp in project table and we only need the maching record from project table which has latest end_date. So I think I need something like
max(project.end_date) somewhere in create view to make sure only one record for one employee.
Also is there possible to include the no. of assigned field(select count(*) from project where status='assigned' and emp=emp_no) into the view as well?
Q3 All the fields mentioned above are diaplay-only. So Can I create a control block which has all the fields from emp and project. Then populate them with my sql. The question is
where I put this customerised sql so when user click excute query. My sql will run and display one the form?
REally appreciated your help!
Michael -
What IS the best program to use to create an animation, that needs to be viewed in powerpoint? Essentially i want to output a Movie File, so i'm guessing that Edge Animate is out of the question and it's not photoshop, more likely Flash?
So it sounds like you want to create a form. There are really two approaches, either Acrobat (AcroForm) or LiveCycle Designer (XFA form). LiveCycle Designer comes with Acrobat Pro, but it's an entirely separate application.
For an AcroForm, you'd create the underlying document in a page layout program (e.g., InDesign), word processor, or some other software and convert to PDF. Then in Acrobat you;d add the interactive form fields and any scripting you want. You can also add other types of interactive elements such as links, bookmarks, multimedia, etc. You can add a button which when clicked initiates an email with the filled-in form attached of submits to a web server.
For an XFA form, you'd normally create the entire document in LiveCycle Designer, particularly for a dynamic forms. There's a lot that PDF has to offer that's not available with XFA forms, but XFA forms can do things AcroForms can't. For a good discussion of the important differences between the two types of forms, see the following article: http://acrobatusers.com/blogs/thomp/so-what-difference-between-acroforms-and-xfa
For a form that needs to be saved with Adobe Reader, the document needs to be Reader-enabled. When such a document is opened in Reader, it will unlock certain functionality that Reader does not have otherwise, such as commenting, signing digital signature fields, and most important saving. But when a document has been extended this way with Acrobat, there are licesning restrictions. In short, if you distribute an enabled document to more than 500 recipients, you are allowed to use data from no more than 500 forms that have been returned to you, including hard copied. If fewer than 500 recipients, there is no such limit. -
What kind of view object would I need to create to achieve this ADF form?
I have an entity that has several dates. The dates are stored in a table separate from the entity, each entity date has a date type (open, close, interview, etc) associated with it. The DBAs idea (who else of course!) was to have the flexibility to add new types of dates for entities when needed.
So you have tables like this -
Table: EntityTable
Columns: EntityId, EntityName
Table: DatesTable
Columns: EntityId, Date, DateTypeCd
I need to display an editable ADF form where I can update the entity and the entity dates
The ADF form would contain something like this
Entity Name: []
Opening Date: []
Closing Date: []
Interview Date: []
What kind of view object would I need to create to achieve this?That would be a master-detail relation 1-* between 'entity' and 'entity dates'. If your dba has set up the foreign key association in the db and you use the wizard to create the business objects, jdev pick up the relation and create the correct master detail relation in the vo layer for you.
By the way naming a table 'entity' is not a good idea when working with ADFbc. We all talk about entities when we relate to a business object (in this case a row of a table or entity object or EO). So it's hard to distinguish the two, your specific table 'entiyt' and the common term entity or EO which can be a row of any table.
Timo -
Creating Views using XSU PL/SQL API.Urgent please.
Folks,
I need some help in creating a View.
I am using XSU PL/SQL to generate an XML Document.
I have a table (SDI) with 2 cols CMPY_NUM and CPTY_BORG_NUM.
If the values in these 2 cols are equal then the xml
value to be returned is 'OURS' else return 'THEIRS'.
How do I Create this View please?
The XSU PL/SQL I am using to generate the XML is:
declare
queryCtx DBMS_XMLquery.ctxType;
xmlResult CLOB;
begin
queryCtx := DBMS_XMLQuery.newContext('select CMPY_NUM,CPTY_BORG_NUM from SDI');
xmlResult := DBMS_XMLQuery.getXML(queryCtx);
DBMS_XMLQuery.closeContext(queryCtx); -- you must close the query handle..
end;
Output
<?xml version='1.0'?>
<ROWSET>
<ROW num="1">
<CMPY_NUM>1</CMPY_NUM>
<CPTY_BORG_NUM>2/CPTY_BORG_NUM>
</ROW>
<!-- additional rows ... -->
</ROWSET>
Please can any one tell me how to create a view that will be used in place
of the select statement,and returns back OURS or THEIRS
Create View XML ASThis is a duplicate of this posting Creating a View to check for 2 conditions.. This is a particularly heinous case because some of our finest minds have already responded in that thread.
Lose ten culture points.
Regards, APC -
What privileges are needed to create a cross-schema view
For example:
User A owns T1, T2
User B wants to create a view using T1 and T2 (join them)
What privileges does user B need? I have 2 claims:
1. Create View and SELECT on A.T1 and A.T2 to user B
2. SELECT WITH GRANT OPTION on A.T1 and A.T2 to user B
Thanks!# 1
# 2 is required if user B wanted to grant select on that created view to other users. -
Urgent Need for creating 100 tables in Oracle.
Hello All,
I need to create 100 tables in oracle using a loop.
Please suggest . Advance thanks for your efforts.
ANtoI am getting the foll error at run time when executing the procedure ..
ERROR at line 1:
ORA-01031: insufficient privileges
ORA-06512: at "ORAUSER.CREATE_100_TABLE", line 9
ORA-06512: at line 1
The script goes here ...
create or replace procedure create_100_table
is
v_sql_string varchar2(200);
begin
for i in 1..100
loop
v_sql_string := 'create table ajames' || i || ' as select * from emp';
execute immediate v_sql_string;
end loop;
end;
------------------------ -
Please Help: create a procedure that needs a sys view
Hi gurus,
I am trying to create a stored procedure that opens a cursor for a select on a view owned by sys, but the errors says table or view does not exist. I can select * from the view (sys.mgw_gateway) from SQL*Plus or any other tool. Anyone have an idea why I get the ORA-00942: table or view does not exist error when I try to create a procedure? Here is the simple SQL statement for the procedure (I just want the users to see if the messaging gateway is running) and that's all in it.
open p_MGWStatus for
select AGENT_STATUS, AGENT_PING, to_char(LAST_ERROR_DATE, 'mm/dd/yyyy hh24:mi') as LastErrorDate,
LAST_ERROR_MSG
from sys.mgw_gateway;
Thanks a lot.
BenHi
To allow the view owned by sys in a procedure, you have to grant select on that particular view to the owner of that procedure.
Suggestion: may or may not be acceptable: create your own view in system schema (if it has the privilege to select that view else in sys schema) with the required column of the sys view and grant this newly created view to the owner of the procedure.
Regards
Opps! Very late reply
Message was edited by:
Anurag Tibrewal -
Doubts related to views urgent help needed
Hi all ,
i am new to oracle technology and have a doubt related to VIEWS
i have a master table job_master and i have preapred a view of the master table as
job_master_view
The view i created as create view job_master_view as select * from job_master
Now my doubt is if i exevute a SELECT FOR UPDATE NOWAIT query on the view job_master_view then will corresponding row of the master table also be locked
I am trying to execute above query to avoid simultaneous access by multiple users
I the above approach correct ? and will the row of master table get locked ?
please let me know in case my query is not clear
Thanking in advance
RegardsMy question is, how long you are going to hold lock on these table? If not, you can only use select for update with requried records using where cluase. I also suggest other application which updates this table to use same kind of statement, with NOWAIT caluse, when these applicationg trying to get a lock on these records and found already locked my other, it wont block or wait, just statement fails and can be re-tried again.
Bascially triggers are used for sort of action not for selecting data. What you can do is that develop a procedure and call it in the trigger and in the procedure you can easily use dbms_outout.put_line to display output on the sqlprompt.
Jaffar -
I need to create a meterialized view.
hey guys,
i need to create a mv for one of my large database table and that should be refresh for every 30 min. so can you plese give me some syntax.
thanks in advance,
Lakshman.If you look up the documentation (which you can find at http://tahiti.oracle.com) You will get all the syntax you'll ever need
-
Need to create a Calender in WebDynpro for ABAP
Hi,
Tcode SSC1 displays owner's calender. I need to create same calender in WebDynpro for ABAP. I couldn't find any standard component usage for the same. Is there any component usage for the same or is there any altenative to create the same?
It's quite urgent.
Thanks,
MaheshHi
You have to use DateNavigator Control to get the left hand side screen in SCC1 and
for the right hand side one you have to work with table Control
for Date Navigator UI control see WDR_TEST_EVENTS
and to get the right hand side screen see WDR_TEST_TABLE see the view SingleMarkableCell.
Using both these standard components you can achieve this.
Abhi -
Create view link programatically
Hi all,
I am working on this weird requirement.
Basically, I have to create a detail table on a search resullt table. The search result is seeded search, for Item Advance search in Oracle PIM module which is not based upon a VO. The search result table is dynamically built at run time in the EgoItemSearchHelper class and that's where they build the search result VO (EgoItemSearchResultsVO).
Now, I need to access this VO in the controller class, and create a view link programatically between details table VO and this VO. The problem is since I do not have Impl class for the EgoItemSearchResultsVO, how do I accees the column that is the key attribute. Second I do not know how to create view link between the two VOs programatically.
Please help it's urgent.
ThanksPratap, My problem is the seeded VO is in seeded AM and my details VO will be in my custom AM, I don't know if we can have a view link between View objects that are in different AMs.
To bypass that problem, I tried to create a VO in the seeded AM programatically and then created a view link. Now since the AM is seeded, and I am adding my details VO to this AM programatically, I thought of creating a table also programatically on the detais VO.
In the end it does not work, I end up getting a show button on the main table, but when I click I get an error (Cannot find <null> attribute in the EOGITEMSEARCHRESULTVO) which is the seeded VO class. Unfortunately there is no boolean variable on the dynamic seeded VO, so don't know what to put in oatablebean.setDetailViewAttributeName("") method;
Any clues on this, appreciate all responses from the forum gurus.
ViewObject voEmp = oaapplicationmodule.createViewObject("MyEmp", "xxuss.oracle.apps.ego.item.eu.server.DetailsOrderLinesVO");
ViewObject voEmp = am.createViewObject("MyEmp", "xxuss.oracle.apps.ego.item.eu.server.DetailsOrderLinesVO");
AttributeDef[] prjLinkAttrs = new AttributeDef[]{oaapplicationmodule.findViewObject("EgoItemSearchResultsVO").findAttributeDef("INVENTORY_ITEM_ID_B")};
System.out.println("definition for attr = "+ prjLinkAttrs[0]);
AttributeDef[] taskLinkAttrs = new AttributeDef[]{voEmp.findAttributeDef("InvId") };
ViewLink vl = am.createViewLinkBetweenViewObjects("MyLink3",
"DetailInv", // accessor name--more on this below
am.findViewObject("EgoItemSearchResultsVO"), // master
prjLinkAttrs, // department attributes
voEmp, // detail
taskLinkAttrs, // employee attributes
null); // assoc clause
System.out.println("view link =" + vl.getName());
OATableBean tb = (OATableBean)createWebBean(oapagecontext,TABLE_BEAN,null,"table");
tb.setViewUsageName("MyEmp");
OAMessageStyledTextBean beans = (OAMessageStyledTextBean)createWebBean(oapagecontext,MESSAGE_STYLED_TEXT_BEAN,OAWebBeanConstants.VARCHAR2_DATATYPE,"number");
beans.setPrompt("column1");
beans.setViewUsageName("MyEmp");
beans.setViewAttributeName("InvId");
tb.addIndexedChild(beans);
oatablebean.setDetail((OAWebBean)tb);
oatablebean.setDetailViewAttributeName("SelectFlag"); // I just tried this, SelectFlag is not a boolean attribute though, is there a way to create a boolean attribute programatically for seeded VO EGOITEMSEARCHRESULTVO and set it here, will it help
oatablebean.setAllDetailsEnabled(true); -
Insert and update a data block which is based on view--urgent help required
Hi experts,
I created a view(A_VIEW) which is based on a union select. I have created a data block A_VIW_BLOCK which is based on this view. I need to insert/update one of the base tablesfor A_VIEW through this data block. I also need to be able to make a query through all the fields in the view.
The questions are:
1.Can it be done at all?
2. What properties need to be set?
3. If can't be done, what the best approach to achieve this?
Thanks in advance!!
Michaelhi
try something like this.
CREATE TABLE demo_tab (
person_id NUMBER(3),
first_name VARCHAR2(20),
last_name VARCHAR2(20));
CREATE OR REPLACE VIEW upd_view AS
SELECT * FROM demo_tab;
INSERT INTO demo_tab
(person_id, first_name, last_name)
VALUES
(1, 'Daniel', 'Morgan');
INSERT INTO demo_tab
(person_id, first_name, last_name)
VALUES
(2, 'Helen', 'Lofstrom');
COMMIT;
SELECT * FROM upd_view;
UPDATE upd_view
SET person_id = person_id * 10;
SELECT * FROM upd_view;
desc user_updatable_columns
SELECT table_name, column_name, updatable, insertable, deletable
FROM user_updatable_columns
WHERE table_name IN (
SELECT view_name
FROM user_views);
SQL> create table dummy (f1 number);
Table created.
SQL> create view dummy_v
2 as
3 select f1 from dummy
4 union all
5 select f1 from dummy;
View created.
SQL> create trigger dummy_v_it
2 instead of insert
3 on dummy_v
4 for each row
5 begin
6 insert into dummy values (:NEW.f1);
7 end;
8 /
Trigger created.
SQL> insert into dummy_v values (1);
1 row created.
SQL> select * from dummy_v;
F1
1
1
SQL> select *
2 from user_updatable_columns
3 where table_name = 'DUMMY_V';
OWNER TABLE_NAME COLUMN_NAME UPD INS DEL
FORBESC DUMMY_V F1 NO NO NOforms settings.
Enforce Primary Key - No
Query Allowed - Yes
Query datasource Name - V_TSFDETAIL
Insert Allowed - Yes
Update Allowed - Yes
Delete Allowed - Yes
Locking Mode - Automatic
Key Mode - Automatic
do not forget to create synonyms.
hope this helps.
sarah
Maybe you are looking for
-
XML Publisher to BI Publisher - Report Upgrade
Hi all, Would like to know what the procedure is, if any, to convert XML Publisher Reports to BI Publisher report formats after an upgrade? Thanks
-
How do you change your security questions so I can but apps
I must have put a answer for a couple questions for when I buy apps but I can't change them and I forgot the answers . What do I do?!
-
IPhoto doesn't ask to delete imported photos
For years, iPhoto on my MacBook Pro always asked if I wanted to delete the photos from the camera after importing them. For the last year or so, iPhoto 11 didn't always do that with my previous camera, although it sometimes did. Since I got the new C
-
Permanent timeouts for 10 set of documents
I've been experimenting with DocumentDB and have added a couple of documents. Document Explorer won't load anymore (I'm assuming it times out, but it simply just loads for a while then display nothing but "Load more") and Query Explorer just times ou
-
No ask to buy option. I set up my son and he is automatically an adult. A calendar I had previously created called family has been shared with him. I can't remove the calendar, unshare it or delete it. Tried removing him from family share and re-addi