FORMS_DDL with select into
Hi,
Here my code for un dynamic query in ORACLE FORMS
ls_query:=' select count(*) into ' || pkg_hist.pkg_count_pdt ||' from FN_WAVE_PROD_HIER_DETAIL where PROD_HIER_ID='||:b_produit.PROD_HIER_ID ||' and division ='|| :b_produit.division || pkg_and_clause ;
Forms_ddl ( ls_query );
/* Where pkg_and_clause contains the dynamic statement
and pkg_hist.pkg_count_pdt is a package variable
I got the following error : ORA-24374: define not done before fetch or execute and fetch
Does this code can works ?
regards
Edited by: Totem92 on 3 août 2011 07:57
This forum is about C programming in general, and about using the Studio C compiler. Your question is about Oracle database programming. I suggest you try a database forum here:
http://forums.oracle.com/
Similar Messages
-
Dynamic Pivot with Select Into
I have this Dynamic Pivot which works fine.
DECLARE @query VARCHAR(4000)
DECLARE @years VARCHAR(2000)
SELECT @years = STUFF(( SELECT DISTINCT'],[' + [factor_label]
FROM [TEMP_lacp_factors]
ORDER BY '],[' + [factor_label]
FOR XML PATH('')
), 1, 2, '') + ']'
SET @query =
'SELECT * FROM
SELECT [date_],[issue_id],[cusip],[Factor_value],[factor_label]
FROM [TEMP_lacp_factors]
)t
PIVOT (MAX([factor_value]) FOR [factor_label]
IN ('+@years+')) AS pvt'
EXECUTE (@query)
I'm trying to take the results of that and do a SELECT INTO, so I can move the results to another table. Is this possible? I didn't find a whole lot online.
The error that I'm getting is this.
Caused by: Column name or number of supplied values does not match table definition.
How can I do this? Is it even possible?
Knowledge is the only thing that I can give you, and still retain, and we are both better off for it.Sure, you can create a table with SELECT INTO, but it cannot be a #temptable. Well, it can be a #temptable, but it will disappear as soon as you exit the scope it was created it, that is the dynamic SQL.
The question is only, what would you do with this table later? Since you don't know the column names, about all work will have to be done through dynamic SQL.
A dynamic pivot is a non-relational operation. A SELECT statement produces a table, and a table describes a distinct entity, of which the column are distinct and well-defined attributes. Something which your dynamic pivot does not adhere to.
There is only one thing you can do with your dynamic pivot: returning the data to the client. I don't know what you want to do with that table, but probably you should do that manipulation before the dynamic pivot, because as I said: that is always your
last step.
Erland Sommarskog, SQL Server MVP, [email protected] -
Dynamic column name with SELECT INTO
I am trying to build a function that derives a pay amount from a set of business rules. There are about 40 columns that hold various pay amounts and their column names are variations of 4 indicators (day shift, vs night shift, etc.) that I have to dynamically look up, ie here is the ID number and a timecard, now figure out which of the 40 fields to look up to get the pay amount.
I can determine from the timecard and employee ID which field to look at, but I'm getting hung up with the syntax needed to construct and execute the statement inside the PL/SQL block. I need to RETURN the pay I extract using the function, and I can create the correct SQL statement, but the EXECUTE IMMEDIATE won't accept the SELECT INTO syntax.
Can someone please suggest a solution? Here is the function:
create or replace FUNCTION FN_GET_PAYRATE(tc in NUMBER, e in NUMBER, pc in VARCHAR2)
RETURN NUMBER
IS
e_id NUMBER;
tc_id NUMBER;
pl_cd VARCHAR2(7);
shft VARCHAR2(2);
lvl VARCHAR2(2);
typ VARCHAR2(2);
e_typ VARCHAR2(4);
proj NUMBER;
hrly VARCHAR2(4);
payrt NUMBER;
var_col VARCHAR2(10);
sql_select VARCHAR2(200);
sql_from VARCHAR2(200);
sql_where VARCHAR2(200);
sql_and1 VARCHAR2(200);
sql_and2 VARCHAR2(200);
sql_and3 VARCHAR2(200);
sql_orderby VARCHAR2(200);
var_sql VARCHAR2(2000);
BEGIN
e_id := e;
tc_id := tc;
pl_cd := pc;
SELECT NVL(SHIFT,'D') INTO shft
FROM TS_TIMECARD_MAIN
WHERE TIMECARD_ID = tc_id;
--DBMS_OUTPUT.PUT_LINE('SHIFT= ' || shft);
SELECT NVL(PAY_LVL, 1), NVL(PAY_TYPE, 'B'), NVL(RTRIM(EMP_TYPE), 'LHD'), NVL(PROJECT, 001)
INTO lvl, typ, e_typ, proj
FROM TS_EMPLOYEES
WHERE EMP_ID = e_id;
--DBMS_OUTPUT.PUT_LINE('Level= ' || lvl);
--DBMS_OUTPUT.PUT_LINE('PAY_TYPE= ' || typ);
--DBMS_OUTPUT.PUT_LINE('EMP_TYPE= ' || e_typ);
--DBMS_OUTPUT.PUT_LINE('PROJECT= ' || proj);
IF e_typ <> 'LHD' THEN
hrly := 'H';
ELSE
hrly := '';
END IF;
IF proj <> 001 THEN
var_col := shft || lvl || typ || hrly;
--DBMS_OUTPUT.PUT_LINE('RATE COLUMN= ' || var_col);
sql_select := 'SELECT NVL(' || var_col || ', .01) INTO payrt';
sql_from := ' FROM TS_PAYRATES';
sql_where := ' WHERE PROJECT_ID = ' || proj;
sql_and1 := ' AND ACTIVE = 1';
sql_and2 := ' AND JOB_TYPE = ' || CHR(39) || e_typ || CHR(39);
sql_and3 := ' AND PILE_ID = ' || CHR(39) || pl_cd || CHR(39);
var_sql := sql_select || sql_from || sql_where || sql_and1 || sql_and2 || sql_and3 || sql_orderby;
DBMS_OUTPUT.PUT_LINE('SQL: ' || var_sql);
EXECUTE IMMEDIATE var_sql;
DBMS_OUTPUT.PUT_LINE('RATE= ' || payrt);
RETURN payrt;
ELSE
DBMS_OUTPUT.PUT_LINE('ERROR');
RETURN 1;
END IF;
END;
I have alternately tried this:
SELECT NVL(var_col,.01) into payrt
FROM TS_PAYRATES
WHERE PROJECT_ID = proj AND ACTIVE = 1
AND JOB_TYPE = CHR(39) || e_typ || CHR(39)
AND PILE_ID = CHR(39) || pl_cd || CHR(39);
as a substitute for the EXECUTE IMMEDIATE block, but I can't seem to use a dynamic substitution for the column name.
Any help would be greatly appreciated.That's the most difficult part - the error messages seem to indicate a problem with the SQL statement in its execution context, because I can take the SQL string by itself and it executes perfectly.
Here are three variations:
SELECT INTO
select fn_get_payrate(21555, 30162, 15) from dual
ERROR at line 1:
ORA-00905: missing keyword
ORA-06512: at "PEOPLENETIF.FN_GET_PAYRATE", line 60
SQL: SELECT NVL(N4P , .01) INTO payrt FROM TS_PAYRATES WHERE PROJECT_ID = 701 AND ACTIVE = 1 AND JOB_TYPE = 'LHD' AND PILE_ID = '15'
Without SELECT INTO (returns NULL)
SQL> select fn_get_payrate(21555, 30162, 15) from dual;
FN_GET_PAYRATE(21555,30162,15)
SQL: SELECT NVL(N4P , .01) FROM TS_PAYRATES WHERE PROJECT_ID = 701 AND ACTIVE = 1 AND JOB_TYPE = 'LHD' AND PILE_ID = '15'
RATE=
EXECUTE IMMEDIATE USING
SQL> select fn_get_payrate(21555, 30162, 15) from dual;
select fn_get_payrate(21555, 30162, 15) from dual
ERROR at line 1:
ORA-01006: bind variable does not exist
ORA-06512: at "PEOPLENETIF.FN_GET_PAYRATE", line 61
SQL: SELECT NVL(N4P , .01) FROM TS_PAYRATES WHERE PROJECT_ID = 701 AND ACTIVE = 1 AND JOB_TYPE = 'LHD' AND PILE_ID = '15' -
Good morning everyone,
I have a problem with my function. I need to do the dynamic select with the SELECT INTO
create or replace function prueba (p_param IN VARCHAR2) RETURN VARCHAR2
IS
v_aux1 VARCHAR2(200);
v_aux2 VARCHAR2(200);
BEGIN
SELECT col1
INTO v_aux1
FROM my_table
WHERE col2 = p_param; --UNION SELECT '1233' FROM DUAL;
RETURN v_aux1;
EXCEPTION
WHEN OTHERS THEN
RAISE_APPLICATION_ERROR(-20000,SQLERRM );
--RETURN v_aux2;
END;
When I try to call my function with the golden as follows:
select (prueba('''MON'' UNION SELECT '||chr(039)||'12'||chr(039)||' FROM DUAL')) from dual
OR
select (prueba(chr(039)||'MON'||chr(039)||' UNION SELECT '||chr(039)||'12'||chr(039)||' FROM DUAL')) from dual
I get the error: no data found
If I use the sentence in Golden or SQLPLUS as follows:
SELECT col1
-- INTO aux1
FROM my_table
WHERE despaise = 'MON' UNION SELECT '12' FROM DUAL
It ´s correct, and it return '1233'
The value 'MON' no exists in my_table.
If uncommented the sentence "UNION SELECT '1233' FROM DUAL" in my function an I use 'MON' as parameter it´s correct.
How I can do this using the parameter with the UNION?.
Thank you very much to all and sorry for my englishHi,
welcome to the forum.
Please read SQL and PL/SQL FAQ
When you put some code or output please enclose it between two lines starting with {noformat}{noformat}
i.e.:
{noformat}{noformat}
SELECT ...
{noformat}{noformat}
you cannot pass static SQL as part of the string.
When you call the procedure in either wayselect (prueba('''MON'' UNION SELECT '||chr(039)||'12'||chr(039)||' FROM DUAL')) from dual
select (prueba(chr(039)||'MON'||chr(039)||' UNION SELECT '||chr(039)||'12'||chr(039)||' FROM DUAL')) from dual
This result in passing a whole string to your function as'MON' UNION SELECT '12' FROM DUAL
which translates in your code asSELECT col1
INTO v_aux1
FROM my_table
WHERE col2 = '''MON'' UNION SELECT ''12'' FROM DUAL'
So it is searching a rows having col2 with value '''MON'' UNION SELECT ''12'' FROM DUAL'
Please try to explain what you are trying to achieve and we may help you.
You could use dynamic SQL to do that but it is not clear what are your business requirement and the approach that you are using does not seem to be correct.
Regards.
Al -
Case with select into and sub query
hi im trying to use case and select with sebqueries, but my beginer like understanding of syntax fails me. can someone point out what im doing wrong in the case select below. im using select into, as i ultimatly need to load a ref cursor for use with crystal reports.
thanks
james
ps if anyone is london based, and would like to spend a day or two teaching me how to be a bit better at PL/SQL (can aford to pay a little bit) please get in touch!!
SELECT
Case (select kind_code from event where
event.event_id = event.container_event_id)
when 1094006
then promo_name
end
into result
FROM promo, promo_plan , event_promotion
WHERE promo.promo_id = promo_plan.promo_id
AND promo_plan.promo_plan_id = event_promotion.promo_plan_id
AND event_promotion.detail_id = '33532282'
when blah then 'blah';Hello
AH i see what you are driveing at, yes i am just using case slect to determin which >routine to run, as the name is stored in a diferent location depending on the event kind >code. are are you saying i need multiple selects within the case statment? one for each >type of kind code?Well it depends really. If the select
select kind_code from event where
event.event_id = event.container_event_idIs going to return more than one row for any given run, you're going to need to take a bit of a different approach. Is it the case that this query will return more than one row which would mean that you want value X and value Y for each row?
Using the test data and everything from before:
SQL> CREATE OR REPLACE PROCEDURE p_GetStuff(ac_Result OUT sys_refcursor)
2 IS
3
4 BEGIN
5 /*
6 This uses a cartesian product i.e. repeat every row in
7 dt_test_data against every row in dt_test_event
8 */
9 OPEN Ac_Result FOR
10 SELECT
11 CASE dt_test_event.kind_code
12 WHEN 1 THEN
13 dt_test_data.object_name
14 WHEN 2 THEN
15 dt_test_data.object_type
16 END
17 FROM
18 dt_test_data,
19 dt_test_event;
20
21 END;
22 /
Procedure created.
SQL> var x refcursor
SQL> exec p_getstuff(:x)
PL/SQL procedure successfully completed.
SQL> print x
CASEDT_TEST_EVENT.KIND_CODEWHEN1THENDT_TEST_DATA.OBJECT_NAMEWHEN2THENDT_TEST_DAT
ABC
ABC4
AD1
AD2
ADHOC_CONTACT_LOG
AK_CD_CLAIM_VALIDATION_SOURCE
AK_CD_CLAIM_VALIDATION_TYPE
AK_CLAIM_ACTION_ROWSOURCE
APPROVAL_LIST_MEM_IE
APPROVE_GRP_HIST_IE
10 rows selected.
SQL> insert into dt_test_event values(2);
1 row created.
SQL> exec p_getstuff(:x)
PL/SQL procedure successfully completed.
SQL> print x
CASEDT_TEST_EVENT.KIND_CODEWHEN1THENDT_TEST_DATA.OBJECT_NAMEWHEN2THENDT_TEST_DAT
ABC
ABC4
AD1
AD2
ADHOC_CONTACT_LOG
AK_CD_CLAIM_VALIDATION_SOURCE
AK_CD_CLAIM_VALIDATION_TYPE
AK_CLAIM_ACTION_ROWSOURCE
APPROVAL_LIST_MEM_IE
APPROVE_GRP_HIST_IE
TABLE
CASEDT_TEST_EVENT.KIND_CODEWHEN1THENDT_TEST_DATA.OBJECT_NAMEWHEN2THENDT_TEST_DAT
TABLE
TABLE
TABLE
TABLE
INDEX
INDEX
INDEX
INDEX
INDEX
20 rows selected.Or an alternative to that would be, if you have a fixed number of event ids and they relate to a fixed number of attributes you could use something like:
CREATE OR REPLACE PROCEDURE p_GetStuff3(ac_Result OUT sys_refcursor)
IS
BEGIN
The SUBSTR
is just there to make sure the data fit on screen, my SQL*Plus
is a bit weird!
OPEN Ac_Result FOR
SELECT
SUBSTR(MAX(DECODE(dt_test_event.kind_code,1,dt_test_data.object_name,NULL)),1,30) attribute_1,
SUBSTR(MAX(DECODE(dt_test_event.kind_code,2,dt_test_data.object_type,NULL)),1,30) attribute_2
FROM
dt_test_data,
dt_test_event
GROUP BY
object_name;
END;
SQL> delete from dt_test_event where kind_code=2;
1 row deleted.
SQL> exec p_getstuff3(:x)
PL/SQL procedure successfully completed.
SQL> print x
ATTRIBUTE_1 ATTRIBUTE_2
ABC
ABC4
AD1
AD2
ADHOC_CONTACT_LOG
AK_CD_CLAIM_VALIDATION_SOURCE
AK_CD_CLAIM_VALIDATION_TYPE
AK_CLAIM_ACTION_ROWSOURCE
APPROVAL_LIST_MEM_IE
APPROVE_GRP_HIST_IE
10 rows selected.
SQL> insert into dt_test_event values(2);
1 row created.
SQL> exec p_getstuff3(:x)
PL/SQL procedure successfully completed.
SQL> print x
ATTRIBUTE_1 ATTRIBUTE_2
ABC TABLE
ABC4 TABLE
AD1 TABLE
AD2 TABLE
ADHOC_CONTACT_LOG TABLE
AK_CD_CLAIM_VALIDATION_SOURCE INDEX
AK_CD_CLAIM_VALIDATION_TYPE INDEX
AK_CLAIM_ACTION_ROWSOURCE INDEX
APPROVAL_LIST_MEM_IE INDEX
APPROVE_GRP_HIST_IE INDEX
10 rows selected.Message was edited by:
david_tyler
Oops, copy + pasted the wrong comments for the 2nd proc. -
Problem with SELECT INTO Query
Why am I always getting 0 for returnvalue in the following query?
create or replace
PACKAGE BODY MyPKG AS
PROCEDURE SelectCount
returnvalue OUT INTEGER
AS
BEGIN
select COUNT(*) from MyTable into returnvalue;
IF( SQL%ROWCOUNT >= 1 )
THEN
returnvalue := 1;
ELSE
returnvalue := 0;
END IF;
dbms_output.put_line('returnvalue: ' || returnvalue);
END SelectCount;
END MyPKG ;Hi,
When you use an aggregate function, such as COUNT, without a GROUP BY clause, then the query is guaranteed to return exactly 1 row, regadless of whether there are any rows in the table or not.
Perhaps you meant:
create or replace
PACKAGE BODY MyPKG AS
PROCEDURE SelectCount
returnvalue OUT INTEGER
AS
BEGIN
select COUNT(*) from MyTable into returnvalue;
dbms_output.put_line('returnvalue: ' || returnvalue);
END SelectCount;
END MyPKG ;
that is, simply lose the IF block. -
Hi there,
I would just like to know if it would be possible to pass a Select statement to forms_ddl? Since I need to use a variable in the 'From' clause, I was wondering if forms_ddl could be used?
thnxIf you needed the answer that urgently you should have just tried it for yourself. Then you would have discovered that:
(1) we can put a SELECT statement in a FORMS_DDL call and have it execute successfully;
(2) that's useless to us because, as Steve points out, FORMS_DDL is a procedure and can't return any values.
So you would have had your answer quicker and got the warm inner glow that comes from figuring something out for yourself.
Cheers, APC -
Select Into statement in db function - query from granted schema table
problem with "select into" in db function in 10.2
There are two schemas. 'mdbdev' is the master database and 'devusr' is granted SELECT table access to execute queries in mdbdev schema.
with devusr, in SQL, I'm able to execute the following query
select wm_concat(strConcatedCountryList)
from (select country_name as strConcatedCountryList from mdbdev.country_master mdbcm
where mdbcm.country_ship_status = <param?>
order by country_name)
but when I use the same query in function/procedure with "select into", the compilation failed with error *"table or view does not exist"*
FUNCTION GETCOUNTRYLISTTOSHIP (SHIP_STATUS IN NUMBER)
RETURN VARCHAR2
IS
var2CountryList VARCHAR2(1000);
BEGIN
select wm_concat(strConcatedCountryList) INTO var2CountryList
from (select country_name as strConcatedCountryList from mdbdev.country_master mdbcm
where mdbcm.country_ship_status = <value of SHIP_STATUS>
order by country_name);
return var2CountryList;
END;
Please advise/help/hint :)David, Justine, Thank you. The facts from this forum post helped a lot to get the solution.
The query helped a lot (select * from all_tab_privs_recd where owner = 'MDBDEV' and table_name = 'COUNTRY_MASTER").
there was a grant using ???(donno wht DBA said) and no direct SELECT grant on that country_master to "devusr". grant command executed. Now, it works :) -
hi all
i want to write a select statment in a procedure with out into statement ..
is it possilbe if yes how can i do this.
if its not possible then if we have to Return a number of rows from procedure then how can i do this..
thanks in advanceUser1728 wrote:
actual i want to return a datatable type data from procedureWhat does "datatable type" mean? "Datatable" is not a type in PL/SQL, so I assume that it has some meaning in your client programming language. What Oracle data type are you trying to return?
My guess would be that you are trying to return a REF CURSOR so that you want something like
SQL> create procedure return_rc( p_rc OUT sys_refcursor )
2 as
3 begin
4 open p_rc for select * from emp;
5 end;
6 /
Procedure created.
SQL> variable rc ref cursor;
Usage: VAR[IABLE] [ <variable> [ NUMBER | CHAR | CHAR (n [CHAR|BYTE]) |
VARCHAR2 (n [CHAR|BYTE]) | NCHAR | NCHAR (n) |
NVARCHAR2 (n) | CLOB | NCLOB | REFCURSOR |
BINARY_FLOAT | BINARY_DOUBLE ] ]
SQL> variable rc refcursor;
SQL> exec return_rc( :rc );
PL/SQL procedure successfully completed.
SQL> print rc
EMPNO ENAME JOB MGR HIREDATE SAL COMM
DEPTNO
7369 SMITH CLERK 7902 17-DEC-80 800
20
7499 ALLEN SALESMAN 7698 20-FEB-81 1600 300
30
7521 WARD SALESMAN 7698 22-FEB-81 1250 500
30
EMPNO ENAME JOB MGR HIREDATE SAL COMM
DEPTNO
7566 JONES MANAGER 7839 02-APR-81 2975
20
7654 MARTIN SALESMAN 7698 28-SEP-81 1250 1400
30
<<more data snipped>>Justin -
Should a user be created with Select / Read authorizat into GRC database
Hi,
Project team wants the access to the GRC 5.3 database of non production system. The access should be with only read/select authorization on few tables.
So would you please suggest
1 : Should the access to the database be given with select authorization ?
2 : If it is recommended then how to create such user id in database with only read/select authorization.
2 : Or is there any other way so that the project team can get the required data through the GRC application itself.
Kindly guide us.
Thanks & Regards
Girish GarjeHi,
Are you talking to provide access at DB level?
You should not do so.
For starters you could be in violation of the license (if you adquired Oracle from SAP) see note 581312 for more information
Probably there is a way of getting the required information from SAP itself, but probably this is not the correct forum to ask that question. -
Converting MS-Access select * into... to run in Oracle
I have this stored procedure in MS Access:
create procedure foo as
begin
if exists(select name from sysobjects where name='cif_retail)
drop table 'cif_retail'
select * into cif_retail from cif where cstresf=1
end
The above stored procedure checks if table cif_retail exists and if it exists it drops it and then it creates a new table cif_retail with data from cif with the condition cstresf=1.
How can I do the above in Oracle SQL? I tried the following but it comlains about the drop command, and when i remove it, it complains about the create table command too. Please help:
create or replace procedure foo as
begin
drop table w;
CREATE TABLE w AS SELECT * FROM x;
end;
Thanks,
TheodoraYou can Also Use
FORMS_DLL
Example
PROCEDURE Create_N_Column_Number_Table (n NUMBER) IS
my_stmt VARCHAR2(2000);
BEGIN
my_stmt := 'create table tmp(COL1 NUMBER';
FOR I in 2..N LOOP
my_stmt := my_stmt||',COL'||TO_CHAR(i)||' NUMBER';
END LOOP;
my_stmt := my_stmt||')';
** Now, create the table...
Forms_DDL(my_stmt);
IF NOT Form_Success THEN
Message ('Table Creation Failed');
ELSE
Message ('Table Created');
END IF;
END; -
what is the difference b/w
Select
Endselect
and select into table....
Akshitha..Hi,
When ever u want to append data into the workarea then use select ... endselect. When u r appending data into the internal table then use select. Also when u use select single then also use only select.
Eg: Using only Select
data : begin of itab occurs 0,
lifnr like lfa1-lifnr,
end of itab.
select single lifnr from lfa1 into itab.
data itab like lfa1 occurs 0 with header line.
select * from lfa1 into table itab.
Eg: Using Select .. endselect.
data : itab like lfa1 occurs 0,
wa like lfa1.
select * from lfa1 into wa.
append wa to itab.
endselect.
Regards -
Problem with "SELECT...FOR UPDATE OF..." and "POST command" combination
Problem in committing transactions in Multiple Forms (Oracle Forms) with POST built-in command:
Consider that the following statements are written in WHEN-WINDOW-CLOSED trigger of a called form.
Statements in called form (Form name: FORM_CHILD):
go_block('display_block') ;
do_key('execute_query') ;
-- Data from table_b will be populated in this block, based on the value of COLUMN_1 obtained
-- from TABLE_A.
-- Example: If the value of COLUMN_1 is 10, then all the matching records from TABLE_B, which
-- are inserted with value 10 in TABLE_B.COLUMN_1 will be fetched and shown here.
if user_choice = 'YES' then
commit ;
else
rollback ;
end if ;
Statements in calling forms:
There are two calling forms having following statements and it is going to call the above said called form.
CALLING FORM 1
Statements in KEY-COMMIT trigger:
post;
call_form(form_child, no_activate) ;
Statements in ON-INSERT trigger:
select column_1
from table_a
for update of column_1
where column_2 = 'X' ;
update table_a
set column_1 = column_1 + 1
where column_2 = 'X' ;
insert into table_b ...;
insert into table_b ...; Statements in KEY-COMMIT trigger:
post;
call_form(form_child, no_activate) ;
CALLING FORM 2:
Statements in ON-INSERT trigger:
select column_1
from table_a
for update of column_1
where column_2 = 'X' ;
update table_a
set column_1 = column_1 + 1
where column_2 = 'X' ;
insert into table_b ...;
insert into table_b ...;
insert into table_b ...;
Our understanding:
Assume that both the forms are running from two different machines/instances, issuing commit at the same time. In this case, forms will start executing the statements written in ON-INSERT trigger, the moment POST command is executed. Though the commit is issued at the same time, according to oracle, only one of the request will be taken for processing first. Assume that calling form 1 is getting processed first.
So, it fetches the value available in COLUMN_1 of TABLE_A and locks the row from further select, update, etc. as SELECT...FOR UPDATE command is used (note that NOWAIT is not given, hence the lock will be released only when COMMIT or ROLLBACK happens) and proceed executing further INSERT statements. Because of the lock provided by the SELECT...FOR UPDATE command, the statements in calling form 2 will wait for the resource.
After executing the INSERT statements, the FORM_CHILD is called. The rows inserted in to TABLE_A will be queried and shown. The database changes will be committed when user closes the window (as COMMIT is issued in its WHEN-WINDOW-CLOSED trigger). Then the SELECT...FOR UPDATE lock will be released and calling form 2's statements will be executed.
Actual happenings or Mis-behavior:
Calling form 2 starts executing INSERT statements instead of waiting for SELECT...FOR UPDATE lock. Also, the value selected from TABLE_A.COLUMN_1 is same in both the calling forms, which is wrong.
The rows inserted into TABLE_B are having similar COLUMN_1 values in calling form 2 and they are fetched and shown in the called form FORM_CHILD.
Note that in calling form 2 also POST only is issued, but the changes posted there are accessible in calling form 1 also, which is wrong.
Kindly suggest us as to how to fix above problem. It will be much use, if you can send us the information regarding the behavior of Oracle Forms POST built-in also.
Our mail ID: [email protected]
Thanks a lot in advance.You have several problems:
1. On-Insert will ONLY run if you have created a new record in a base-table block. If you haven't done that, then the POST command will not cause it to run.
2. Select for update without a "no wait" will lock records for the first form, but when the second form tries this, it will hit the ORA-00054 exception, and will NOT wait. The only way you could make it wait is to issue an UPDATE sql command, which is not such a good way to go.
All POST does is issues SQL insert or update commands for any changes the user has made to records in a form's base-table blocks, without following with a Commit command.
Also understand that Commit is the same as Commit_Form, and Rollback is the same as Clear_Form. You should read up on these in the Forms help topics. -
Problem with SUBMIT report [ WITH SELECTION-TABLE ] or [ IN range ]
Hello Everybody,
I am trying to call transaction F.80 for mass reversal of FI documents by using SUBMIT sentence and its parameters like this:
LOOP AT i_zfi013 INTO wa_zfi013.
PERFORM llena_params USING 'BR_BELNR' 'S' 'I' 'EQ' wa_zfi013-num_doc ''.
range_line-sign = 'I'.
range_line-option = 'EQ'.
range_line-low = wa_zfi013-num_doc.
APPEND range_line TO range_tab.
endloop.
Line: -
SUBMIT sapf080
WITH br_bukrs-low = p_bukrs
WITH SELECTION-TABLE it_params [ same problem with - WITH BR_BELNR IN range_tab]
WITH br_gjahr-low = p_an1
WITH stogrd = '05'
WITH testlauf = ''
AND RETURN.
My problem is that when the report is executed the BR_BELNR only delete one document of the all the inputs in the selection criteria from the loop. if I add the statement [ VIA SELECTION-SCREEN] in the SUBMIT if open the multiple selection criteria in the screen I can check that all the documents are set in it from the ABAP code in the loop from it I just need to push F8 to copy them and run the program processing all the documents normally .
Can some one help me with this? is there a way to execute the transaction BY the SUBMIT with the multiple selection criteria for the Document Number working well?
Thank for you time and help.This is my code:
TYPES: BEGIN OF T_ZFI013,
BUKRS TYPE BUKRS,
GJAHR TYPE GJAHR,
MONAT TYPE MONAT,
ANLN1 TYPE ANLN1,
ANLN2 TYPE ANLN2,
NUM_DOC TYPE BELNR_D,
DATE TYPE DATUM,
TIME TYPE UZEIT,
USER TYPE SYUNAME,
END OF T_ZFI013.
DATA: I_ZFI013 TYPE STANDARD TABLE OF T_ZFI013,
WA_ZFI013 TYPE T_ZFI013,
DATA: br_belnr TYPE BELNR_D,
rspar_tab TYPE TABLE OF rsparams,
rspar_line LIKE LINE OF rspar_tab,
range_tab LIKE RANGE OF br_belnr,
range_line LIKE LINE OF range_tab."range_tab.
LOOP AT i_zfi013 INTO wa_zfi013.
range_line-sign = 'I'.
range_line-option = 'EQ'.
range_line-low = wa_zfi013-num_doc.
APPEND range_line TO range_tab.
ENDLOOP.
SUBMIT sapf080
WITH br_bukrs-low = p_bukrs
WITH br_belnr IN range_tab
WITH br_gjahr-low = p_an1
WITH stogrd = '05'
WITH testlauf = ''.
This is the RANGE_TAB table before submit:
1 I EQ 1001xxxxxx
2 I EQ 1002xxxxxx
3 I EQ 1003xxxxxx
4 I EQ 1004xxxxxx
5 I EQ 1005xxxxxx
6 I EQ 1006xxxxxx
7 I EQ 1007xxxxxx
8 I EQ 1008xxxxxx
I think this wont work for some reason so I will start to do this by a BDC.
Many thanks for your help. -
How can I fill a table of objects from cursor with select * bulk collect???
Hi All, I have a TYPE as OBJECT
create or replace type dept2_o as object (
deptno NUMBER(2),
dname VARCHAR2(14),
loc VARCHAR2(13));
I can fill a table of objects from cursor with out select * bulk collect...., row by row
declare
TYPE dept2_t IS TABLE of dept2_o;
dept_o_tab dept2_t:=dept2_t();
i integer;
begin
i:=0;
dept_o_tab.extend(20);
for rec in (select * from dept) loop
i:=i+1;
dept_o_tab(i):=dept2_o(
deptno => rec.deptno,
dname => rec.dname,
loc =>rec.loc
end loop;
for k IN 1..i loop
dbms_output.put_line(dept_o_tab(k).deptno||' '||dept_o_tab(k).dname||' '||dept_o_tab(k).loc);
end loop;
end;
RESULT
10 ACCOUNTING NEW YORK
20 RESEARCH DALLAS
30 SALES CHICAGO
40 OPERATIONS BOSTON
But I can't fill a table of objects from cursor with select * bulk collect construction ...
declare
TYPE dept2_t IS TABLE of dept2_o;
dept_o_tab dept2_t:=dept2_t();
begin
dept_o_tab.extend(20);
select * bulk collect into dept_o_tab from dept;
end;
RESULT
ORA-06550: line 6, column 39;
PL/SQL: ORA-00947: not enough values ....
How can I fill a table of objects from cursor with select * bulk collect???create or replace type dept_ot as object (
deptno NUMBER(2),
dname VARCHAR2(14),
loc VARCHAR2(13));
create table dept
(deptno number
,dname varchar2(14)
,loc varchar2(13)
insert into dept values (10, 'x', 'xx');
insert into dept values (20, 'y', 'yy');
insert into dept values (30, 'z', 'zz');
select dept_ot (deptno, dname, loc)
from dept
create type dept_nt is table of dept_ot
declare
l_depts dept_nt;
begin
select dept_ot (deptno, dname, loc)
bulk collect
into l_depts
from dept
for i in l_depts.first .. l_depts.last
loop
dbms_output.put_line (l_depts(i).deptno);
dbms_output.put_line (l_depts(i).dname);
dbms_output.put_line (l_depts(i).loc);
end loop;
end;
/
Maybe you are looking for
-
Our company recently moved to Office 365 which mean our on premise exchange server went away as well with the move. I am trying to configure my new sql server (OS-Windows Server 2012 R2, DBMS- SQL 2014 Std Edtion). After some searching I found this
-
Please I need some help with a table
Hi All I need some help with a table. My table needs to hold prices that the user can update. Also has a total of the column. my question is if the user adds in a new price how can i pick up the value they have just entered and then add it to the tot
-
CE 7.1 sp3 installation failed in step 1: CheckDBServer...Error
Hello, While trying to install CE the installation failed in Step 1. Following is the error dump: ===================================================== perl: executing the following command C:\usr\sap\A35\home\tools\osql -E -i checkDBServer_param.txt
-
Installation of oracle utilities CC&B and MDM
hi friends, could any body help me how to install oracle CC&B and meter data management softwares.my doubt is should we install cc&B and MDM in developer mechines and application and web server mechines both.How many servers are required for this. th
-
I have a Fuji X-Pro1 camera. I use Mac OSX Lion 10.7.5 I have Photoshop CS5. How do I open its RAW files?