Help needed in writing a procedure
Guys, i need some more help.
I am selecting one value using select by passing a parameter to that select statement which are stored in a file using utl_file package.
Now, I want to use the output of that query and use that value to update a column in the same table.
for ex:-
select comm from emp where empno = &empno1;
I want to use the comm value and update the comm value.
update emp
set comm = comm + 10
where empno = &empno1
Help Appreciated
Thanks
SQL> desc emp
Name Null? Type
EMPLOYEE_ID NOT NULL NUMBER(6)
FIRST_NAME VARCHAR2(20)
LAST_NAME NOT NULL VARCHAR2(25)
EMAIL NOT NULL VARCHAR2(25)
PHONE_NUMBER VARCHAR2(20)
HIRE_DATE NOT NULL DATE
JOB_ID NOT NULL VARCHAR2(10)
SALARY NUMBER(8,2)
COMMISSION_PCT NUMBER(2,2)
MANAGER_ID NUMBER(6)
DEPARTMENT_ID NUMBER(4)
NET_SALARY NUMBER(12,2)
SQL> select salary,COMMISSION_PCT,net_salary from emp where employee_id = 198;
SALARY COMMISSION_PCT NET_SALARY
2600 .1
SQL> update emp
2 set net_salary = salary + (select COMMISSION_PCT from emp where employee_id = &&empno)*salary
3 where employee_id = &&empno
4 /
Enter value for empno: 198
old 2: set net_salary = salary + (select COMMISSION_PCT from emp where employee_id = &&empno)*salary
new 2: set net_salary = salary + (select COMMISSION_PCT from emp where employee_id = 198)*salary
old 3: where employee_id = &&empno
new 3: where employee_id = 198
1 row updated.
SQL> select salary,COMMISSION_PCT,net_salary from emp where employee_id = 198;
SALARY COMMISSION_PCT NET_SALARY
2600 .1 2860
Hope this helps;
Similar Messages
-
help needed for writing query
i have the following tables(with data) as mentioned below
FK*-foregin key (SUBJECTS)
FK**-foregin key (COMBINATION)
1)SUBJECTS(table name)
SUB_ID(NUMBER) SUB_CODE(VARCHAR2) SUB_NAME (VARCHAR2)
2 02 Computer Science
3 03 Physics
4 04 Chemistry
5 05 Mathematics
7 07 Commerce
8 08 Computer Applications
9 09 Biology
2)COMBINATION
COMB_ID(NUMBER) COMB_NAME(VARCHAR2) SUB_ID1(NUMBER(FK*)) SUB_ID2(NUMBER(FK*)) SUB_ID3(NUMBER(FK*)) SUBJ_ID4(NUMBER(FK*))
383 S1 9 4 2 3
384 S2 4 2 5 3
---------I actually designed the ABOVE table also like this
3) a)COMBINATION
COMB_ID(NUMBER) COMB_NAME(VARCHAR2)
383 S1
384 S2
b)COMBINATION_DET
COMBDET_ID(NUMBER) COMB_ID(FK**) SUB_ID(FK*)
1 383 9
2 383 4
3 383 2
4 383 3
5 384 4
6 384 2
7 384 5
8 384 3
Business rule: a combination consists of a maximum of 4 subjects (must contain)
and the user is less relevant to a COMB_NAME(name of combinations) but user need
the subjects contained in combinations
i need the following output
COMB_ID COMB_NAME SUBJECT1 SUBJECT2 SUBJECT3 SUBJECT4
383 S1 Biology Chemistry Computer Science Physics
384 S2 Chemistry Computer Science Mathematics Physics
or even this is enough(what i actually needed)
COMB_ID subjects
383 Biology,Chemistry,Computer Science,Physics
384 Chemistry,Computer Science,Mathematics,Physics
you can use any of the COMBINATION table(either (2) or (3))
and i want to know
1)which design is good in this case
(i think SUB_ID1,SUB_ID2,SUB_ID3,SUB_ID4 is not a
good method to link with same table but if 4 subjects only(and must) comes
detail table is not neccessary )
now i am achieving the result by program-coding in C# after getting the rows from oracle
i am using oracle 9i (also ODP.NET)
i want to know how can i get the result in the stored procedure itsef.
2)how it could be designed in any other way.
any help/suggestion is welcome
thanks for your time --PradeeshWell I forgot the table-alias, here now with:
SELECT C.COMB_ID
, C.COMB_NAME
, (SELECT SUB_NAME
FROM SUBJECTS
WHERE SUB_ID = C.SUB_ID1) AS SUBJECT_NAME1
, (SELECT SUB_NAME
FROM SUBJECTS
WHERE SUB_ID = C.SUB_ID2) AS SUBJECT_NAME2
, (SELECT SUB_NAME
FROM SUBJECTS
WHERE SUB_ID = C.SUB_ID3) AS SUBJECT_NAME3
, (SELECT SUB_NAME
FROM SUBJECTS
WHERE SUB_ID = C.SUB_ID4) AS SUBJECT_NAME4
FROM COMBINATION C;
As you need exactly 4 subjects, the columns-solution is just fine I would say. -
Help needed in writing a function.
I am using Oracle 11g and SQL plus. I am a complete newbie, so I need some help here in writing a function. I guess my question is more about writing the trigonometric functions within the function.
latA, longA latB, longB // these are the four input parameters,
theta = longA - longB
distX = sin( latA * PI / 180) * sin ( latB * PI /180) + cos ( latA * PI/180) * cos ( latB * PI/180) * cos ( theta * PI / 180)
distY = acos(distX) // this is arc cosine
distZ = distY * 180 / PI // PI refers to the mathematical PI
distP = distZ * 60 * 1.1515; // this value should be returned. Of course the intermediate variable names don't matter.
Please help. Thanks.CREATE OR REPLACE FUNCTION fucntion_name(latA IN NUMBER, longA IN NUMBER, latB IN NUMBER, longB IN NUMBER) RETURN NUMBER
IS
pi CONSTANT NUMBER:=3.14159;
theta NUMBER;
distX NUMBER;
distY NUMBER;
distZ NUMBER;
distP NUMBER;
BEGIN
theta :=longA - longB;
distX :=sin( latA * PI /180) * sin ( latB * PI /180) + cos ( latA * PI/180) * cos ( latB * PI/180) * cos ( theta * PI / 180);
distY :=acos(distX); --this is arc cosine
distZ :=distY * 180/PI; --PI refers to the mathematical PI
distP :=distZ * 60 * 1.1515; --this value should be returned. Of course the intermediate variable names don't matter.
RETURN distP;
END;Edited by: Ora on May 3, 2011 11:46 PM -
Help needed In testing a procedure
Hi,
This Is My procedure. I need to test this procedure. How can i pass multiple values to this first two parameters and check ?
CREATE OR REPLACE PROCEDURE testts (
i_custid IN str_varray,
i_pymtref IN str_varray,
i_screen IN VARCHAR2,
i_rejreason IN VARCHAR2,
i_userid IN tl_pymt_details.user_id%TYPE,
i_country_code IN tl_pymt_details.country_code%TYPE,
i_city_code IN tl_pymt_details.city_code%TYPE,
o_intrc OUT NUMBER
IS
w_intrc NUMBER;
w_excep EXCEPTION;
w_time_zone_date TIMESTAMP ( 6 );
w_custid tl_pymt_details.cust_id%TYPE;
w_pymtref tl_pymt_details.pymt_ref%TYPE;
BEGIN
IF i_screen = 'confirm'
THEN
FOR i IN 1 .. i_custid.COUNT
LOOP
w_custid := i_custid (i);
w_pymtref := i_pymtref (i);
sp_031_process_time_zone_diff (w_time_zone_date);
UPDATE tl_pymt_details
SET status_code = 151
WHERE cust_id = i_custid (i) AND pymt_ref = i_pymtref (i);
INSERT INTO tl_pymt_details_trk
(cust_id, pymt_ref, modi_date, status_code,
payee_charge_status, modi_by, country_code, city_code)
(SELECT cust_id, pymt_ref, w_time_zone_date, status_code,
payee_charge_status, i_userid, pd.country_code,
pd.city_code
FROM tl_pymt_details pd, tl_sys_parm sp
WHERE cust_id = i_custid (i)
AND pymt_ref = i_pymtref (i)
AND pd.country_code = i_country_code
AND pd.city_code = i_city_code);
END LOOP;
ELSE
FOR i IN 1 .. i_custid.COUNT
LOOP
w_custid := i_custid (i);
w_pymtref := i_pymtref (i);
sp_031_process_time_zone_diff (w_time_zone_date);
UPDATE tl_pymt_details
SET status_code = 5,
rejected_reason = i_rejreason
WHERE cust_id = i_custid (i) AND pymt_ref = i_pymtref (i);
INSERT INTO tl_pymt_details_trk
(cust_id, pymt_ref, modi_date, status_code,
payee_charge_status, modi_by, country_code, city_code)
(SELECT cust_id, pymt_ref, w_time_zone_date, status_code,
payee_charge_status, i_userid, pd.country_code,
pd.city_code
FROM tl_pymt_details pd, tl_sys_parm sp
WHERE cust_id = i_custid (i)
AND pymt_ref = i_pymtref (i)
AND pd.country_code = i_country_code
AND pd.city_code = i_city_code);
END LOOP;
END IF;
o_intrc := 1;
END testts;
Your Help is highly appreciated.
Regards,
SImma....Hi,
I supposed your varray is created by TYPE str_varray IS VARRAY(100) OF VARCHAR2(30); Then you can do the following:
declare
l_custid str_varray;
l_pymtref str_varray;
l_out number;
begin
/* filling of varray */
l_custid := str_varray('test1','test2');
l_pymtref := str_varray('test4','test5');
/* call procedure */
testts (
i_custid => l_custid,
i_pymtref => l_pymtref,
i_screen => ..... , -- set value
i_rejreason => ..... , -- set value
i_userid => ..... , -- set value
i_country_code => ..... , -- set value
i_city_code => ..... , -- set value
o_intrc => l_out
end;Herald ten Dam
http://htendam.wordpress.com -
Help needed to create a Procedure
Can anyone help me with a small procedure I have to write?
Requirement to create Stored Procedure :
1. Create tables
A1
A2
B1
B2
----------- this is done------
Fill the data in those tables
------------this is also done----
Create "Source_table.tx"t file with table names and place them in any location.
------------this is also done----
write a procedure to read the above file "Source_table.txt" and it should read the tables name 1 by 1 which performs a simple operation inside SP -->
Select * from @Table_Name
Also, it should check if the .txt file is exisiting or not.
If exists then Read the file and execute the SP.
SP does this :
Select * from A1
Select * from A2
Select * from B1
Select * from B2
After that, write an output file with the counts of records to the same location where our Source_table.txt exists .
If doesnt exist then write to a .txt file that "File name and Location doesnt exist"What format is the data inside your .txt file?
If it's just some lines containing the names of the tables then you may as well just use the UTL_FILE package to:
a) check the existence of the file using the UTL_FILE.FGETATTR procedure
b) open and read the contents of the file using the UTL_FILE.FOPEN, UTL_FILE.GET_LINE and UTL_FILE.FCLOSE functions/procedures.
UTL_FILE
Alternatively you could set up an external table to read the .txt file as though it's a table.
Managing External Tables
Once you extract the table names from the .txt file, you'll then have to construct dynamic SQL queries to query the data from them. Are all of the tables of the same structure or do they change? If they change you'll have to use the DBMS_SQL package. If they don't you could do it more statically in PL/SQL code (at least in terms of the structures you're reading the data into), but you may still be better using DBMS_SQL for it. It depends what you're trying to do exactly and why these table names are being exported to a file and need to be read dynamically in this way. Often Dynamic coding indicates poor design, but without knowing exactly what you're doing, it's hard to tell if it's really necessary or not. -
Hi,
Could anyone help me in writing below query without syntax errors.
I tried but no luck
select xmlelement("g", XMLATTRIBUTES(g.contentgroup_id as "id",g.groupname as "label",
(select xmlagg(xmlelement ("c",XMLATTRIBUTES(c.title as "title",c.content_id as "id")))) as "A"))
as "A" from
(SELECT g.contentgroup_id AS id, g.groupname AS label, c.title AS label, c.content_id AS id
FROM content_ec c FULL OUTER JOIN contentgroup_ec g ON c.group_id = g.contentgroup_id
oRDER BY g.groupname ,c.title ASC );
Any help really appreciated.
ThanksFew tips to get your question answered here
1. Give your database version. Some thing that does not work in one version works fine in the next. And 8i,9i or 10g is not version. best way to give the version is to query your v$version table like this.
SQL> select * from v$version where rownum = 1
2 /
BANNER
Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Prod2. You should understand we don't have what you have, meaning you should provide your data structure and some sample data for us to help.
3. "I got an error"... "Its not working"... and the list goes on. Sentences like this does not help. If you got a error past the entire error. If stuff does not work, tell us the details.
4. Just don't throw some output and say i want it. Please explain to every one how you derive it.
5. And the most important thing. Use \...\ tag to format. Please.. Please.. Please.. use it. It helps every one a lot. When you use it your SQL looks some thing like this.
SELECT xmlelement("g", XMLATTRIBUTES(g.contentgroup_id as "id",g.groupname as "label",
(select xmlagg(xmlelement ("c",XMLATTRIBUTES(c.title as "title",c.content_id as "id")))) as "A")) as "A"
FROM (SELECT g.contentgroup_id AS id,
g.groupname AS label,
c.title AS label,
c.content_id AS id
FROM content_ec c
FULL OUTER JOIN contentgroup_ec g
ON c.group_id = g.contentgroup_id
ORDER BY g.groupname ,c.title ASC );6. And also do search this forum. Most of your my queries are answered by simple search.
Thanks,
Karthick. -
Help needed in writing a Query/Procedure
Hello All,
Need all ur help in writing a query or procedure
Lets say the Table name is DEMO
There i have one column like num it has values
1
2
3
4
5
8
9
10
my query output should be
1-5
8-10
i,e .. if the diff between two rows is greater than 1 then it result should be in a separate group
I need a query/Procedure for this. Kindly help
Regards,
ChandraTried obtaining the output using SQL and the result is as follows:
SQL> WITH T AS
2 (
3 SELECT 1 COL1 FROM DUAL
4 UNION
5 SELECT 2 COL1 FROM DUAL
6 UNION
7 SELECT 3 COL1 FROM DUAL
8 UNION
9 SELECT 4 COL1 FROM DUAL
10 UNION
11 SELECT 5 COL1 FROM DUAL
12 UNION
13 SELECT 8 COL1 FROM DUAL
14 UNION
15 SELECT 9 COL1 FROM DUAL
16 UNION
17 SELECT 10 COL1 FROM DUAL
18 UNION
19 SELECT 13 COL1 FROM DUAL
20 UNION
21 SELECT 14 COL1 FROM DUAL
22 UNION
23 SELECT 15 COL1 FROM DUAL
24 UNION
25 SELECT 16 COL1 FROM DUAL
26 UNION
27 SELECT 23 COL1 FROM DUAL
28 UNION
29 SELECT 24 COL1 FROM DUAL
30 )
31 SELECT OUTPUT FROM
32 (
33 SELECT DECODE(COL3,NULL,COL1, COL2) || '-' || LEAD(DECODE(COL3,NULL,COL3, COL1)) OVER (ORDER BY DECODE(COL3,NULL,COL1, COL2)) OUTPUT FROM
34 (
35 SELECT COL1, LEAD(COL1) OVER (ORDER BY COL1) COL2, LAG(COL1) OVER (ORDER BY COL1) COL3 FROM T
36 )
37 WHERE
38 (COL2 - COL1 > 1 OR COL2 IS NULL OR COL3 IS NULL)
39 )
40 WHERE OUTPUT != '-';
OUTPUT
1-5
8-10
13-16
23-24 -
Help Needed - Step by Step Procedure CMOS / BIOS Reset (MSI GX600)
Hi guys,
I gave my old MSI GX600 laptop to my parents (after I got married) the catch is... they had some virus problems with the laptop (after a few months) and had a technician (just a guy manning a cyber cafe) check the laptop. When they got the laptop back it now has a BIOS password... to make matters worse... the guy gave the wrong password for the BIOS... and insists that - that's the password. (the guy didn't have any rights placing a BIOS password - it's not his laptop to begin with).
So basically we can't boot to Windows since when you turn-on the laptop the first thing you see is the BIOS login. They contacted me to try and resolve the situation. I thought that the best way to reset it to factory default... so I went on the net and looked for ways to do the BIOS reset (factory default) and so far everything I tried still resulted to not having it reset back to faculty default. The BIOS login is still there.
Below are the things I did... any help on this matter will be greatly appreciated.
1. Uplugged the Laptop
2. Removed the batteries
3. Removed bottom panel
4. Un-attach Internal Battery connector to the mainboard (have no idea how to short it... since there are videos on shorting the board [but that's for MSI motherboards and not for laptops])
5. Left it for a few minutes
6. Connected everything again
7. Re-booted the laptop
Anyhow, it still asks for the BIOS login. I even went to the extent of removing all the connectors I can see on the board. But still to no avail. Anyhow, I have no idea what the guy (technician) did to the laptop but it still continues to ask for the BIOS password. Any help regarding this matter... the proper way or procedure of doing it would be greatly appreciated. I just need to remove the BIOS password requirement that is now implemented on the laptop.
Thanks in advanced!We don't assist with password removal, contact msi at >>How to contact MSI.<<
-
Help need for PL/SQL procedure
Hi guys,
I have scenario like this
Schema T LOGTABLENAME TDIRECTORY
DEV DEV.ABC_LOG import-abc
DEV DEV.GBTSLOG import-gbts
DEV DEV.CLSSBOG import-cls
QA QA.TransactionlOG import-transaction
QA1 QA1.tlog import-ess
QA2 QA2.translog import-trnals
I have to write a procedure to get the log table data from schema Dev.I have to take Shcema dev and go to DEv.abc_log table and get the record from the dev.abc_logtable. The same way for other schema also with respective logtables .
I would appreciate your help or suggestions.
Reards,
User
Edited by: user1758353 on Dec 5, 2008 11:43 AMhello,
im also not sure if i get the point but maybe you need sth. like that...
create table schema_logtable as
select 'dev' schema, 'dev.abc_log' tlogtable, 'import-abc' tdirectory from dual union all
select 'dev', 'dev.gbtslog', 'import-gpts' from dual union all
select 'dev', 'dev.clssbog', 'import-cls' from dual );
declare
v_slt_row schema_logtable%rowtype;
type log_description_table is table of varchar2(1000char);
v_log_description log_description_table := log_description_table();
begin
for v_slt_row in ( select * from schema_logtable )
loop
execute immediate 'select log_description from ' || v_slt_row.tlogtable bulk collect into v_log_description;
for i in v_log_description.first .. v_log_description.last
loop
dbms_output.put_Line( 'log_desc: ' || v_log_description(i) );
end loop;
end loop;
end;
/this reads for every schema in table schema_logtable the name of the logtable.
for each logtable you fetch all rows of that table into a variable and you can do what-ever you want with that...
-mario -
Help needed in TEXT determination procedure - Urgent
Hi Experts,
I have defined my own text determination procedure for complaints. This procedure is for the item category for the transaction(complaint).
The following are the Text ID's that I have include in my procedure :
1. C001
2. C002
3. C003
My requirment is to have logs(history) for each of the text id's(C001, C002, C003).
i.e. what ever i do in C001, it has to be loogged only in text id let;s say ZC001, same way C002 shld be logged only in ZC002 and C003 in ZC003.
I have also defined ZC001, ZC002, ZC003 in the text detrmination procedure.
Please help me in slving this problem. Can i do it in the config itself or shld i go for development?.
Regards,
Arul Jothi A.hi,
This is what exactly i am lloking for, but i tried with your proposal. It didint work.
Please find the detailos below.
Text Object CRM_ORDERI
Text Det.Proc: ZCOMP001
Text Type Description Seq. changes Transfer Access Seq.
C001 Complaints Text 0001 P - -
Z001 complaints1 0002 R A ZC01
C002 Internal note 0003 P - -
Z002 original text test 0004 R A ZC02
C003 Recomm. Solution 0005 P - -
Z003 original text 3 0006 R A ZC03
Access Seq :
ZC01 :
Ref. Object CRM_ORDERI
Ref. Text Type C001
continue chcked.
ZC02.
Ref. Object CRM_ORDERI
Ref. Text Type C002
continue chked
ZC03.
Ref. Object CRM_ORDERI
Ref. Text Type C003
continue chked
I want to log all C001 text into Z001 only, C002 in Z002 only and C003 in Z003 only.
hope you got it....
Please help.
Regrads,
Arul Jothi A -
Help needed in writing SQL CASE or DECODE statement
Hi experts,
I need to write a SQL to select order_num, cntry_cde, prod_id and Qty by joining order_num on PROD_ORDER and PROD_ORDER_TXT.
Here is my sample data
PRODORDER_
order_num cntry_cde Prod_id Qty
100 US A1 5
101 US A2 10
102 AU A3 4
103 AU A4 9
104 IN A5 3
PRODORDER_TXT_
order_num cntry_cde Prod_id
100 US A1
101 US A2
102 NZ A3
103 AU A4
104 A5
Here is the requirement,
1) If the cntry_cde in PROD_ORDER is same as cntry_cde in PROD_ORDER_TXT then select PROD_ORDER.cntry_cde (orders 100, 101, 103)
2) If they are different, pick the country code from PROD_ORDER_TXT (order 102, AU <> NZ)
3) If they are different and PROD_ORDER_TXT.cntry_cde is NULL, I cannot use it as cntry_cde in my report (order 104). It happenend just because of the bad data at source.
I cannot avoid it. Then simply use the cntry_cde from PROD_ORDER
Output expected
100 US A1 5
101 US A2 10
102 NZ A3 4 -- AU changed to NZ
103 AU A4 9
104 IN A5 3 -- IN retained as PROD_ORDER_TXT.cntry_cde is null
sample table creation and insert statements are below
create table prod_order
(order_num number,
cntry_cde CHAR(2),
prod_id VARCHAR2(6),
qty number)
create table prod_order_txt
(order_num number,
cntry_cde CHAR(2),
prod_id VARCHAR2(6))
insert into prod_order values (100, 'US', 'A1',5);
insert into prod_order values (101, 'US', 'A2',1);
insert into prod_order values (102, 'AU', 'A3',4);
insert into prod_order values (103, 'AU', 'A4',9);
insert into prod_order values (104, 'IN', 'A5',3);
insert into prod_order_txt values (100,'US','A1');
insert into prod_order_txt values (101,'US','A2');
insert into prod_order_txt values (102,'NZ','A3');
insert into prod_order_txt values (103,'AU','A4');
insert into prod_order_txt values (104,NULL,'A5');
commit;
Thanks for your help in advance
Edited by: sarvan on Mar 28, 2012 1:39 PMHello
Thank you for posting all of the ddl and test data along with your expected output - very helpful!. One small point would be to remember to type {noformat}{noformat} before and after any section of code or data in your post so that formatting is retained. Anyway, this should be a simple join and a combination of CASE and NVL...Select
po.order_num,
CASE
WHEN po.cntry_cde != NVL(pot.cntry_cde,po.cntry_cde)
THEN
pot.cntry_cde
ELSE
po.cntry_cde
END cntry_code,
po.prod_id,
po.qty
FROM
prod_order po
JOIN
prod_order_txt pot
ON
( po.order_num = pot.order_num
ORDER_NUM CN PROD_I QTY
100 US A1 5
101 US A2 1
102 NZ A3 4
103 AU A4 9
104 IN A5 3
5 rows selected.
HTH
David
Edited by: Bravid on Mar 28, 2012 8:32 AM
corrected != -
Urgent help needed on writing errors in to windows events application logs
Hi all,
we have web based application. Whenever there is critical errors encounters in our application we need to write that errors in to windows
event viewer, application logs. Please help me on how to do this.
do we have any specific API for this ?
thanks in advance
ShivakumarYou should use WinAPI to do so. Asking in JNI forum (or specialized WinAPI forum) for more details is good idea I think.
-
Urgent help needed on writing errors in to windows application logs
Hi all,
we have web based application. Whenever there is critical errors encounters in our application we need to write that errors in to windows
event viewer, application logs. Please help me on how to do this.
do we have any specific API for this ?
thanks in advance
ShivakumarYou should use WinAPI and followed functions: RegisterEventSource(), ReportEvent() and may be some more. It was some time ago as I deal with...
-
Help Needed in Xml Stored Procedure
Hi , i am trying to write one sp which takes xml document as a parameter. I want to update/Insert the data in the xml based on some conditions. So i put the data from xml to a global TEMPORARY table. The i process this data and will update /Insert the data based on the output.
Right now i am unable to create global TEMPORARY table my stored procedure .When i compile the stored procedure , its showing the following error
Compilation errors for PROCEDURE SYSTEM.TESTXML
Error: PLS-00103: Encountered the symbol "CREATE" when expecting one of the following:
begin case declare exit for goto if loop mod null pragma
raise return select update while with <an identifier>
<<
close current delete fetch lock insert open rollback
savepoint set sql execute commit forall merge pipe
Line: 8
Text: CREATE GLOBAL TEMPORARY TABLE temp
I am attaching my sp below
create or replace procedure testxml
( xmlDoc IN clob )
is
updCtx DBMS_XMLStore.ctxType;
rows NUMBER;
begin
CREATE GLOBAL TEMPORARY TABLE temp
( cdcalendar NUMBER,
cdperiod NUMBER,
cdsubperiod NUMBER,
cdglperiod NUMBER,
dtstartsubperiod date,
dtendsubperiod date
) ON COMMIT PRESERVE ROWS;
updCtx := DBMS_XMLStore.newContext(temp)
rows := DBMS_XMLStore.insertXML(updCtx,xmlDoc);
DBMS_XMLStore.closeContext(updCtx);
if Not exists
(Select Distinct cd_calendar from Calendar_Period
Where cd_calendar = select Distinct cdcalendar from temp )
Then
Insert into calendar_period
cd_calendar,
cd_period,
cd_subperiod,
cd_gl_period,
dt_start_subperiod,
dt_end_subperiod
select cdcalendar,
cdperiod,
cdsubperiod,
cdglperiod,
dtstartsubperiod,
dtendsubperiod
from temp ;
Else
Update calendar_period
Set cdp.cd_calendar = temp.cdcalendar ,
cdp.cd_period = temp.cdperiod,
cdp.cd_subperiod = temp.cdsubperiod ,
cdp.cd_gl_period = temp.cdglperiod,
cdp.dt_start_subperiod = temp.dtstartsubperiod ,
cdp.dt_end_subperiod = temp.dtendsubperiod
From
calendar_period cdp Inner Join temp
On
cdp.cd_calendar = temp.cdcalendar
cdp.cd_subperiod = temp.cdsubperiod
cdp.cd_period = temp.cdperiod ;
End if
end testxml;
Kindly guide me !!!!Hi,
"CREATE GLOBAL TEMPORARY TABLE" is not a PL/SQL sommand; it is a SQL command. That explain the error message you're getting.
Normally, tables (including Global Temporary Tables) are created once for all, without using PL/SQL. After they are created, you can write PL/SQL code to populate and use them. This job doies not seem to be an exception.
In the rare event that you do need to create a table in PL/SQL, use EXECUTE IMMEDIATE, which can do any SQL command from withiin PL/SQL.
EXECUTE IMMEDIATE is documented in the PL/SQL manual:
http://download.oracle.com/docs/cd/B28359_01/appdev.111/b28370/dynamic.htm#sthref857 -
Help needed in writing a query
Hi all,
Following is the structure of my table.
Data
Key Number
Id Number
Value varchar2(100)
activity_name varchar2(100)
Creation_Date Date
Eval_Point varchar2(100)
In the above table Id is the primary key.
The column eval_point holds only two types of entries 'activation' or 'completion'
The activity_name column holds the name of the activity.
The sample entries in the table are as follows
Key Value activity_name Creation_Date Id Eval_Point
260002 XXX assign_1 2007-09-21 16:58:41.920000 951 activation
260002 XXX assign_1 2007-09-21 16:58:43.392000 953 completion
260002 XXX assign_2 2007-09-21 16:59:03.732000 956 activation
260002 XXX assign_2 2007-09-21 16:59:04.112000 954 completion
260002 XXX assign_3 2007-09-21 16:59:24.331000 958 activation
260002 XXX assign_3 2007-09-21 16:59:24.421000 957 completion
i need to write a query which gives me data in the following format
value id start_date end_date
XXX YYY 2007-09-21 16:58:41.920000 2007-09-21 16:58:43.392000
where start_date is the creation date of the 'activation' and end_date is the creation_date of 'completion'.
Can somebody help?
-thanks
lavanyahello all,
I would like to re frame my question.
this is the output of the base query
select id,instance_key,sensor_target,activity_sensor,creation_date,eval_point from bpel_variable_sensor_values where instance_key=260002;
953 260002 Assign_1 952 2007-09-21 16:58:43.392000 completion
951 260002 Assign_1 952 2007-09-21 16:58:41.920000 activation
956 260002 Assign_2 955 2007-09-21 16:59:03.732000 activation
954 260002 Assign_2 955 2007-09-21 16:59:04.112000 completion
958 260002 Assign_3 959 2007-09-21 16:59:24.331000 activation
957 260002 Assign_3 959 2007-09-21 16:59:24.421000 completion
962 260002 Assign_4 960 2007-09-21 16:59:44.741000 completion
961 260002 Assign_4 960 2007-09-21 16:59:44.640000 activation
964 260002 Assign_5 965 2007-09-21 17:00:05.290000 completion
963 260002 Assign_5 965 2007-09-21 17:00:04.950000 activation
I am trying out this query
select a.instance_key,a.creation_date,b.creation_date,a.id
from bpel_variable_sensor_values a, bpel_variable_sensor_values b
where a.instance_key=b.instance_key
and a.instance_key=260002
and a.eval_point='activation'
and b.eval_point='completion'
and i am getting 25 entries i.e a cartesian product of a.creation_date
260002 2007-09-21 16:58:41.920000 2007-09-21 16:58:43.392000 951
260002 2007-09-21 16:58:41.920000 2007-09-21 16:59:04.112000 951
260002 2007-09-21 16:58:41.920000 2007-09-21 16:59:24.421000 951
260002 2007-09-21 16:58:41.920000 2007-09-21 16:59:44.741000 951
260002 2007-09-21 16:58:41.920000 2007-09-21 17:00:05.290000 951
260002 2007-09-21 16:59:03.732000 2007-09-21 16:58:43.392000 956
260002 2007-09-21 16:59:03.732000 2007-09-21 16:59:04.112000 956
260002 2007-09-21 16:59:03.732000 2007-09-21 16:59:24.421000 956
260002 2007-09-21 16:59:03.732000 2007-09-21 16:59:44.741000 956
260002 2007-09-21 16:59:03.732000 2007-09-21 17:00:05.290000 956
260002 2007-09-21 16:59:24.331000 2007-09-21 16:58:43.392000 958
260002 2007-09-21 16:59:24.331000 2007-09-21 16:59:04.112000 958
260002 2007-09-21 16:59:24.331000 2007-09-21 16:59:24.421000 958
260002 2007-09-21 16:59:24.331000 2007-09-21 16:59:44.741000 958
260002 2007-09-21 16:59:24.331000 2007-09-21 17:00:05.290000 958
260002 2007-09-21 16:59:44.640000 2007-09-21 16:58:43.392000 961
260002 2007-09-21 16:59:44.640000 2007-09-21 16:59:04.112000 961
260002 2007-09-21 16:59:44.640000 2007-09-21 16:59:24.421000 961
260002 2007-09-21 16:59:44.640000 2007-09-21 16:59:44.741000 961
260002 2007-09-21 16:59:44.640000 2007-09-21 17:00:05.290000 961
260002 2007-09-21 17:00:04.950000 2007-09-21 16:58:43.392000 963
260002 2007-09-21 17:00:04.950000 2007-09-21 16:59:04.112000 963
260002 2007-09-21 17:00:04.950000 2007-09-21 16:59:24.421000 963
260002 2007-09-21 17:00:04.950000 2007-09-21 16:59:44.741000 963
260002 2007-09-21 17:00:04.950000 2007-09-21 17:00:05.290000 963
can soembody help me to reduce these to 5 rows.
Maybe you are looking for
-
Multi-row "Drag and Drop" works for some users, not others
Background: We are working on Win7 SP1 clients, Project Prof. 2010, SP2 A couple of users have reported that they cannot move ("drag") multiple selected rows in a task sheet, only a single row at a time. Other MS Project users around them
-
Network Error when Trying to Use V Cast Apps on OS 6.0
I recently updated to OS 6.0 on my Bold 9650 via the OTA and the VCast Apps icon is now visible on my device. When I select teh icon, it opens 1.0.8 build .8. When I try to select a category, I am prompted for a "V CAST Apps Update" that I must comp
-
RE: Is it possible to sort tags?
This is a continuation of the Support Forum question titled: “Is it possible to sort tags?” located at: https://support.mozilla.org/en-US/questions/963133?esab=a&as=s&r=2&page=1 If this new topic has to be posed as a new question the following applie
-
Hi all ODI Gurus, I have reverse engineered a table in ODI. say tab_a Subsequently I drop the table in the database and create a table say 'tab_b', which is the same as 'tab_a'. In ODI model, I just change the name of the object from 'tab_a' to 'tab_
-
Hi All, I stumbled upon an issue on WAD. First page of my WAD report should show only the Radio buttons. Using that I will open different queries. But when I execute the report I am getting all the variable selection screen of all the queries embedde