Bind the Variable in a dynamic query
The procedure below uses a variable binding for the deptno and run it with a ref cursor The expected result is to display the ename from EMP for the deptno passed for the p_deptno parameter, but the procedure fails with an exception.
CREATE OR REPLACE PROCEDURE dynamic_query(p_deptno NUMBER) AS lv_deptno number(4); -- l_lookup_type VARCHAR2(30):='PBAMERICAS_CO'; lv_query VARCHAR2(15000) :=' SELECT ename,''Year'' from emp where deptno='|| p_deptno; lv_cursor SYS_REFCURSOR; lv_lookup VARCHAR2(20); lv_emp_rec emp%rowtype; lv_ename VARCHAR2(10); lv_year VARCHAR2(10); BEGIN dbms_output.put_line(lv_query); OPEN lv_cursor FOR lv_query USING p_deptno ; Loop FETCH lv_cursor INTO lv_ename,lv_year; dbms_output.put_line(lv_ename || ',' ||lv_year); EXIT WHEN lv_cursor%NOTFOUND; END LOOP; CLOSE lv_cursor; END dynamic_query;
SQL> exec dynamic_query(10); SELECT ename,'Year' from emp where deptno=10 BEGIN dynamic_query(10); END; * ERROR at line 1: ORA-01006: bind variable does not exist ORA-06512: at "APPS.DYNAMIC_QUERY", line 13 ORA-06512: at line 1
I can change the code slightly and change the where clause to work but wanted to know what am I did wrong which makes the procedure fails with the above code.
CREATE OR REPLACE PROCEDURE APPS.dynamic_query(p_deptno NUMBER) AS lv_deptno number(4); lv_query VARCHAR2(15000) :=' SELECT ename,''Year'' from emp ' ; lv_cursor SYS_REFCURSOR; lv_lookup VARCHAR2(20); lv_emp_rec emp%rowtype; lv_ename VARCHAR2(10); lv_year VARCHAR2(10); BEGIN IF p_deptno IS NOT NULL THEN lv_query := lv_query || ' Where deptno =' || TO_CHAR(p_deptno); END IF; dbms_output.put_line(lv_query); OPEN lv_cursor FOR lv_query ; Loop FETCH lv_cursor INTO lv_ename,lv_year; dbms_output.put_line(lv_ename || ',' ||lv_year); EXIT WHEN lv_cursor%NOTFOUND; END LOOP; CLOSE lv_cursor; END dynamic_query; /
PS: I use the table EMP for this example includes so not CREATE TABLE and INSERT.
The procedure below uses a variable binding
No, it isn't.
You're just concatenation of the value of p_deptno in the query, such as a literal.
It's using a variable binding:
lv_query VARCHAR2 (15000): = ' 'year', SELECT ename from emp where deptno =: 1';
Then, the variable may be correctly bound (by post) via the USING clause.
Tags: Database
Similar Questions
-
Bind the Variable Table name in the query of VO
I have a VO that must have its clause defined dynamically at run time. I have a string bind variable defined with a default value that is referenced in the query of the VO. However, JDeveloper allow me to leave the definition of the query of the view object when the from clause is a variable binding, even if the binding variable has the default value.
For example.
Select
« X »
Of
: TABLE
where
1 = 1
The variable binding TABLE is defined as a string with a default value of the 'double '. Did I miss something in the definition of the VO?
Thank you
Hello
I suggest you to dynamically set the query of the view object. This does not meet your requirements.
xxVo.setQuery ();
-
To bind the Variable as being of a literal string value
Oracle Database 10g Enterprise Edition Release 10.2.0.5.0 - Prod
PL/SQL Release 10.2.0.5.0 - Production
CORE Production 10.2.0.5.0
AMT for Linux: Version 10.2.0.5.0 - Production
NLSRTL Version 10.2.0.5.0 - Production
Hi there, thank in advance. I have a problem when you create a dynamic statement. The problem is in the binding variable': OLD. CUST_NAME'... my question is is there an escape character to treat the affair as a literal string variable?
{code}
v_str2: = "' client_name =" ' |' | ' || ': OLD. CUST_NAME';
EXECUTE IMMEDIATE 'create or replace trigger trg_.
|| SUBSTR (rec_cur.table_name, 1, 26)
|| "before insert or update or delete on.
|| rec_cur. Owner
|| '.'
|| rec_cur.table_name
|| '
declare
Start
If the UPDATE can
FIFAPPS.ibug.log_errors('||)
v_str2 | »
);
end if;
end;';
{code}
I want the output in a trigger something like this:
{code}
If the UPDATE can
FIFAPPS.ibug.log_errors (' client_name ='|: O LD.) CUST_NAME
);
{code}
Hello
What is the need of business that you are trying to address? Before writing any kind or trigger and especially before you dynamically create a lot of triggers, see if Oracle provides a better way to meet your needs, for example, audit.
If triggers are really justified, and you are looking for just an easy way to crank out a large number of almost identical triggers right now (not something that end users will do all the time), so I suggest SQL * Plus and the substitution variables. It will be easier to debug writing and debugging, because you won't have to you not so much worried about quotes and concatenation. For example, if all the triggers are identical except for the diagram, the table name and column name, you can write a simple script that can be used to create an unlimited number of triggers, like this:
-Trigger_Factory.sql - create trigger standard
DEFINE schema_name = & 1
DEFINE table_name = & 2
DEFINE column_name = & 3CREATE OR REPLACE TRIGGER trg_ & table_name
BEFORE ON INSERT or UPDATE or DELETE &... schema_name table_name
-' SEO NEW OLD NEW old' is the default, so do not say-REFERENCING NEW AS NEW OLD O
-In this way, you don't have to worry about the bad OLD spelling.
FOR EACH LINE
BEGIN
IF THE UPDATE CAN
fifapps. IBUG.log_errors (: OLD & column_name);
...Once you have this course of debugging, you can write another script that calls the script above:
@trigger_factory fifapps t t_column_key
@trigger_factory fifapps u colonne_1
@trigger_factory foo bar column_xyz
Alternatively, instead of manually create a script like the one above, write a query to do it for you:
SELECT '@trigger_factory'
owner
table_name
column_name
From all_tab_columns
WHERE THE...
-
the variable name of database query to SQL Server using the Oracle database link
Hi all
I have an ApEx 4.1 application running on x 64 (11.2.0.1) 11g on Windows Server 2008 x 64, and I have a few points of data integration with SQL (2005 and 2008) server that I need to create. I have configured the database with dg4odbc link and it works perfectly... I can run queries on the SQL Server database without any problem using the database link.
However, there is a scenario where the SQL Server database name is dynamic, and I need to generate on the fly in a PL/SQL block and then use it in a query dynamic SQL (all this in the ApEx). It of wherever I meet problems... when I asked the default database that is based on the ODBC connection and I don't have to specify the name of the database, no problem. But when I need access to one of the several other databases by default, I received the error "invalid table.
It works well:* (note that 'fv' is the name of my database link)
v_query1: = "select 'Release Date' from dbo." Schedules@FV where dbo. Annexes. "" SchedID "=: calendar";
EXECUTE IMMEDIATE v_query1 in rel_date using the grid.
I then take this rel_date variable, convert a varchar2 (rel_date_char), then use it as the name of the database in the following query...
_ It returns an error(error ORA-00903: invalid table name)
v_query2: = "select"PARTNO": rel_date_char.dbo.ProdDetails@fv where 'SchedID' =: calendar and"UnitID"=: unit"
and 'MasterKey' =: master and "ParentKey" =: parent';
EXECUTE IMMEDIATE v_query2 in part_number using planning, master, parent unit;
I also tried using all of the following conditions without result:
"select"PARTNO"of" | : rel_date_char | '.dbo. ProdDetails@fv where 'SchedID '...
"select"PARTNO"of" | rel_date_char | '.dbo. ProdDetails@fv where 'SchedID '...
"select"PARTNO"of" | @rel_date_char | '.dbo. ProdDetails@fv where 'SchedID '...
"select"PARTNO"in @rel_date_char.dbo.ProdDetails @fv where 'SchedID'..."
Is it possible to do it in PL/SQL?
Thanks for any help!
-Ian C.
Published by: 946532 on July 15, 2012 19:45Just did a test using passthrough:
SQL > set serveroutput on
SQL > declare
2 val varchar2 (100);
3 c whole;
4 whole nr;
5. start
c: 6 = dbms_hs_passthrough.open_cursor@FREETDS_DG4ODBC_EMGTW_11_2_0_3;
7 dbms_hs_passthrough.parse@FREETDS_DG4ODBC_EMGTW_11_2_0_3 (c, "select count (*) from EMP");
8 LOOP
9 nr: = DBMS_Hs_Passthrough.fetch_row@FREETDS_DG4ODBC_EMGTW_11_2_0_3 (c);
10 output when nr = 0;
11 dbms_hs_passthrough.get_value@FREETDS_DG4ODBC_EMGTW_11_2_0_3 (c, 1, val);
12 dbms_output.put_line (val);
13 end of loop;
14 dbms_hs_passthrough.close_cursor@FREETDS_DG4ODBC_EMGTW_11_2_0_3 (c);
15 end;
16.
24576PL/SQL procedure successfully completed.
SQL > declare
2 val varchar2 (100);
3 c whole;
4 whole nr;
5. start
c: 6 = dbms_hs_passthrough.open_cursor@FREETDS_DG4ODBC_EMGTW_11_2_0_3;
7 dbms_hs_passthrough.parse@FREETDS_DG4ODBC_EMGTW_11_2_0_3 (c, ' select count (*) from dbo.) EMP');
8 LOOP
9 nr: = DBMS_Hs_Passthrough.fetch_row@FREETDS_DG4ODBC_EMGTW_11_2_0_3 (c);
10 output when nr = 0;
11 dbms_hs_passthrough.get_value@FREETDS_DG4ODBC_EMGTW_11_2_0_3 (c, 1, val);
12 dbms_output.put_line (val);
13 end of loop;
14 dbms_hs_passthrough.close_cursor@FREETDS_DG4ODBC_EMGTW_11_2_0_3 (c);
15 end;
16.
24576PL/SQL procedure successfully completed.
So all 3 ways work for me.
Published by: kgronau on July 23, 2012 10:08
Now, using the variables to make the selection:
SQL > declare
2 val varchar2 (100);
3 c whole;
4 whole nr;
5 tabname varchar2 (20): = 'EMP ';
6 ownr varchar2 (20): = "dbo."
7 dbname varchar2 (20): = "door";
Start 8
c: 9 = dbms_hs_passthrough.open_cursor@FREETDS_DG4ODBC_EMGTW_11_2_0_3;
10 dbms_hs_passthrough.parse@FREETDS_DG4ODBC_EMGTW_11_2_0_3 (c, ' SELECT count (*) FROM ': dbname: '.) ' || ownr | '.'|| tabname | ") ;
11 LOOP
12 nr: = DBMS_Hs_Passthrough.fetch_row@FREETDS_DG4ODBC_EMGTW_11_2_0_3 (c);
13 when the exit nr = 0;
14 dbms_hs_passthrough.get_value@FREETDS_DG4ODBC_EMGTW_11_2_0_3 (c, 1, val);
15 dbms_output.put_line (val);
16 end loop;
17 dbms_hs_passthrough.close_cursor@FREETDS_DG4ODBC_EMGTW_11_2_0_3 (c);
18 end;
19.
24576PL/SQL procedure successfully completed.
=> instead of executing the statement using the "execute Immediate" we use the PASTHROUGH package to pass the statement to SQL Server.
Published by: kgronau on July 23, 2012 10:10
-
bind the variable column of v$ sqlarea
BANNER Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - 64bi PL/SQL Release 10.2.0.4.0 - Production CORE 10.2.0.4.0 Production TNS for HPUX: Version 10.2.0.4.0 - Production NLSRTL Version 10.2.0.4.0 - Production
select to_char(sql_fulltext), bind_data from v$sqlarea where sql_id = '5fwm73ndv5pjp';
I'm not horribly v$ sqlarea. but there were some questions about the application executes a query and getTO_CHAR(SQL_FULLTEXT) BIND_DATA select vgal.GAFS_DISPLAY_LINE_CD from view_gafs_account_line vgal where vgal.ACCOUNT_ID = :p1 and vgal.ACCOUNT_LINE_SEQ_CD = :p2 and vgal.ACCOUNT_TYPE_ID = :p3 and vgal.PROGRAM_SUMMARY_ID = :p4
no row is returned.
I find the query in v$ sqlarea but I would like to know what are bind variables, but this column is null.
This means that the query has been run with null for all bind variables?
or bind variables not seized for any reason are any?v$ sql_bind_capture I bind the value of the variable
SELECT a.sql_text, b.name, b.position, b.datatype_string, b.value_string FROM v$sql_bind_capture b, v$sqlarea a WHERE b.sql_id = 'dpf3w96us2797' AND b.sql_id = a.sql_id;
-
BIND THE VARIABLE INSIDE A LOOP
Hello
I have question about the sort of the values using Plsql... My requirement is to get values of N with the user and sorting in ascending or descending order. I tried the following query
DECLARE
Is of type TABLE numsort
NUMBER
INDEX OF DIRECTORY;
v_num numsort;
number of v_total;
number of v_no;
BEGIN
-get the number of values to sort
v_total: =: TotalNum;
dbms_output.put_line (v_total);
because me in 1.v_total
LOOP
v_no: =: none; -Read the values
v_num (i): = v_no;
dbms_output.put_line (v_num (i): 10;)
END LOOP;
END;
its code is not complete... sound to read the value in the table... Read itself does not
The problem is that the connection variable is not reset with each iteration. I am using Toad and he asked me to pass all the variable binding both... But I want to read the values in the table with each iteration. Is it possible in PLSQL... or is there another way to do this...
hope you are clear with the requirement... If any infomartion extra need please come bk...
Waiting for your replay
Thanks and greetings
RognardMaybe like this?
SQL> create or replace procedure test_proc (p_input varchar2, p_separator varchar2) is 2 v_input varchar2(32767):= p_input||p_separator; 3 begin 4 if p_input is not null then 5 while instr(v_input,p_separator) > 0 loop 6 dbms_output.put_line(substr(v_input,1,instr(v_input,p_separator)-1)); 7 v_input:=substr(v_input,instr(v_input,p_separator)+1); 8 end loop; 9 end if; 10 end; 11 / Procedure created. SQL> exec test_proc('10, 4, 6, 3',',') 10 4 6 3 PL/SQL procedure successfully completed. SQL> exec test_proc('',',') PL/SQL procedure successfully completed. SQL>
Nicolas.
-
to BIND the variable SUBSTITUTION
I have a code where I find dates START and end range for the past 3 years, the beginning Date must start on a Sunday and the end Date is at the end on Saturday using the weird system they have here:-)
the end usable VARIABLE must be in YYYYMMDD format as number, because that's how they set up Date here... can anything about...
So I thought to all the Dates, performing a combination of Variables of SUBSTITUTION AND LINKING, why I do like that it is because
I received an error when I used just the variables SUBSTITUTION (maximum 240 characters used on the START DATE of the year2, in)
switching to this, the error has disappeared), well that's what I thought he'll fix it.
But now, when I try to use and VARIABLE in SQL, I get an error that it cannot use BIND variables, so try to pass values to a SUBSTITUTION
afin_que this error disappears) - unless there is a better way?
If there is a better way to stay maybe everything inside SUBSTITUTION and don't imply any LINK, maybe it would be better, if you guys know a way around the 240 character error...
:-)
My variables are:
-find YEAR 1
SET LY_END_DATE_NUM = "TO_NUMBER (TO_CHAR (NEXT_DAY ((SYSDATE-7), 'SATURDAY'), 'YYYYMMDD'));
variable BIND_LY_END_DATE_N number;
run: BIND_LY_END_DATE_N: = & LY_END_DATE_NUM;
PRINT BIND_LY_END_DATE_N;
SET LY_START_DATE = ' TO_DATE (: BIND_LY_END_DATE_N, 'yyyy-mm-dd')-363;
SET LY_START_DATE_NUM = "TO_NUMBER (TO_CHAR (& LY_START_DATE, 'YYYYMMDD'));
variable BIND_LY_START_DATE_N number;
run: BIND_LY_START_DATE_N: = & LY_START_DATE_NUM;
PRINT BIND_LY_START_DATE_N;
-find YEAR 2
SET YRS2_END_DATE = ' TO_DATE (: BIND_LY_START_DATE_N, 'yyyy-mm-dd')-1;
SET YRS2_END_DATE_NUM = "TO_NUMBER (TO_CHAR (& YRS2_END_DATE, 'YYYYMMDD'));
variable BIND_YRS2_END_DATE_N number;
run: BIND_YRS2_END_DATE_N: = & YRS2_END_DATE_NUM;
PRINT BIND_YRS2_END_DATE_N;
SET YRS2_START_DATE = ' TO_DATE (: BIND_YRS2_END_DATE_N, 'yyyy-mm-dd')-363;
SET YRS2_START_DATE_NUM = "TO_NUMBER (TO_CHAR (& YRS2_START_DATE, 'YYYYMMDD'));
variable BIND_YRS2_START_DATE_N number;
run: BIND_YRS2_START_DATE_N: = & YRS2_START_DATE_NUM;
PRINT BIND_YRS2_START_DATE_N;
-find YEAR 3
SET YRS3_END_DATE = ' TO_DATE (: BIND_YRS2_START_DATE_N, 'yyyy-mm-dd')-1;
SET YRS3_END_DATE_NUM = "TO_NUMBER (TO_CHAR (& YRS3_END_DATE, 'YYYYMMDD'));
variable BIND_YRS3_END_DATE_N number;
run: BIND_YRS3_END_DATE_N: = & YRS3_END_DATE_NUM;
PRINT BIND_YRS3_END_DATE_N;
SET YRS3_START_DATE = ' TO_DATE (: BIND_YRS3_END_DATE_N, 'yyyy-mm-dd')-363;
SET YRS3_START_DATE_NUM = "TO_NUMBER (TO_CHAR (& YRS3_START_DATE, 'YYYYMMDD'));
variable BIND_YRS3_START_DATE_N number;
run: BIND_YRS3_START_DATE_N: = & YRS3_START_DATE_NUM;
PRINT BIND_YRS3_START_DATE_N;
Hello
Kodiak_Seattle wrote:
I have a code where I find dates START and end range for the past 3 years, the beginning Date must start on a Sunday and the end Date is at the end on Saturday using the weird system they have here:-)
the end usable VARIABLE must be in YYYYMMDD format as number, because that's how they set up Date here... can anything about...
So I thought to all the Dates, performing a combination of Variables of SUBSTITUTION AND LINKING, why I do like that it is because
I received an error when I used just the variables SUBSTITUTION (maximum 240 characters used on the START DATE of the year2, in)
switching to this, the error has disappeared), well that's what I thought he'll fix it.
But now, when I try to use & VARIABLE in SQL, I get an error that it cannot use BIND variables, so try to pass values to a SUBSTITUTION
afin_que this error disappears) - unless there is a better way?
If there is a better way to stay maybe everything inside SUBSTITUTION and don't imply any LINK, maybe it would be better, if you guys know a way around the 240 character error...
:-)
My variables are:
-find YEAR 1
SET LY_END_DATE_NUM = "TO_NUMBER (TO_CHAR (NEXT_DAY ((SYSDATE-7), 'SATURDAY'), 'YYYYMMDD'));
variable BIND_LY_END_DATE_N number;
run: BIND_LY_END_DATE_N: = & LY_END_DATE_NUM;
PRINT BIND_LY_END_DATE_N;
SET LY_START_DATE = ' TO_DATE (: BIND_LY_END_DATE_N, 'yyyy-mm-dd')-363;
SET LY_START_DATE_NUM = "TO_NUMBER (TO_CHAR (& LY_START_DATE, 'YYYYMMDD'));
variable BIND_LY_START_DATE_N number;
run: BIND_LY_START_DATE_N: = & LY_START_DATE_NUM;
PRINT BIND_LY_START_DATE_N;
-find YEAR 2
SET YRS2_END_DATE = ' TO_DATE (: BIND_LY_START_DATE_N, 'yyyy-mm-dd')-1;
SET YRS2_END_DATE_NUM = "TO_NUMBER (TO_CHAR (& YRS2_END_DATE, 'YYYYMMDD'));
variable BIND_YRS2_END_DATE_N number;
run: BIND_YRS2_END_DATE_N: = & YRS2_END_DATE_NUM;
PRINT BIND_YRS2_END_DATE_N;
SET YRS2_START_DATE = ' TO_DATE (: BIND_YRS2_END_DATE_N, 'yyyy-mm-dd')-363;
SET YRS2_START_DATE_NUM = "TO_NUMBER (TO_CHAR (& YRS2_START_DATE, 'YYYYMMDD'));
variable BIND_YRS2_START_DATE_N number;
run: BIND_YRS2_START_DATE_N: = & YRS2_START_DATE_NUM;
PRINT BIND_YRS2_START_DATE_N;
-find YEAR 3
SET YRS3_END_DATE = ' TO_DATE (: BIND_YRS2_START_DATE_N, 'yyyy-mm-dd')-1;
SET YRS3_END_DATE_NUM = "TO_NUMBER (TO_CHAR (& YRS3_END_DATE, 'YYYYMMDD'));
variable BIND_YRS3_END_DATE_N number;
run: BIND_YRS3_END_DATE_N: = & YRS3_END_DATE_NUM;
PRINT BIND_YRS3_END_DATE_N;
SET YRS3_START_DATE = ' TO_DATE (: BIND_YRS3_END_DATE_N, 'yyyy-mm-dd')-363;
SET YRS3_START_DATE_NUM = "TO_NUMBER (TO_CHAR (& YRS3_START_DATE, 'YYYYMMDD'));
variable BIND_YRS3_START_DATE_N number;
run: BIND_YRS3_START_DATE_N: = & YRS3_START_DATE_NUM;
PRINT BIND_YRS3_START_DATE_N;
Let me make sure I understand the problem.
One year, in this problem, is exactly 364 days.
You want the year that ended on the most recent Saturday (otherwise said, the year ending Saturday between 6 days ago and today) and two years ago.
You want the first date in each of those years and the last date each year, in the format YYYYMMDD.
Is this fair?
Here's a way to define variables of substitution (with names like year_1_start):
COLUMN y1_start new_value by year_1_start
COLUMN y1_end new_value by year_1_end
COLUMN y2_start new_value by year_2_start
COLUMN y2_end new_value by year_2_end
COLUMN y3_start new_value by year_3_start
COLUMN y3_end new_value by year_3_end
WITH got_y1e AS
(
SELECT NEXT_DAY (SYSDATE - 7 'SATURDAY') AS y1e
OF the double
)
SELECT TO_CHAR (y1e + 1 - (364 * 3), 'YYYYMMDD') AS y3_start
, TO_CHAR (y1e - (364 * 2), 'YYYYMMDD') AS y3_end
, TO_CHAR (y1e + 1 - (364 * 2), 'YYYYMMDD') AS y2_start
, TO_CHAR (y1e - 364, 'YYYYMMDD') AS y2_end
, TO_CHAR (y1e + 1-364, 'YYYYMMDD') AS y1_start
, TO_CHAR (y1e, 'YYYYMMDD') AS y1_end
OF got_y1e
;
If you prefer that bind variable, write an anonymous PL/SQL block and use the same logic to 6 variables.
-
Hi all
CREATE OR REPLACE PROCEDURE PRMADM_BATCH. UPDATE_PROC_LOG (p_SRC_SYS_ID VARCHAR,
p_APPL_MOD_NM VARCHAR, p_INPT_OBJ_NM VARCHAR, VARCHAR, p_OUTPT_OBJ_NM p_ERR_ID
VARCHAR, p_ERR_DESC VARCHAR)
AS
number of p_OUTPT_ROW_CNT;
number of p_INPT_ROW_CNT;
p_OUTPT_SQL VARCHAR2 (4000);
p_INPT_SQL VARCHAR2 (4000);
number of p_ERR_ID_CHK;
BEGIN
IF p_ERR_ID = 0 THEN - success
p_OUTPT_ROW_CNT: = 0;
p_INPT_ROW_CNT: = 0;
p_OUTPT_SQL: = NULL;
p_INPT_SQL: = NULL;
p_ERR_ID_CHK: = 0;
DBMS_OUTPUT. PUT_LINE ('SRC_SYS_ID =' | p_SRC_SYS_ID);
p_OUTPT_SQL: = 'SELECT COUNT (*) FROM "| p_OUTPT_OBJ_NM | ' WHERE
SRC_SYS_ID =: a ';
p_INPT_SQL: = 'SELECT COUNT (*) FROM "| p_INPT_OBJ_NM | ' WHERE
SRC_SYS_ID =: b';
DBMS_OUTPUT. Put_line (p_OUTPT_SQL);
DBMS_OUTPUT. Put_line (p_INPT_SQL);
EXECUTE IMMEDIATE p_OUTPT_SQL IN p_OUTPT_ROW_CNT IN USING p_SRC_SYS_ID;
EXECUTE IMMEDIATE p_INPT_SQL IN p_INPT_ROW_CNT IN USING p_SRC_SYS_ID;
Else - failure
p_OUTPT_ROW_CNT: = - 1;
p_INPT_ROW_CNT: = - 1;
p_OUTPT_SQL: = NULL;
p_INPT_SQL: = NULL;
p_ERR_ID_CHK: = - 1;
SELECT COUNT (*) IN the p_ERR_ID_CHK OF PRMADM. ERR WHERE ERR_ID =
p_ERR_ID;
IF p_ERR_ID_CHK = 0 THEN
INSERT INTO PRMADM. ERR (ERR_ID, ERR_DESC) VALUES (p_ERR_ID,
p_ERR_DESC);
COMMIT;
END IF;
END IF;
UPDATE PRMADM. PROC_LOG
SET PROC_END_DY_DT = SYSDATE,
INPT_ROW_CNT = p_INPT_ROW_CNT,
OUTPT_ROW_CNT = p_OUTPT_ROW_CNT,
ERR_ID = p_ERR_ID
WHERE APPL_MOD_NM = p_APPL_MOD_NM
AND PROC_END_DY_DT IS NULL
AND OUTPT_OBJ_NM = p_OUTPT_OBJ_NM
AND INPT_OBJ_NM = p_INPT_OBJ_NM
AND SRC_SYS_ID = p_SRC_SYS_ID;
COMMIT;
END UPDATE_PROC_LOG;
/
The proc above is running well and gives the result below
SRC_SYS_ID = 1030
SELECT COUNT (*) IN THE PRMADM. PGM WHERE
SRC_SYS_ID =: a
SELECT COUNT (*) IN THE PRMADM. INPT_PGM WHERE
SRC_SYS_ID =: b
My question is where can I enter the value for the variable bind a and b...
I want to put two to 1030
Thanks in advanceNdiaye (ndiaye) wrote:
p_SRC_SYS_ID (input in my proc parameter) takes the value of 1030 and I want that the connection variable: an and: b take the same value...But they take this value...
EXECUTE IMMEDIATE p_OUTPT_SQL IN p_OUTPT_ROW_CNT IN USING p_SRC_SYS_ID;
EXECUTE IMMEDIATE p_INPT_SQL IN p_INPT_ROW_CNT IN USING p_SRC_SYS_ID;The 'USE' of the declaration part links the value to bind variables in the SQL statement.
Where is the problem?
-
Access to bind the variables of class EntityImpl
Hello
I use jdeveloper 11.1.1.7.0
I have an Obj to the entity and a view Obj, in the a view Obj I defined some variables bind to the WhereClause,
EntityImpl of EO class, I need to access these variable bind, how can I do for this case?
Habib
Concerning
There are several options:
1. download VO in your EOImpl class (as I have already suggested). It is the best way to recover your var bind, but will present a dependence between OT and VO (and usually EO should not depend on a VO, but of course it depends on concrete use cases). So, if you know that there is only one THAT VO editable based on this OS, I'd go with this approach.
2. put your var to link to the http session and then access this variable with: ADFContext.getCurrent () .getSessionScope (). It is not difficult to implement, but this isn't a very good approach because it would break the MVC pattern (you should not reference something layer in the layer of view model).
3. place your var bind to structure UserData. It's probably "appropriately", but it is also the most difficult to implement correctly, see for example Andrejus Baranovskis Blog: Solution for sharing the global user data in British Colombia ADF
Dario
-
How to assign the variable element of dynamic page?
Hello
I am facing following problem:
I need assign a variable with a value of a page element - for example apex_application.g_f04 (i).
My problem is, that f04 maybe everthing between f04 and f52 (or whatelse was number of page elements?).
I've tried several things, among others, something like this:
v_test: = apex_application.g_f | x | (i) / * where x can be another variable * /.
or
v_stat: = 'SELECT apex_application.g_f ' | x | "(i) the double '.
EXECUTE IMMEDIATE v_stat INTO v_test
but I do not understand so far...
Any ideas?
Published by: DFiles on 06.01.2011 13:57apex_application.g_f0x variable package are associative arrays and are not accessible to the dynamic SQL. You must use the dynamic PL/SQL:
declare i pls_integer; x pls_integer; v varchar2(32767); begin /* However you get values for x and i... */ i := 1; x := 4; execute immediate 'begin :1 := apex_application.g_f' || to_char(x, 'fm09') || '(:2); end;' using out v, i; return v; end;
-
How to pass the number object type to bind the variable in a select statement
Hello
I have a scenario like,
UI, we store the values in the type of object, and this object type must be spent in a select query to retrieve the data accordingly.
Is it possible to do so.
If this isn't the case, please let me know how to take the values of object type and pass to the select query.
Kind regards
I found it,
Object_name ('parameters1', 'parameter2');
-
Hello
I wonder what trivial mistake, am I doing here? Qsure uite that the syntax is correct and it has worked before in the developer doesn't have it?
variable bind_variable number execute :bind_variable := 1; print bind_variable PL/SQL procedure successfully completed. BIND_VARIABLE ------
I found regarding reports bug, but for versions a lot older.
Win 7
Version 4.1.0.19
Java 1.8.0_31
Looks like a bug in 4.1 based on the thread below and the comments in the blog below:
Printing in SQL Developer 4.1 output
http://www.thatjeffsmith.com/archive/2015/05/SQL-Developer-version-4-1-feature-recap/
Works very well in 4.0.3.16
See you soon
AJ
-
How to add dynamic items based on the results of a dynamic query?
Hi all
I'm quite new to ofa, here's my problem.
I have a table 'interventions', each intervention have actions stored in the table "actions".
I want to show the actions of an intervention in a list, based on the id of the intervention. the response ID value is dynamic, so does not know the number of shares that you want to display in the list.
Can someone tell me the steps to create a region that has dynamic elements to display names of action?
Thank you
Kind regards
Afaf
Afaf,.
Take a look on the link below to see how to create dynamic VO:
You could add messageStyled text like the code below:
OAMessageStyledTextBean newMessageBean = (OAMessageStyledTextBean) createWebBean (pageContext, MESSAGE_STYLED_TEXT_BEAN, null,"
" "); Links to dynamically create elements below:
Add columns to the table advanced in OA Framework Programatically by Extension
Let us know if you get any errors when creating.
See you soon
AJ
-
What is the problem with this dynamic query? help
with the following code, I get the correct answer.
I just want to know maxempno current (and care for the 3rd, 4th tank only)
declare
Temp varchar2 (2);
Start
Select substr (A1.empno, 3, 2) in the emp A1 temp where A1.empno = (select (max (A2.empno) of emp A2) and rownum = 1;)
HTP.p ('temp' is |) Temp)
end;
Temp is 34
=====================================
Now I need to make a call to the procedure and pass the name of a table and column
P_CHECK_MAX
('emp' = > p_table,)
('empno' = > p_column)
create or replace procedure 'P_CHECK_MAX '.
(p_table in VARCHAR2,
p_column in varchar2)
is
Temp varcahr2 (2);
d_select varchar2 (500);
Start
d_select: ='SELECT substr (A1.'| p_column | 3: 2) IN ' | "temp" | 'FROM ' | p_table | "A1 WHERE A1.' | p_column | "= (SELECT max (A2.' | p_column |')) OF ' | p_table | ("A2) AND rownum = 1';
immediately run d_select;
end;
I'm getting ORA - 00905 missing keywords. Can you help me what is the missing word here? I am stomped for hours on it.
Published by: wanwan63 on September 29, 2009 06:23
Sorry I reverse the setting in the call. must be p_table = > 'emp', p_column = > 'empno '.P_CHECK_MAX
("emp"-online p_table,
'empno'-online p_column)It must be
p_check_max(p_table=>'emp', p_column=> 'empno)
d_select: ='SELECT substr (A1.'| p_column | 3: 2) IN ' | "temp" | 'FROM ' | p_table | "A1 WHERE A1.' | p_column | "= (SELECT max (A2.' | p_column |')) OF ' | p_table | ("A2) AND rownum = 1';
immediately run d_select;IN is not part of the SQL syntax. Its syntax PL. If you can not use dynamic SQL. It should be like this
d_select:='SELECT substr(A1.'||p_column|| ',3,2) FROM ' || p_table || ' A1 WHERE A1.' ||p_column ||'= (SELECT max(A2.' ||p_column||') FROM ' || p_table||' A2) AND rownum=1'; execute immediate d_select into temp;
-
Bind the Variable for: 'No. Inline Validation errors displayed' existing?
Hello
Is there a variable corresponding to 'No Inline Validation errors displayed' APEX?
I would test this variable combined with others for complex validation scenarios.
Kind regards
ChristianChristian:
You can use 'wwv_flow.g_inline_validation_error_cnt' to determine the number of online validation errors
CITY
Maybe you are looking for
-
OfficeJet 6700 Premium: Officejet 6700 the computer scanner has stopped working
My scan of the computer stopped working with my PC HP 10 Windows, I ran doctor scan it says driver error and can not solve the problem, but I seem to have the latest version of the driver and the fax does not either, so only print work. All is connec
-
Hi guys,. 2 weeks ago, I bought my satellite M40 129 withHarman/kardon. I had 2 problems. 1) SOUND through the HEADSETSongs (CD or mp3s) I'm listening on my 3 year old officethrough good quality well real, true stereo headphones. On my laptop...-If I
-
HP 14 laptop: cover does nothing
Hello Recently closing the lid will not be introduced Hibernate, standby or shutdown. I chnaged the settings in the power for the correct settings options and whenever I close the lid, nothing happens. If I click on Hibernate in the startmenu PC Hibe
-
HP compaq 610 model wh247ut # wireless n issue
Hi, I've recently upgraded my home network wireless n and may not know what the internal card would work with this laptop I have a intel 4965agn card but when I put it in it says device not supported is anyway to get this card to work in this laptop
-
Note: Please go down to the replica of dngnuyen a link for the latest driver. The one currently on the site for the U400 Lenovo driver is outdated. I didn't score it as a solution, as I still have to test carefully and still believe that he can do be