Select name into :Name_supp from py_emp where id=:id_supp; in (Tablour) ?
Hi i want to use this query in Tablour Style form
Select name into :Name_supp from py_emp where id=:id_supp;
Exception when no_data_found then null;
Now i need that its will generate all name when id=:id_supp
When i used this Trigger in button its not update all text box its update only current text box
Regards
Shahzaib ismail
Shahzaib ismail,
When i used this Trigger in button its not update all text box its update only current text box
From this i think that its a multi record block, and after fetching it, you changed the id_supp in the master block. So in order to that change, you want to set the name of that supplier in the detail block.
For this you can,
1) Create a function that returns the name using the select statement you wrote, and call that function in the Formula property. Also change the Calculation Mode to Formula.
2) Assign the name in to a text item in master block, which is hidden, and assign that item's name in the Synchronize with Item property of the detail item.
3) Loop through the detail block, and assign the name value.
Regards,
Manu.
If this answer is helpful or correct, please mark it. Thanks.
Similar Messages
-
Hi,
I've been given a java.util.Collection of data (actually composite alternative keys) to query Oracle. so I need to build dynamic SQL query:
SELECT ... FROM table1
WHERE (ak_col1 = ... AND ak_col2 = ...)
OR (ak_col1 = ... AND ak_col2 = ...)
OR (ak_col1 = ... AND ak_col2 = ...)
... // till the last element in the Collection
The size of Collection is between 100 to 500. When I construct this query as String and passed to JDBC Statment. It can take a few seconds to run.
I wonder if any one know a better way to imporve the performance?
TIA
chuckIt might be perform better and it would certainly maintain performance whether 100 or 500 entries existed if you could transform the sql logic to use the between keyword. No idea if the data would support this, and you would have to preprocess the Collection (which may negate any overall performance benefit). It may not completely eliminate the OR condition, but it could minimize the count. Something like (This solution is totally data dependent.):
SELECT ... FROM table1
WHERE (ak_col1 between ... and .... and ak_col2 between ... and ...)
or (ak_col1 between ... and .... and ak_col2 between ... and ...)================
It might be easier, and is not as data dependent to try using an inlist. Perhaps something like this:
SELECT ... FROM table1
WHERE (ak_col1 in (...,...,...,...) and ak_col2 in (...,...,...,...) )
or (ak_col1 in (...,...,...,...) and ak_col2 in (...,...,...,...))Once again, you would have to preprocess the Collection to build this SQL which could negate any overall performance benefit. And you would be minimizing the but not eliminating the OR conditions. This is not as as good a solution from a performance perspective as using the between.
I kind of like the previous posters idea of looking at the table structures and modifying them to eliminate the need for multiple OR conditions. As stated, that's not always possible.
In most cases, when Oracle is provided this type of SQL (500 OR's, 1000 AND's) the optimizer simply gives up and scans the table. You are correct in looking at alternative strategies unless this is a very small table and scanning the table is a reasonable thing to do.
There are probably a handful of other possible strategies for altering the SQL to attempt to improve or stabilize performance.
Just ramblings... Not really a Java question... Good luck though. -
Select (variable) into:parameter from xyz , dynamic sql
hello everyone
I have a table with the columns KZ01*01*, KZ01*02*, KZ01*03*.....
I want to select the value from one column depending of a variable z.b. varable=3 I want the value select KZ01*03*
I wrote the trigger post_querry:
declare
v_kfz string(20);
begin
v_kfz:='select KZ010'||:daten.lkw||'into :kennzeichen from r_bestellung@r where nummer=:daten.r_bestell_nummer';
Forms_DDL(v_kfz);
end;
alternativ I tried:
execute IMMEDIATE 'select KZ010'||:daten.lkw||'from r_bestellung@r where nummer=:daten.r_bestell_nummer'
I am using Form builder 6.0.... and Oracel 8i
what I am doing wrong, thanks for helping
regards
robertI think there was good example in form but here is the example for your crieteria.
DECLARE
vSqlStr VARCHAR2(1024);
cursor_number EXEC_SQL.CursType;
vRecCount NUMBER;
vReturnedValue DATATYPE; -- Set this datatype upon table field
BEGIN
cursor_number := Exec_SQL.Open_cursor;
-- Here variable your field name
-- for numeric
vSqlStr := 'select '||<VARIABLE>||' from r_bestellung@r where nummer='||:daten.r_bestell_nummer;
-- for characters
vSqlStr := 'select '||<VARIABLE>||' from r_bestellung@r where nummer='''||:daten.r_bestell_nummer||'''';
-- From above use only one on your requirement
EXEC_SQL.PARSE(cursor_number, vSqlStr);
EXEC_SQL.DEFINE_COLUMN(cursor_number,1,vReturnedValue,30);
vRecCount := EXEC_SQL.EXECUTE(cursor_number);
IF EXEC_SQL.FETCH_ROWS(cursor_number)=1 THEN
EXEC_SQL.COLUMN_VALUE(cursor_number,1,<:FORM_FIELD_NAME>); -- Here form_field_name replace with you current form field.
END IF;
EXEC_SQL.CLOSE_CURSOR(cursor_number);
EXCEPTION
When EXEC_SQL.INVALID_CONNECTION Then
message('Unexpected Invalid Connection error from EXEC_SQL');
When EXEC_SQL.PACKAGE_ERROR Then
message('Unexpected error from EXEC_SQL: '||to_char(EXEC_SQL.LAST_ERROR_CODE)|| EXEC_SQL.LAST_ERROR_MESG);
If EXEC_SQL.IS_OPEN(cursor_number) Then
EXEC_SQL.CLOSE_CURSOR(cursor_number);
message('Exception - Cleaned up Cursor');
End if;
END;-Ammad -
Insert data file name into table from sql loader
Hi All,
I have a requirement to insert the data file name dynamically into table using sql loader.
Example:
sqlldr userid=username/passwword@host_string control=test_ctl.ctl data=test_data.dat
test_ctl.ctl
LOAD DATA
FILED TERMINATED BY ','
INTO TABLE test
(empid number,
ename varchar2(20),
file_name varchar2(20) ---------- This should be the data file name which can be dynamic (coming from parameter)
test_data.dat
1,test
2,hello
3,world
4,end
Please help..
Thanks in advance.
Regards
Anujyou'll probably have to write your control file on the fly, using a .bat or .sh file
rem ===== file : test.bat ========
rem
rem ============== in pseudo speak =============
rem
rem
echo LOAD DATA > test.ctl
echo FILED TERMINATED BY ',' >> test.ctl
echo INTO TABLE test >> test.ctl
echo (empid number, >> test.ctl
echo ename varchar2(20), >> test.ctl
echo file_name constant %1% >> test.ctl
echo ) >> test.ctl
rem
rem
rem
sqlldr userid=username/passwword@host_string control=test.ctl data=test_data.dat
rem =============== end of file test.bat =======================
http://download.oracle.com/docs/cd/B19306_01/server.102/b14215/ldr_field_list.htm#i1008664 -
hi master
sir i use this command for user ip address
SELECT sys_context('userenv', 'host'), sys_context('userenv', 'ip_address') FROM dual;
BUT
form6i give me this error
Error 201 at line 26, column 12
Identifier SYS_CONTEXT must be declared
please give me idea how i get ip_address in form
thankthank for your reply
sir my need is
i check user computer name if that computer in table then i update the user feeding ouer wise i insert that computer name as new and give the feeding form access to user
you see my code
SELECT sys_context('userenv','host'), sys_context('userenv', 'ip_address') INTO HOSTNAME,IPADD FROM dual;
SELECT COUNT(*) INTO USERCOUNT FRoM forclosingyear WHERE HOSTNAME=HOSTNAME AND IPADD=IPADD;
IF USERCOUNT>0 THEN
update forclosingyear SET YEARID=:SYID,datefrom=:ysdate,dateto=:yedate WHERE HOSTNAME=HOSTNAME AND IPADD=IPADD;
ELSIF USERCOUNT=0 THEN
INSERT INTO forclosingyear (YEARID,datefrom,dateto,HOSTNAME,IPADD) VALUES (:SYID,:ysdate,:yedate,HOSTNAME,IPADD);
END IF;
this is my need
please give me idea how i get termenal name or user computer name
thank
aamir -
Storing Column-Name into variable? Possible?
Hello from germany
I got stuck with following:
How is it possible to store the name of a column into a variable or is it possible to put an index "on" a column?
The reason for this: I need to fill and check a complete column!
Thanks for Your help!
Best regards
MarlonYour question is not clear. Howver, this is what I guess you want to do.
Example, Check that the Emplyee Number I enter is KING. Check and Print message accordingly.
Here i user PL/SQL run in SQLPlus
SET VERIFY OFF
SET SERVEROUTPUT ON
DECLARE
EMP_NAME VARCHAR(30);
BEGIN
SELECT ENAME
INTO EMP_NAME
FROM EMP
WHERE EMPNO = &EMP_NUMBER;
IF EMP_NAME = 'KING'
THEN
DBMS_OUTPUT.PUT_LINE('The Emplyee Name is: '||EMP_Name);
ELSIF EMP_NAME != 'KING'
THEN
DBMS_OUTPUT.PUT_LINE('The Emplyee is not KING but: '||EMP_Name);
END IF;
EXCEPTION
WHEN NO_DATA_FOUND
THEN
DBMS_OUTPUT.PUT_LINE('The Employee Number Entered is Invalid');
END;
/ -
Passing field name into Cursor
I would like to pass the name of a field for the WHERE clause, into a cursor. In my application I need to change the field name for the where clause. I get an "Invalid Number" error when I try the following:
cursor l_sel2Cur (c_group varchar2)
is
select email from test_grp_tbl6 where c_group = 1;
select column_name
into l_colName
from listserv_grp_lk
where lg_id = v_listserv_grp;
open l_sel2Cur(l_colName);
I hope this is enough explanation. I have seen examples where the value for the where clause is passed in, but not where the field name itself is passed in. Is this possible?
Thanks in advance,
JohnSee the following example:
SQL> create or replace procedure print_enames(in_col in varchar, in_val in varchar2) is
2 c sys_refcursor;
3 v_name emp.ename%type;
4 begin
5 open c for 'select ename from emp where '||in_col||'='''||in_val||'''';
6 loop
7 fetch c into v_name;
8 exit when c%notfound;
9 dbms_output.put_line('ename='||v_name);
10 end loop;
11 end;
12 /
Procedure created.
SQL> select * from emp;
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
7566 JONES MANAGER 7839 02-APR-81 2975 20
7654 MARTIN SALESMAN 7698 28-SEP-81 1250 1400 30
7698 BLAKE MANAGER 7839 01-MAY-81 2850 30
7782 CLARK MANAGER 7839 09-JUN-81 2450 10
7788 SCOTT ANALYST 7566 19-APR-87 3000 20
7839 KING PRESIDENT 17-NOV-81 5000 10
7844 TURNER SALESMAN 7698 08-SEP-81 1500 0 30
7876 ADAMS CLERK 7788 23-MAY-87 1100 20
7900 JAMES CLERK 7698 03-DEC-81 950 30
7902 FORD ANALYST 7566 03-DEC-81 3000 20
7934 MILLER CLERK 7782 23-JAN-82 1300 10
14 rows selected.
SQL> set serverout on
SQL> exec print_enames('mgr','7839')
ename=JONES
ename=BLAKE
ename=CLARK
PL/SQL procedure successfully completed.
SQL> exec print_enames('sal','1250')
ename=WARD
ename=MARTIN
PL/SQL procedure successfully completed.
SQL> exec print_enames('deptno','30')
ename=ALLEN
ename=WARD
ename=MARTIN
ename=BLAKE
ename=TURNER
ename=JAMES
PL/SQL procedure successfully completed. -
Memory problem when store xml into XMLDB from CLOB source
Hi,
We have performed a stress test and looped the following
stored procedures for 1500 XML documents.
We found the UGA and PGA memory for this oracle process increased tremendously.
PGA memory
==========
6MB -> 2.9GB
UGA memory
==========
5MB -> 2.8GB
We have also experienced ORA-4030 error when more XML documents were inserted.
The PGA & UGA memory would not ever be released. We have checked that
the PGA & UGA memory for this process are still 2.9GB & 2.8GB the day after the stress test.
Stored Procedure
================
create or replace procedure clob_to_xml (indocid IN NUMBER) AS
clobdoc clob := EMPTY_CLOB();
myParser dbms_xmlparser.Parser;
indomdoc dbms_xmldom.domdocument;
xsltdomdoc dbms_xmldom.domdocument;
xsl dbms_xslprocessor.stylesheet;
outdomdocf dbms_xmldom.domdocumentfragment;
outnode dbms_xmldom.domnode;
outclobdoc clob := EMPTY_CLOB();
proc dbms_xslprocessor.processor;
xsltpath doc_types.canonical_doc_trim_xslt_name%type;
xmltabname doc_types.xmldb_table_name%type;
doc_type doc_types.doc_type%type;
doc_type_version doc_types.doc_type_version%type;
category doc_types.category%type;
sqlstring varchar2(500);
outxmldoc xmltype;
begin
-- clobdoc := :new.canonical_doc_content;
begin
select canonical_doc_content into clobdoc
from canonical_doc
where dttn_doc_id = indocid;
exception
when no_data_found then raise_application_error(-20001,'Doc ID ' || indocid || ' cannot be found');
when others then raise;
end;
begin
select dt.canonical_doc_trim_xslt_name, dt.xmldb_table_name, ddi.doc_type,ddi.doc_type_version, dt.category
into xsltpath, xmltabname, doc_type, doc_type_version, category
from
dttn_doc_info ddi,
doc_types dt
where ddi.dttn_doc_id = indocid
and ddi.doc_type = dt.doc_type
and ddi.doc_type_version = dt.doc_type_version;
exception
when no_data_found then raise_application_error(-20001,'Doc Type is not defined');
-- when others then raise;
end;
if (category <> 0 ) then
--only support business document at this moment
return;
end if;
if (xsltpath is null or xsltpath = '') then
raise_application_error (-20001,'XSLT is not defined on doc_type table - ' || doc_type);
end if;
if (xmltabname is null or xmltabname = '') then
raise_application_error (-20001,'XMLTable is not defined on doc_type table - ' || doc_type);
end if;
myParser := dbms_xmlparser.newParser;
dbms_xmlparser.parseClob(myParser, clobdoc);
indomdoc := dbms_xmlparser.getDocument(myParser);
dbms_xmlparser.parseClob(myParser, xdbURIType(xsltpath).getClob());
xsltdomdoc := dbms_xmlparser.getDocument(myParser);
xsl := dbms_xslprocessor.newstylesheet(xsltdomdoc, '');
proc := dbms_xslprocessor.newProcessor;
--apply stylesheet to DOM document
outdomdocf := dbms_xslprocessor.processxsl(proc, xsl, indomdoc);
outnode := dbms_xmldom.makenode(outdomdocf);
-- PL/SQL DOM API for XMLType can be used here
dbms_lob.createTemporary(outclobdoc, true);
dbms_xmldom.writeToClob(outnode, outclobdoc);
begin
sqlstring := 'INSERT INTO ' || xmltabname || ' values (:1, :2)';
EXECUTE IMMEDIATE sqlstring USING indocid, outxmldoc;
exception
when others then
begin
rollback;
raise_application_error (-20001,'Cannot insert into XMLDB , docid = ' || indocid);
end;
end;
dbms_lob.freeTemporary(outclobdoc);
DBMS_XMLDOM.freeDocument(indomdoc);
DBMS_XMLDOM.freeDocument(xsltdomdoc);
DBMS_XMLDOM.freeDocFrag(outdomdocf);
DBMS_XMLPARSER.freeParser(myParser);
DBMS_XSLPROCESSOR.freeProcessor(proc);
end;
Is there anything wrong with the Stored Procedure ?
My oracle version is 10.1.0.4.
Thanks & Regards,
NMMark,
I think you missed it. OP gave you the version.
My oracle version is 10.1.0.4.Rahul. -
Getting result of dynamic select statement into variable
I have a function that builds a dynamic sql statement. I then want to take the result of that statement and insert it into a variable. I have tried this
execute immediate strSQL USING OUT intCounter;but that is giving me an error on that line of code. The SQL is a select count(*) and works fine. It is just how to get it into the variable that is tripping me up.
Thanks,
EvaSure. Version 11g. The complete procedure reads as follows:
CREATE OR REPLACE FUNCTION VALIDATIONQUESTIONRESULT
p_ShortName VARCHAR2,
p_SiteID VARCHAR2
RETURN NUMBER IS
strSQL VARCHAR2(5000);
strTableName VARCHAR2(200);
strPatIDFieldName VARCHAR2(200);
intCounter NUMBER;
BEGIN
select VALIDATIONSQL into strSQL from vwvalidationquestions where upper(shortname) = upper(p_ShortName);
select
case UPPER(DBTABLENAME)
when 'CPTICODES' then 'CPTIPATID'
when 'CPTIICODES' then 'CPTIIPATID'
when 'DEMOGRAPHICS' then 'PATID'
when 'FAMILYHISTORY' then 'FHPATID'
when 'GCODES' then 'GCODEPATID'
when 'HOSPITALIZATION' then 'HPATID'
when 'MEDICALHISTORY' then 'MHPATID'
when 'MEDICATIONS' then 'MPATID'
when 'PROCEDURES' then 'PPATID'
when 'VISITS' then 'VPATID' end into strPatIDFieldName
from DATASPECIFICATIONS where UPPER(SHORTNAME) = UPPER(p_ShortName);
strSQL := strSQL||' and '||strPatIDFieldName||' in (select PATID from DEMOGRAPHICS where PARTICID = '||p_SiteID||');';
execute immediate strSQL into intCounter;
return intCounter;
END VALIDATIONQUESTIONRESULT; strSQL when checked builds perfectly. I get 100% what I expect from it. An example of what I am getting from strSQL is:
select count(*) from Procedures where TO_CHAR(ProcdDt, 'MM') = TO_CHAR(ADD_MONTHS(SYSDATE, -1), 'MM') and TO_CHAR(ProcdDt, 'YYYY') = TO_CHAR(ADD_MONTHS(SYSDATE, -12), 'YYYY') and PPATID in (select PATID from DEMOGRAPHICS where PARTICID = 12);I am getting the number I would expect from this. I just need to put that number into intCounter. I tried altering strSQL so it looked like this:
select count(*) into intCounter from Procedures where TO_CHAR(ProcdDt, 'MM') = TO_CHAR(ADD_MONTHS(SYSDATE, -1), 'MM') and TO_CHAR(ProcdDt, 'YYYY') = TO_CHAR(ADD_MONTHS(SYSDATE, -12), 'YYYY') and PPATID in (select PATID from DEMOGRAPHICS where PARTICID = 12);but that gave me an error on the execute immediate line as well.
Sorry, I thought it would be simple so that was why I only put that bit of info. I guess it is more complicated than it at first appeared!
Eva -
Pro C - Select abc into :cds returns value but strcpy(cds, 'test' did not
Dear All
I have a test.pc program at Unix as follow:
varchar cds [11];
varchar xyz [30];
varchar fxo [11]
main(argc, argv)
int argc;
char **argv;
find_sp_inv ();
ins_inv();
find_sp_inv()
EXEC SQL SELECT inv_no into :cds
FROM sup_inv
WHERE REF_NO = 12 ;
cds.arr[cds.len] = '\0';
EXEC SQL DECLARE cinvno CURSOR for select inv_type from inv_types
where ref_no = 12;
EXEC SQL OPEN cinvno;
for (i=0;i<3;i++) /* max three inv_type needed only against one reference */
/* invoice types may be one, two or three against one ref_no so need loop */
EXEC SQL WHENEVER NOT FOUND GOTO notfoundd;
EXEC SQL FETCH cinvno into :fxo;
fxo.arr[fxo.len] = '\0';
strcat((char*)xyz.arr,(char*)fxo.arr);
notfoundd:
printf("%-30sn\", xyz.arr) /* prints the value .. printing fine */
return;
ins_inv()
EXEC SQL
INSERT INTO inv_reference (ref_NO, ref_types)
SELECT :cds, :xyz from dual;
return;
} /* end my program */
**So it only picks Value of :cds an did not :xyz value? why please explain me ( i mean help me out).**
**Kind regards.**
**Saeed**Perhaps you have posted your problem in a wrong place - i guess.
Check from here ->
http://forums.oracle.com/forums/category.jspa?categoryID=18
Or,
http://forums.oracle.com/forums/main.jspa?categoryID=84
And, please close this thread by marked it as answered.
Regards.
Satyaki De. -
SELECT on TIMESTAMP field from ABAP with EXEC SQL
Hello,
I'm trying to get a field of one table which is defined as TIMESTAMP. MaxDB parameter DATE_TIME_FORMAT is set to INTERNAL. When I do the SELECT in SQL Studio I get ISO format 'YYYY-MM-DD HH:MM:SS.MMMMMM' back. So I tried a SELECT with ISO in WHERE clause, but I'm always getting a shortdump with this error:
Database error text........: "POS(82) Invalid date input value"
Database error code........: "-3065"
Then I did a SELECT without a WHERE clause in ABAP and got value '06-FEB-09' back from this field. So I tried with this ABAP statement and got no shortdump, but I also need to add time and not only the date.
EXEC SQL.
SELECT recv_time INTO :l_time FROM ztest WHERE sent_recv_time = '06-FEB-09'
ENDEXEC.
I'm using Native SQL because the SELECT is on a table which is not located in SAP Schema User. "SELECT recv_time FROM ztest WHERE recv_time = '2009-02-24 10:02:55.888000'" works in SQL studio, but not from ABAP.
Does anyone know which format I need to specify in the WHERE clause?
Regards
Markus Karsch
Edited by: Markus Karsch on Feb 26, 2009 4:22 PM>
Thomas Theodor Koetter wrote:
> Hello Markus
>
> I don't know whether this will work from ABAP, but at least MaxDB can internally handle the ODBC literals for time, date and timestamp.
>
> Therefore literals like
>
> "{d'0001-02-03'}"
> "{t'01:02:03'}"
> "{ts'0001-02-03 04:05:06'}"
>
> might work. See [http://msdn.microsoft.com/de-de/library/ms190234(SQL.90).aspx]
>
>
> HTH & regards Thomas
Hi Thomas,
Thanks for your help. Unfortunately doesn't seem to work, I get following shortdumps (tried with 3 different notations):
Database error text........: " "
Database error code........: "-4005"
Triggering SQL statement...: "SELECT xxxxxx, status, sent_xxxx_time FROM
xxx_xxxxxxxxx WHERE sent_recv_time = "{ts'2009-02-06 04:05:06'}""
Database error text........: "POS(87) Invalid keyword or missing delimiter"
Database error code........: "-3008"
Triggering SQL statement...: "SELECT xxxxxx, status, sent_xxxx_time FROM
xxx_xxxxxxxxx WHERE sent_recv_time = '{ts' 2009-02-06 04:05:06 '}'"
Database error text........: "POS(81) Missing value specification"
Database error code........: "-5010"
Triggering SQL statement...: "SELECT xxxxxx, status, sent_xxxx_time FROM
xxx_xxxxxxxxx WHERE sent_recv_time = { ts '2009-02-06 04:05:06.000' }"
Regards
Markus -
If in a form, I assign current_date to a variable like ' wdate:=current_date' the variable get incorrect value than if i assign like 'select current_date into wdate from dual'
Why?, current_date is always from database session isn't it?
Thanks for your help.Hello tony.g
This is the code:
:b11.femovi is a form field date type;
In this code wdate shows differente value than :b11.femovi.
I think that the value must be the same because "current_date" is a database variable isn't it?
declare
wdate date;
begin
:b11.femovi := current_date;
select current_date into wdate from dual;
rutmensaje('date='||to_Char(wdate,'dd/mm/yyyy hh24:MI')||'-'||to_Char(:b11.femovi,'dd/mm/yyyy hh24:MI'));
end; -
I want to use a dynamic schema name in the from clause but its not working.
DECLARE
vblQueryName VARCHAR2(20);
vblSchemaName VARCHAR2(20);
BEGIN
SELECT CurrentSchemaName INTO vblSchemaName FROM HR_989_SCHEMA;
vblQueryName:='060_525_020';
INSERT /*+ APPEND(HP_ELIGIBILITIES,4) */ INTO HP_ELIGIBILITIES
LVL1ID,
LVL1Desc,
LVL2ID,
LVL2Desc,
LVL3ID,
LVL3Desc,
LVL4ID,
LVL4Desc
SELECT /*+ PARALLEL(a,4) */
LVL1ID,
LVL1Desc,
LVL2ID,
LVL2Desc,
LVL3ID,
LVL3Desc,
LVL4ID,
LVL4Desc
FROM
bold vblSchemaName.HP_ELIGIBILITIES a
WHERE
UPPER(LVL2ID) = 'XX' ;
COMMIT;
DBMS_OUTPUT.PUT_LINE( 'Query Executed: ' || vblqueryName);
INSERT INTO HP_QUERYEXECLOG(QueryName) VALUES(vblQueryName);
EXCEPTION WHEN NO_DATA_FOUND THEN NULL;
END;
I want to create a rules table so that the schema name in front of the table name in the from clause can be controlled by a separate table that is maintained but its not working . Help and your valuable inputs needed for this issueI want to use a dynamic schema name in the from clauseyou can alternatively set the current schema as e.g. in:
declare
vblqueryname varchar2 (20);
vblschemaname varchar2 (20);
begin
select currentschemaname into vblschemaname from hr_989_schema;
vblqueryname := '060_525_020';
execute immediate 'alter session set current_schema=' || vblschemaname;
insert /*+ APPEND(HP_ELIGIBILITIES,4) */
into hp_eligibilities (lvl1id,
lvl1desc,
lvl2id,
lvl2desc,
lvl3id,
lvl3desc,
lvl4id,
lvl4desc
select /*+ PARALLEL(a,4) */
lvl1id,
lvl1desc,
lvl2id,
lvl2desc,
lvl3id,
lvl3desc,
lvl4id,
lvl4desc
from hp_eligibilities a
where upper (lvl2id) = 'XX';
commit;
dbms_output.put_line ('Query Executed: ' || vblqueryname);
insert into hp_queryexeclog (queryname)
values (vblqueryname);
exception
when no_data_found
then
null;
end; -
Select count into versus create table as in functions/procedures
I am working on a dynamic PL/SQL script that will count the number of records in a remote database
based on certain criteria and then if the number is "acceptable" will create a table in the connecting
database with those records.
My where clauses are supposed to be the same but I am presented with the problem, when I run the
first code ... select in to rowcount I get 122000 records, when I later do the create table as
with the same whereclause code, I get 77 records. So now I am attempting to validate that the two
where clauses are the same ... you'd think it would be obvious, but it's not.
My first operation does a select count(*) into rowcount with the where clause behind it.
The second operations creates a "sql command literal' that gets executed and returns the less value.
I build it like testscript := 'create table '||tablename ||'as select * from '||remotetablename||'@'||linkname;
testwhere := ' xxxxxxx'
then I do an execute immediate teststring ||' ' testwhere; which works but gives me 77 rows in the table.
Since I believe my where clause might be different, how can I run the first operation ... select count into rowcount
as a normal SQL statement in the script...
When I attempt to just run it I get -- PLS-00428: an into clause expected in this select statement......
I will provide the source code in my next posting. Working to get it moved to this system.. Once you see it you'll understand
why I don't think, it's the same, but I need a way to run them exactly as they are written to understand the different results.
so How can I make the select count (*) into rowcount from .... work just like a normal selectHere is first part of the procedure --- I get returned value of 122000 records ....
SELECT COUNT (*)
INTO ROWCOUNT
FROM A_K_A_D_TBL@FCA08_INGRES
WHERE (( "a_" = '1' OR "a_" = '6' ) AND
( "d_t" <> '3' OR "k_c_s" = 'Y' ) AND
"d_d" < DATECUTOFFDATE AND
"k_c_d" < DATECUTOFFDATE )OR
(( "a_" = 4 OR "a_" = 7 ) AND
( "d_t" <> '3' OR
"k_c_s" = 'Y' OR
"r_t" = '0' OR
"r_t" = '2' OR
"r_t" = '3' ) AND
"d_d" < DATECUTOFFDATE AND
"k_c_d" < DATECUTOFFDATE AND
"r_d" < DATECUTOFFDATE AND
"s_d" < DATECUTOFFDATE);
then I attempt to duplicate it for string literals.... when this runs ... I get only 77 records. So that makes me think that my strings are not
done properly.
So I want to try to run the first sql itself ... but then I get the errors about needing select into ..... etc..
TESTWHERE := q'[WHERE (( "a_" = '1' OR "a_" = '6' ) AND ( "d_t" <> '3' OR "k_c_s" = 'Y' )]'||
q'[ AND "d_d" < DATE ']'||TO_CHAR(DATECUTOFFDATE,'YYYY-MM-DD')||q'[']'||
q'[ AND "k_c_d" < DATE ']'||TO_CHAR(DATECUTOFFDATE,'YYYY-MM-DD')||q'[')]'||
q'[ OR (( "a_" = 4 OR "a_" = 7 )]'||
q'[ AND ( "d_t" <> '3' OR "k_c_s" = 'Y' OR "r_t" = '0' OR "r_t" = '2' OR "r_t" = '3' )]'||
q'[ AND "d_d" < DATE ']'||TO_CHAR(DATECUTOFFDATE,'YYYY-MM-DD')||q'[']'||
q'[ AND "k_c_d" < DATE ']'||TO_CHAR(DATECUTOFFDATE,'YYYY-MM-DD')||q'[']'||
q'[ AND "r_d" < DATE ']'||TO_CHAR(DATECUTOFFDATE,'YYYY-MM-DD')||q'[']'||
q'[ AND "s_d" < DATE ']'||TO_CHAR(DATECUTOFFDATE,'YYYY-MM-DD')||q'[')]';
TESTSTRING := 'CREATE TABLE '||UCASEXTABLENAMETEMP||' AS SELECT * FROM '||UCASEXTABLENAME||'@'||XLINKNAME;
DBMS_OUTPUT.PUT_LINE(TESTSTRING);
DBMS_OUTPUT.PUT_LINE(TESTWHERE);
EXECUTE IMMEDIATE TESTSTRING||' '||TESTWHERE; -
Select fom table for all entries where field starts with value
Hello
I want to write a select like this
select * from bsis
into lt_bsis
for all entries in lt_itab
where xblnr like lt_itab-belnr%
I want to select all the entries from bsis where the field xblnr starts with the values found in lt_itab-belnr.
for example
ls_itab-belnr = 5100000028
bsis-xblnr = 510000002810001
510000002810002
510000002810003
520000002810001
and i want to select only the entries that start with 5100000028 in this case
Can anybody help?
ThanksHi,
I hope below example code will help you to fix your issue,
REPORT ytest.
TYPES : BEGIN OF ty_typ1,
val TYPE i,
END OF ty_typ1.
TYPES : BEGIN OF ty_typ2,
val1 TYPE hrobjid,
val2 TYPE hrobjid,
END OF ty_typ2.
DATA : int_typ1 TYPE TABLE OF ty_typ1,
int_typ2 TYPE TABLE OF ty_typ2,
wa_typ1 TYPE ty_typ1,
wa_typ2 TYPE ty_typ2,
int_1001 TYPE TABLE OF hrp1001,
wa_1001 TYPE hrp1001.
REFRESH : int_typ1, int_typ2, int_1001.
CLEAR : wa_typ1, wa_typ2, wa_1001.
wa_typ1-val = 500001.
APPEND wa_typ1 TO int_typ1.
wa_typ1-val = 500002.
APPEND wa_typ1 TO int_typ1.
wa_typ1-val = 500003.
APPEND wa_typ1 TO int_typ1.
wa_typ1-val = 500001.
APPEND wa_typ1 TO int_typ1.
SORT int_typ1 ASCENDING BY val.
DELETE ADJACENT DUPLICATES FROM int_typ1 COMPARING val.
LOOP AT int_typ1 INTO wa_typ1.
wa_typ2-val1 = ( wa_typ1-val * 100 ) + 1.
wa_typ2-val2 = wa_typ2-val1 + 98.
APPEND wa_typ2 TO int_typ2.
CLEAR : wa_typ1, wa_typ2.
ENDLOOP.
SELECT * FROM hrp1001 INTO TABLE int_1001
FOR ALL ENTRIES IN int_typ2 WHERE
plvar EQ '01' AND
otype EQ 'S' AND
sclas EQ 'O' AND
begda LE sy-datum AND
endda GE sy-datum AND
objid GE int_typ2-val1 AND
objid LE int_typ2-val2.
LOOP AT int_1001 INTO wa_1001.
WRITE : / wa_1001-objid.
ENDLOOP.
Thanks & Regards,
Harish Kumar N
Maybe you are looking for
-
Can I Retrieve Files From Time Capsule?
I had a MacBook Pro that was fully backed up to a Time Capsule. The laptop was stolen last week. I have some files (photos I wanted to use for holiday cards) I wanted to retrieve while I save up some money to buy a new MacBook. I have two powerbooks
-
TS3297 I can't purchase in a game which's named "Tower Of Saviors"
I used to purchase in this game, but recently I can't, everytime when I buy something, there's a message which shows "Your Purchase Could Not Be Completed For assistance, contact iTunes Support at www.apple.com/support/itunes/ww/." But I can buy Apps
-
Hi everyone, I am confused by wait function in LabVIEW. I have a while loop and the calculation time duration for each iteration is about 0.1ms without using wait funtion inside of the loop. However when I tried to add wait function and set the wait
-
Using MobileMe calendar with MS Outlook Calendar for Mac
For some reason my calendar items in MS Outlook 2011 for Mac aren't syncing with my MobileMe account. When I use iCal, all calendar items are there. But, when I just loaded MS Office Mac 2011 with Outlook, i set up my MobileMe account and it synced
-
How can i install Adobe Acrobat 11 in german language
Hello, a simple question. how can i install Adobe Acrobat XI Prof. in german language? I have the donwload option for german and this will download the AcrobatPro_11_Web_WWMUI.exe. --> Acrobat Professional 11.0 German Windows Acrobat Professional 1