Pass Pl/sql table into USING clause in EXECUTE IMMEDIATE statment
Getting error when I try to pass the PL/SQL table into USING clause in EXECUTE IMMEDIATE statment:
Declare
result NUMBER;
TYPE values_tab IS TABLE OF NUMBER INDEX BY BINARY_INTEGER;
lv_tab values_tab;
lv_exp varchar2(300);
lv_exec varchar2(300);
BEGIN
lv_tab(1) := 5;
lv_tab(2) := 48;
lv_tab(3) := 7;
lv_tab(4) := 6;
lv_exp := ':b1+:b2+(:b3*:b4)';
lv_exec := 'SELECT '||lv_exp ||' FROM DUAL';
EXECUTE IMMEDIATE
lv_exec
INTO
result
USING
lv_tab;
DBMS_OUTPUT.PUT_LINE(result);
END;
Error at line 1
ORA-06550: line 20, column 12:
PLS-00457: expressions have to be of SQL types
ORA-06550: line 15, column 8:
PL/SQL: Statement ignored
I am trying to evaluate the expression ":b1+:b2+(:b3*:b4)" which is stored in table. This table has different expressions (around 300 expressions). I want to use the bind variables in expression because each expression evaluated thousand of time may be more in some case. If I don't use bind variable then it fill shared pool.
Is there any way I can pass the USING (IN) parameters dynamically instead of writing "USING lv_tab(1), lv_tab(2), lv_tab(3), lv_tab(4)"? As number of input parameters change depend on the expression in the table.
If not possible please suggest any other ideas/approches
Please help..
Edited by: satnam on Jun 11, 2009 11:50 AM
Well, you keep changing reqs faster I can keep up. Anyway, assuming N-th bind variable (left-to-right) corresponds to collection N-th element:
Declare
result NUMBER;
lv_tab values_tab := values_tab();
lv_exp varchar2(300);
lv_exec varchar2(300);
lv_i number := 0;
BEGIN
lv_tab.extend(4);
lv_tab(1) := 5;
lv_tab(2) := 48;
lv_tab(3) := 7;
lv_tab(4) := 6;
lv_exp := ':5000135+:5403456+(:5900111*:5200456)';
lv_exec := lv_exp;
While regexp_like(lv_exec,':\d+') loop
lv_i := lv_i + 1;
lv_exec := REGEXP_REPLACE(lv_exec,':\d+',':b(' || lv_i || ')',1,1);
end loop;
lv_exec := 'BEGIN :a := ' || lv_exec || '; END;';
DBMS_OUTPUT.PUT_LINE(lv_exec);
EXECUTE IMMEDIATE lv_exec USING OUT result,IN lv_tab;
DBMS_OUTPUT.PUT_LINE(result);
END;
BEGIN :a := :b(1)+:b(2)+(:b(3)*:b(4)); END;
95
PL/SQL procedure successfully completed.
SQL> SY.
Similar Messages
-
Dynamic USING clause in execute immediate
Hi All,
Is it possible to build a dynamic using clause in execute immediate command.
EXECUTE IMMEDIATE <dynamic query> USING <dynamic clause>;
Rgrds,
Nitin.Hi,
The problem is I have a query in which in some scenarios I want just one column in where clause, in other scenario I need 2 columns in the where clause.
So I would have to write 2 different queries.
execute immediate 'SELECT 1 FROM DUAL WHERE 1 = :bind1' into a using 1;
execute immediate 'SELECT 1 FROM DUAL WHERE 1 = :bind1 AND 2 = :bind2' into a using 1, 2;
Is there any way I can achieve this in a single query like:
dynamic_using_str varchar2(100);
dynamic_using_str := '1';
execute immediate 'SELECT 1 FROM DUAL WHERE 1 = :bind1' into a using dynamic_using_str;
dynamic_using_str := '1, 2';
execute immediate 'SELECT 1 FROM DUAL WHERE 1 = :bind1 AND 2 = :bind2' into a using dynamic_using_str;
~Nitin.
Edited by: user13060845 on Apr 30, 2010 12:29 PM -
How to use using clause in execute immediate statement??
Hi ALL,
Can u help me ....
This is the code which I have written...
declare
type rec_typ is table of forall_test%rowtype;
v_rectype rec_typ:=rec_typ();
begin
--poputating records
for i in 1..10000 loop
v_rectype.extend;
v_rectype(v_rectype.last).id:=i;
v_rectype(v_rectype.last).code:=to_char(i);
v_rectype(v_rectype.last).description:='Description :'||to_char(i);
end loop;
execute immediate 'truncate table forall_test';
forall i in v_rectype.first..v_rectype.last
execute immediate 'insert into forall_test values :1' using v_rectype(i);
commit;
end;
But I am getting this ERROR....
execute immediate 'insert into forall_test values :1' using v_rectype(i);
ERROR at line 14:
ORA-06550: line 14, column 61:
PLS-00457: expressions have to be of SQL types
ORA-06550: line 14, column 1:
PL/SQL: Statement ignored
Thanks & Regards,
T.HalderThatmeans using statement cannot be a non sql type.True: You need an sql type for this:
e.g. with
create or replace type emp_typ
as
object (empno number (4),
ename varchar2 (10 byte),
job varchar2 (9 byte),
mgr number (4),
hiredate date,
sal number (7, 2),
comm number (7, 2),
deptno number (2))
create or replace type emp_tab as table of emp_typ
/you can do
--- an empty test table
SQL> create table emp2
as
select *
from emp
where 1 = 2
Table created.
SQL> declare
emp2_tab emp_tab;
begin
/* fill the collection */
select emp_typ (empno,
ename,
job,
mgr,
hiredate,
sal,
comm,
deptno)
bulk collect into emp2_tab
from emp
where empno like '77%';
-- forall loop
forall c in 1 .. emp2_tab.count
execute immediate 'begin
insert into emp2 select * from table(cast(emp_tab(:1) as emp_tab)) t;
update emp2 set sal = null where empno = (:1).empno and empno = 7788;
end;' using emp2_tab (c);
end;
PL/SQL procedure successfully completed.
SQL> select empno, ename, sal from emp2
EMPNO ENAME SAL
7782 CLARK 2450
7788 SCOTT
2 rows selected. -
Breaking down SQL table into Multiple tables on the web using struts
I have a SQL table with business names and products. I am trying to display tables on a webpage for each individual business and their products. So one table is for each business and each business table lists all the products for that business. I'm not really sure how to do this. I sorted by the business names so all the related records are next to each other. I did try two nested iterate statements but received an error about missing a getter. Any suggestions would be helpful. I am writing this code in a JSP file and can use most struts commands (bean, html, nested commands). Sorry if this topics isn't very related to JSP but couldn't really find a better spot.Thanks
You are missing the position parameter:
set echo on
drop table t1;
drop table t2;
drop table t3;
create table t1 (fld1 varchar2(5), fld2 varchar2(10), fld3 varchar2(10),
fld4 varchar2(10) );
create table t2 (fld1 varchar2(5), fld2 varchar2(10), fld3 varchar2(10),
fld4 number );
create table t3 (fld1 varchar2(5), fld2 varchar2(10), fld3 varchar2(10),
fld4 varchar2(10), fld5 varchar2(10) );
load data
infile *
append
into table mpowel01.t1
when (fld1 = 'T1' )
( fld1 terminated by ',',
fld2 terminated by ',',
fld3 terminated by ',',
fld4 terminated by whitespace)
into table mpowel01.t2
when (fld1 = 'T2' )
( fld1 position(1) terminated by ',',
fld2 terminated by ',',
fld3 terminated by ',',
fld4 terminated by whitespace)
into table mpowel01.t3
when (fld1 = 'T3' )
TRAILING NULLCOLS
( fld1 position(1) terminated by ',',
fld2 terminated by ',',
fld3 terminated by ',',
fld4 terminated by ',',
fld5 terminated by whitespace)
BEGINDATA
T1,one,one,one
T2,two,two,2
T3,three,three,three,three
UT1 > select * from t3;
FLD1 FLD2 FLD3 FLD4 FLD5
T3 three three three three
UT1 > select * from t2;
FLD1 FLD2 FLD3 FLD4
T2 two two 2
UT1 > select * from t1;
FLD1 FLD2 FLD3 FLD4
T1 one one one
HTH -- Mark D Powell -- -
Loading datafrom a PL/SQL table into the Database table
I have created two procedures to try and achieve the problem at hand.
It retrieves and displays the record from a DBMS_OUTPUT.PUT_LINE prospective as indicated in (1&2), but I am having difficulty loading these values into a PL/SQL table from the package labeled as (3). I read your book and all but I do not see a solution to my problem
All code compiles. (1&2) work together, (3) works by itself but will not populate the table, and I get no errors.
1.The first being the one that retrieves the XML file and parses it.
CREATE OR REPLACE procedure xml_main is
P XMLPARSER.Parser;
DOC CLOB;
v_xmldoc xmldom.DOMDocument;
v_out CLOB;
BEGIN
P := xmlparser.newParser;
xmlparser.setValidationMode(p, FALSE);
DOC := '<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<com.welligent.Student.BasicStudent.Create>
<ControlAreaSync messageCategory="com.welligent.Student" messageObject="BasicStudent" messageAction="Create" messageRelease="1.0" messagePriority="1" messageType="Sync">
<Sender>
<MessageId>
<SenderAppId>com.openii.SyncRouter</SenderAppId>
<ProducerId>a72af712-90ea-43be-b958-077a87a29bfb</ProducerId>
<MessageSeq>53</MessageSeq>
</MessageId>
<Authentication>
<AuthUserId>Router</AuthUserId>
</Authentication>
</Sender>
<Datetime>
<Year>2001</Year>
<Month>3</Month>
<Day>23</Day>
<Hour>13</Hour>
<Minute>47</Minute>
<Second>30</Second>
<SubSecond>223</SubSecond>
<Timezone>6:00-GMT</Timezone>
</Datetime>
</ControlAreaSync>
<DataArea>
<NewData>
<BasicStudent mealCode="" usBorn="Yes" migrant="No" workAbility="No" ellStatus="">
<StudentNumber>052589F201</StudentNumber>
<ExternalIdNumber>1234567890</ExternalIdNumber>
<StateIdNumber>123456</StateIdNumber>
<Name>
<LastName>Lopez</LastName>
<FirstName>Maria</FirstName>
<MiddleName>S</MiddleName>
</Name>
<Gender>Female</Gender>
<BirthDate>
<Month>1</Month>
<Day>1</Day>
<Year>1995</Year>
</BirthDate>
<Race>Hispanic</Race>
<Ethnicity>Hispanic</Ethnicity>
<PrimaryLanguage>English</PrimaryLanguage>
<HouseholdLanguage>Spanish</HouseholdLanguage>
<Address>
<Street>123 Any Street</Street>
<ApartmentNumber>12-D</ApartmentNumber>
<City>Los Angeles</City>
<County>Los Angeles</County>
<State>CA</State>
<ZipCode>90071</ZipCode>
</Address>
</BasicStudent>
</NewData>
</DataArea>
</com.welligent.Student.BasicStudent.Create>';
--v_out := DOC;
SYS.XMLPARSER.PARSECLOB ( P, DOC );
v_xmldoc := SYS.XMLPARSER.getDocument(P);
--DBMS_LOB.createtemporary(v_out,FALSE,DBMS_LOB.SESSION);
--v_out := SYS.XMLPARSER.PARSECLOB ( P, DOC );
--SYS.XMLDOM.writetoCLOB(v_xmldoc, v_out);
--INSERT INTO TEST (TEST_COLUMN)
--VALUES(V_OUT);
--printElements(v_xmldoc);
printElementAttributes(v_xmldoc);
exception
when xmldom.INDEX_SIZE_ERR then
raise_application_error(-20120, 'Index Size error');
when xmldom.DOMSTRING_SIZE_ERR then
raise_application_error(-20120, 'String Size error');
when xmldom.HIERARCHY_REQUEST_ERR then
raise_application_error(-20120, 'Hierarchy request error');
when xmldom.WRONG_DOCUMENT_ERR then
raise_application_error(-20120, 'Wrong doc error');
when xmldom.INVALID_CHARACTER_ERR then
raise_application_error(-20120, 'Invalid Char error');
when xmldom.NO_DATA_ALLOWED_ERR then
raise_application_error(-20120, 'Nod data allowed error');
when xmldom.NO_MODIFICATION_ALLOWED_ERR then
raise_application_error(-20120, 'No mod allowed error');
when xmldom.NOT_FOUND_ERR then
raise_application_error(-20120, 'Not found error');
when xmldom.NOT_SUPPORTED_ERR then
raise_application_error(-20120, 'Not supported error');
when xmldom.INUSE_ATTRIBUTE_ERR then
raise_application_error(-20120, 'In use attr error');
END;
2. The second which displays the values from the .xml file I initialized above.
CREATE OR REPLACE procedure printElementAttributes(doc xmldom.DOMDocument) is
nl XMLDOM.DOMNODELIST;
len1 NUMBER;
len2 NUMBER;
n XMLDOM.DOMNODE;
e XMLDOM.DOMELEMENT;
nnm XMLDOM.DOMNAMEDNODEMAP;
attrname VARCHAR2(100);
attrval VARCHAR2(100);
text_value VARCHAR2(100):=NULL;
n_child XMLDOM.DOMNODE;
BEGIN
-- get all elements
nl := XMLDOM.getElementsByTagName(doc, '*');
len1 := XMLDOM.getLength(nl);
-- loop through elements
FOR j in 0..len1-1 LOOP
n := XMLDOM.item(nl, j);
e := XMLDOM.makeElement(n);
DBMS_OUTPUT.PUT_LINE(xmldom.getTagName(e) || ':');
-- get all attributes of element
nnm := xmldom.getAttributes(n);
n_child:=xmldom.getFirstChild(n);
text_value:=xmldom.getNodeValue(n_child);
dbms_output.put_line('val='||text_value);
IF (xmldom.isNull(nnm) = FALSE) THEN
len2 := xmldom.getLength(nnm);
dbms_output.put_line('length='||len2);
-- loop through attributes
FOR i IN 0..len2-1 LOOP
n := xmldom.item(nnm, i);
attrname := xmldom.getNodeName(n);
attrval := xmldom.getNodeValue(n);
dbms_output.put(' ' || attrname || ' = ' || attrval);
END LOOP;
dbms_output.put_line('');
END IF;
END LOOP;
END printElementAttributes;
3. The package trying to insert into a PL/SQL table.
CREATE OR REPLACE PACKAGE BODY XMLSTUD2 AS
PROCEDURE STUDLOAD
IS
v_parser xmlparser.Parser;
v_doc xmldom.DOMDocument;
v_nl xmldom.DOMNodeList;
v_n xmldom.DOMNode;
DOC CLOB;
v_out CLOB;
n2 XMLDOM.DOMNODELIST;
TYPE stuxml_type IS TABLE OF STUDENTS%ROWTYPE;
s_tab stuxml_type := stuxml_type();
--l_sturec students%rowtype;
BEGIN
-- Create a parser.
v_parser := xmlparser.newParser;
xmlparser.setValidationMode(v_parser, FALSE);
DOC := '<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<com.welligent.Student.BasicStudent.Create>
<ControlAreaSync messageCategory="com.welligent.Student" messageObject="BasicStudent" messageAction="Create" messageRelease="1.0" messagePriority="1" messageType="Sync">
<Sender>
<MessageId>
<SenderAppId>com.openii.SyncRouter</SenderAppId>
<ProducerId>a72af712-90ea-43be-b958-077a87a29bfb</ProducerId>
<MessageSeq>53</MessageSeq>
</MessageId>
<Authentication>
<AuthUserId>Router</AuthUserId>
</Authentication>
</Sender>
<Datetime>
<Year>2001</Year>
<Month>3</Month>
<Day>23</Day>
<Hour>13</Hour>
<Minute>47</Minute>
<Second>30</Second>
<SubSecond>223</SubSecond>
<Timezone>6:00-GMT</Timezone>
</Datetime>
</ControlAreaSync>
<DataArea>
<NewData>
<BasicStudent mealCode="" usBorn="Yes" migrant="No" workAbility="No" ellStatus="">
<StudentNumber>052589F201</StudentNumber>
<ExternalIdNumber>1234567890</ExternalIdNumber>
<StateIdNumber>123456</StateIdNumber>
<Name>
<LastName>Lopez</LastName>
<FirstName>Maria</FirstName>
<MiddleName>S</MiddleName>
</Name>
<Gender>Female</Gender>
<BirthDate>
<Month>1</Month>
<Day>1</Day>
<Year>1995</Year>
</BirthDate>
<Race>Hispanic</Race>
<Ethnicity>Hispanic</Ethnicity>
<PrimaryLanguage>English</PrimaryLanguage>
<HouseholdLanguage>Spanish</HouseholdLanguage>
<Address>
<Street>123 Any Street</Street>
<ApartmentNumber>12-D</ApartmentNumber>
<City>Los Angeles</City>
<County>Los Angeles</County>
<State>CA</State>
<ZipCode>90071</ZipCode>
</Address>
</BasicStudent>
</NewData>
</DataArea>
</com.welligent.Student.BasicStudent.Create>';
-- Parse the document and create a new DOM document.
SYS.XMLPARSER.PARSECLOB ( v_parser, DOC );
v_doc := SYS.XMLPARSER.getDocument(v_parser);
-- Free resources associated with the Parser now it is no longer needed.
xmlparser.freeParser(v_parser);
-- Get a list of all the STUD nodes in the document using the XPATH syntax.
v_nl := xslprocessor.selectNodes(xmldom.makeNode(v_doc),'/com.welligent.Student.BasicStudent.Create/DataArea/NewData/BasicStudent/Address');
dbms_output.put_line( 'New Stud processed on '||to_char(sysdate, 'YYYY-MON-DD'));
-- Loop through the list and create a new record in a tble collection
-- for each STUD record.
FOR stud IN 0 .. xmldom.getLength(v_nl) - 1 LOOP
v_n := xmldom.item(v_nl, stud);
s_tab.extend;
-- Use XPATH syntax to assign values to he elements of the collection.
--s_tab(s_tab.last).STUDENT_ID :=xslprocessor.valueOf(v_n,'StudentNumber');
--s_tab(s_tab.last).SSN :=xslprocessor.valueOf(v_n,'ExternalIdNumber');
--s_tab(s_tab.last).SHISID :=xslprocessor.valueOf(v_n,'StateIdNumber');
s_tab(s_tab.last).STUDENT_LAST_NAME :=xslprocessor.valueOf(v_n,'LastName');
--dbms_output.put_line( s_tab(s_tab.last).STUDENT_LAST_NAME);
s_tab(s_tab.last).STUDENT_FIRST_NAME :=xslprocessor.valueOf(v_n,'FirstName');
--s_tab(s_tab.last).STUDENT_MI :=xslprocessor.valueOf(v_n,'MiddleName');
--s_tab(s_tab.last).STUDENT_GENDER :=xslprocessor.valueOf(v_n,'Gender');
--s_tab(s_tab.last).SHISID :=xslprocessor.valueOf(v_n,'Month');
--s_tab(s_tab.last).SHISID :=xslprocessor.valueOf(v_n,'Day');
--s_tab(s_tab.last).SHISID :=xslprocessor.valueOf(v_n,'Year');
--s_tab(s_tab.last).STUDENT_RACE :=xslprocessor.valueOf(v_n,'Race');
--s_tab(s_tab.last).STUDENT_ETHNIC :=xslprocessor.valueOf(v_n,'Ethnicity');
--s_tab(s_tab.last).STUDENT_PRI_LANG :=xslprocessor.valueOf(v_n,'PrimaryLanguage');
--s_tab(s_tab.last).STUDENT_SEC_LANG :=xslprocessor.valueOf(v_n,'HouseholdLanguage');
--s_tab(s_tab.last).STUDENT_STREET :=xslprocessor.valueOf(v_n,'Street');
--s_tab(s_tab.last).STUDENT_APART_NO :=xslprocessor.valueOf(v_n,'ApartmentNumber');
--s_tab(s_tab.last).STUDENT_COUNTY :=xslprocessor.valueOf(v_n,'City');
--s_tab(s_tab.last).STUDENT_COUNTY :=xslprocessor.valueOf(v_n,'County');
--s_tab(s_tab.last).STUDENT_STATE :=xslprocessor.valueOf(v_n,'State');
--s_tab(s_tab.last).STUDENT_ZIP :=xslprocessor.valueOf(v_n,'ZipCode');
END LOOP;
FOR stud IN s_tab.first..s_tab.last LOOP
dbms_output.put_line( s_tab(s_tab.last).STUDENT_LAST_NAME);
INSERT INTO STUDENTS (
SHISID, SSN, DOE_SCHOOL_NUMBER,
PATIENT_TYPE, TEACHER, HOMEROOM,
STUDENT_LAST_NAME, STUDENT_FIRST_NAME, STUDENT_MI,
STUDENT_DOB, STUDENT_BIRTH_CERT, STUDENT_COMM,
STUDENT_MUSA, STUDENT_FAMSIZE, STUDENT_FAMINCOME,
STUDENT_UNINSURED, STUDENT_LUNCH, STUDENT_ZIP,
STUDENT_STATE, STUDENT_COUNTY, STUDENT_STREET,
STUDENT_APART_NO, STUDENT_PHONE, STUDENT_H2O_TYPE,
STUDENT_WASTE_TRT, STUDENT_HOME_SET, STUDENT_NONHOME_SET,
STUDENT_GENDER, STUDENT_RACE, STUDENT_ETHNIC,
STUDENT_PRI_LANG, STUDENT_SEC_LANG, STUDENT_ATRISK,
EMER_COND_MEMO, ASSIST_DEVICE_TYPE, SCHOOL_ENTER_AGE,
STUDENT_CURR_GRADE, S504_ELIG_DATE, S504_DEV_DATE,
S504_REV_DATE, STUDENT_504, STUDENT_IEP,
IEP_EXP_DATE, GRAD_CLASS, TYPE_DIPLOMA,
GRADE_RETAIN, LIT_PASS_TEST_MATH, LIT_PASS_DATE_MATH,
LIT_PASS_TEST_WRITE, LIT_PASS_DATE_WRITE, LIT_PASS_TEST_READ,
LIT_PASS_DATE_READ, SPEC_ED_ELIG, SPEC_ED_CODE,
TRANSPORT_CODE, TRANSPORT_NO, PRIME_HANDICAP,
PRIME_HANDICAP_PERCENT, PRIME_HANDI_MANAGER, FIRST_ADD_HANDI,
FIRST_ADD_HANDICAP_PERCENT, FIRST_ADD_HANDI_504, FIRST_ADD_HANDI_504_DATE,
SECOND_ADD_HANDI, SECOND_ADD_HANDICAP_PERCENT, MED_EXTERNAL_NAME,
INS_TYPE, INS_PRI, INS_NAME,
INS_MEDICAID_NO, ELIGDATE, INS_PRIV_INSURANCE,
INS_APPR_BILL, INS_APPR_DATE, INS_PARENT_APPR,
INS_POL_NAME, INS_POL_NO, INS_CARRIER_NO,
INS_CARRIER_NAME, INS_CARRIER_RELATE, INS_AFFECT_DATE,
INS_COPAY_OV, INS_COPAY_RX, INS_COPAY_AMBUL,
INS_COPAY_EMER, INS_COPAY_OUTPAT, STUDENT_INACTIVE,
PHYS_ID, ENCOUNTERNUM, USERID,
MODDATE, STUDENT_ID, S504_DISABILITY,
CHAPTER1, WELLNESS_ENROLL, SCHOOL_OF_RESIDENCE,
INITIAL_IEP_DATE, CALENDAR_TRACK, USA_BORN,
ALT_ID, FUTURE_SCHOOL, IEP_LAST_MEETING,
IEP_LAST_SETTING, IEP_LAST_REFER_EVAL, THIRD_ADD_HANDI,
LEP, GIFTED, IEP_EXIT_REASON,
CASE_MANAGER_ID, INTAKE_NOTES, CALLER_PHONE,
CALL_DATE, CALLER_RELATIONSHIP, CALLER_NAME,
BUSINESS_PHONE, FAX, EMAIL,
HIGHEST_EDUCATION, INTAKE_DATE, SERVICE_COORDINATOR,
DISCHARGE_DATE, DISCHARGE_REASON, DISCHARGE_NOTES,
INTAKE_BY, INTAKE_STATUS, IEP_LAST_SERVED_DATE,
IEP_APC_DATE, IEP_EXIT_DATE, ADDRESS2,
LEGAL_STATUS, RELIGION, EMPLOYMENT_STATUS,
TARG_POP_GROUP1, TARG_POP_GROUP2, MARITAL_STATUS,
THIRD_ADD_HANDI_PERCENT, LAST_INTERFACE_DATE, SERVICE_PLAN_TYPE,
CURRENT_JURISDICTION, FIPS, BIRTH_PLACE_JURISDICTION,
BIRTH_PLACE_HOSPITAL, BIRTH_PLACE_STATE, BIRTH_PLACE_COUNTRY,
OTHER_CLIENT_NAME, SIBLINGS_WITH_SERVICES, PERM_SHARE_INFORMATION,
PERM_VERIFY_INSURANCE, REFERRING_AGENCY, REFERRING_INDIVIDUAL,
AUTOMATIC_ELIGIBILITY, INTAKE_IEP_ID, FUTURE_SCHOOL2,
FUTURE_SCHOOL3, TRANSLATOR_NEEDED, TOTAL_CHILDREN_IN_HOME,
REFERRED_BY, FAMILY_ID, SCREENING_CONSENT_FLAG,
PICTURE_FILE, DUAL_ENROLLED, DOE_SCHOOL_NUMBER2)
VALUES (123456789012, null,null ,
null,null,null ,s_tab(stud).STUDENT_LAST_NAME
, s_tab(stud).STUDENT_LAST_NAME,null ,
null ,null ,null ,
null ,null , null,
null ,null , null,
null ,null , null,
null ,null , null,
null ,null , null,
null ,null , null,
null ,null , null,
null ,null , null,
null ,null , null,
null ,null , null,
null ,null , null,
null ,null , null,
null ,null , null,
null ,null , null,
null ,null , null,
null ,null , null,
null ,null , null,
null ,null , null,
null ,null , null,
null ,null , null,
null ,null , null,
null ,null , null,
null ,null , null,
null ,null , null,
null ,null , null,
null ,null , null,
null ,null , null,
null ,null , null,
null ,null , null,
null ,null , null,
null ,null , null,
null ,null , null,
null ,null , null,
null ,null , null,
null ,null , null,
null ,null , null,
null ,null , null,
null ,null , null,
null ,null , null,
null ,null , null,
null ,null , null,
null ,null , null,
null ,null , null,
null ,null , null,
null ,null , null,
null ,null , null,
null ,null , null,
null ,null , null,
null ,null , null,
null, null,null );
END LOOP;
COMMIT;
-- Free any resources associated with the document now it
-- is no longer needed.
xmldom.freeDocument(v_doc);
END STUDLOAD;
END XMLSTUD2;
/Here's a first cut for you. Note that I've added some annotations to the XML Schema
SQL>
SQL>
SQL> var schemaURL varchar2(256)
SQL> var schemaPath varchar2(256)
SQL> --
SQL> begin
2 :schemaURL := 'http://xmlns.welligent.com/xsd/Student.xsd';
3 :schemaPath := '/public/Student.xsd';
4 end;
5 /
PL/SQL procedure successfully completed.
SQL> call dbms_xmlSchema.deleteSchema(:schemaURL,4)
2 /
Call completed.
SQL> declare
2 res boolean;
3 xmlSchema xmlType := xmlType(
4 '<xs:schema xmlns:xdb="http://xmlns.oracle.com/xdb" xmlns:xs="http://www.w3.org/2001/XMLSchema">
5 <xs:element name="Address" xdb:defaultTable="">
6 <xs:complexType>
7 <xs:sequence>
8 <xs:element ref="Street"/>
9 <xs:element ref="ApartmentNumber"/>
10 <xs:element ref="City"/>
11 <xs:element ref="County"/>
12 <xs:element ref="State"/>
13 <xs:element ref="ZipCode"/>
14 </xs:sequence>
15 </xs:complexType>
16 </xs:element>
17 <xs:element name="ApartmentNumber" xdb:defaultTable="">
18 <xs:simpleType>
19 <xs:restriction base="xs:string">
20 <xs:enumeration value="12-D"/>
21 </xs:restriction>
22 </xs:simpleType>
23 </xs:element>
24 <xs:element name="AuthUserId" xdb:defaultTable="">
25 <xs:simpleType>
26 <xs:restriction base="xs:string">
27 <xs:enumeration value="Router"/>
28 </xs:restriction>
29 </xs:simpleType>
30 </xs:element>
31 <xs:element name="Authentication" xdb:defaultTable="">
32 <xs:complexType>
33 <xs:sequence>
34 <xs:element ref="AuthUserId"/>
35 </xs:sequence>
36 </xs:complexType>
37 </xs:element>
38 <xs:element name="BasicStudent" xdb:defaultTable="">
39 <xs:complexType>
40 <xs:sequence>
41 <xs:element ref="StudentNumber"/>
42 <xs:element ref="ExternalIdNumber"/>
43 <xs:element ref="StateIdNumber"/>
44 <xs:element ref="Name"/>
45 <xs:element ref="Gender"/>
46 <xs:element ref="BirthDate"/>
47 <xs:element ref="Race"/>
48 <xs:element ref="Ethnicity"/>
49 <xs:element ref="PrimaryLanguage"/>
50 <xs:element ref="HouseholdLanguage"/>
51 <xs:element ref="Address"/>
52 </xs:sequence>
53 <xs:attribute name="mealCode" type="xs:string" use="required"/>
54 <xs:attribute name="usBorn" use="required">
55 <xs:simpleType>
56 <xs:restriction base="xs:string">
57 <xs:enumeration value="Yes"/>
58 </xs:restriction>
59 </xs:simpleType>
60 </xs:attribute>
61 <xs:attribute name="migrant" use="required">
62 <xs:simpleType>
63 <xs:restriction base="xs:string">
64 <xs:enumeration value="No"/>
65 </xs:restriction>
66 </xs:simpleType>
67 </xs:attribute>
68 <xs:attribute name="workAbility" use="required">
69 <xs:simpleType>
70 <xs:restriction base="xs:string">
71 <xs:enumeration value="No"/>
72 </xs:restriction>
73 </xs:simpleType>
74 </xs:attribute>
75 <xs:attribute name="ellStatus" type="xs:string" use="required"/>
76 </xs:complexType>
77 </xs:element>
78 <xs:element name="BirthDate" xdb:defaultTable="">
79 <xs:complexType>
80 <xs:sequence>
81 <xs:element ref="Month"/>
82 <xs:element ref="Day"/>
83 <xs:element ref="Year"/>
84 </xs:sequence>
85 </xs:complexType>
86 </xs:element>
87 <xs:element name="City" xdb:defaultTable="">
88 <xs:simpleType>
89 <xs:restriction base="xs:string">
90 <xs:enumeration value="Los Angeles"/>
91 </xs:restriction>
92 </xs:simpleType>
93 </xs:element>
94 <xs:element name="ControlAreaSync" xdb:defaultTable="">
95 <xs:complexType>
96 <xs:sequence>
97 <xs:element ref="Sender"/>
98 <xs:element ref="Datetime"/>
99 </xs:sequence>
100 <xs:attribute name="messageCategory" use="required">
101 <xs:simpleType>
102 <xs:restriction base="xs:string">
103 <xs:enumeration value="com.welligent.Student"/>
104 </xs:restriction>
105 </xs:simpleType>
106 </xs:attribute>
107 <xs:attribute name="messageObject" use="required">
108 <xs:simpleType>
109 <xs:restriction base="xs:string">
110 <xs:enumeration value="BasicStudent"/>
111 </xs:restriction>
112 </xs:simpleType>
113 </xs:attribute>
114 <xs:attribute name="messageAction" use="required">
115 <xs:simpleType>
116 <xs:restriction base="xs:string">
117 <xs:enumeration value="Create"/>
118 </xs:restriction>
119 </xs:simpleType>
120 </xs:attribute>
121 <xs:attribute name="messageRelease" use="required">
122 <xs:simpleType>
123 <xs:restriction base="xs:decimal">
124 <xs:enumeration value="1.0"/>
125 </xs:restriction>
126 </xs:simpleType>
127 </xs:attribute>
128 <xs:attribute name="messagePriority" use="required">
129 <xs:simpleType>
130 <xs:restriction base="xs:byte">
131 <xs:enumeration value="1"/>
132 </xs:restriction>
133 </xs:simpleType>
134 </xs:attribute>
135 <xs:attribute name="messageType" use="required">
136 <xs:simpleType>
137 <xs:restriction base="xs:string">
138 <xs:enumeration value="Sync"/>
139 </xs:restriction>
140 </xs:simpleType>
141 </xs:attribute>
142 </xs:complexType>
143 </xs:element>
144 <xs:element name="County" xdb:defaultTable="">
145 <xs:simpleType>
146 <xs:restriction base="xs:string">
147 <xs:enumeration value="Los Angeles"/>
148 </xs:restriction>
149 </xs:simpleType>
150 </xs:element>
151 <xs:element name="DataArea" xdb:defaultTable="">
152 <xs:complexType>
153 <xs:sequence>
154 <xs:element ref="NewData"/>
155 </xs:sequence>
156 </xs:complexType>
157 </xs:element>
158 <xs:element name="Datetime">
159 <xs:complexType>
160 <xs:sequence>
161 <xs:element ref="Year"/>
162 <xs:element ref="Month"/>
163 <xs:element ref="Day"/>
164 <xs:element ref="Hour"/>
165 <xs:element ref="Minute"/>
166 <xs:element ref="Second"/>
167 <xs:element ref="SubSecond"/>
168 <xs:element ref="Timezone"/>
169 </xs:sequence>
170 </xs:complexType>
171 </xs:element>
172 <xs:element name="Day" xdb:defaultTable="">
173 <xs:simpleType>
174 <xs:restriction base="xs:byte">
175 <xs:enumeration value="1"/>
176 <xs:enumeration value="23"/>
177 </xs:restriction>
178 </xs:simpleType>
179 </xs:element>
180 <xs:element name="Ethnicity" xdb:defaultTable="">
181 <xs:simpleType>
182 <xs:restriction base="xs:string">
183 <xs:enumeration value="Hispanic"/>
184 </xs:restriction>
185 </xs:simpleType>
186 </xs:element>
187 <xs:element name="ExternalIdNumber" xdb:defaultTable="">
188 <xs:simpleType>
189 <xs:restriction base="xs:int">
190 <xs:enumeration value="1234567890"/>
191 </xs:restriction>
192 </xs:simpleType>
193 </xs:element>
194 <xs:element name="FirstName" xdb:defaultTable="">
195 <xs:simpleType>
196 <xs:restriction base="xs:string">
197 <xs:enumeration value="Maria"/>
198 </xs:restriction>
199 </xs:simpleType>
200 </xs:element>
201 <xs:element name="Gender" xdb:defaultTable="">
202 <xs:simpleType>
203 <xs:restriction base="xs:string">
204 <xs:enumeration value="Female"/>
205 </xs:restriction>
206 </xs:simpleType>
207 </xs:element>
208 <xs:element name="Hour" xdb:defaultTable="">
209 <xs:simpleType>
210 <xs:restriction base="xs:byte">
211 <xs:enumeration value="13"/>
212 </xs:restriction>
213 </xs:simpleType>
214 </xs:element>
215 <xs:element name="HouseholdLanguage" xdb:defaultTable="">
216 <xs:simpleType>
217 <xs:restriction base="xs:string">
218 <xs:enumeration value="Spanish"/>
219 </xs:restriction>
220 </xs:simpleType>
221 </xs:element>
222 <xs:element name="LastName" xdb:defaultTable="">
223 <xs:simpleType>
224 <xs:restriction base="xs:string">
225 <xs:enumeration value="Lopez"/>
226 </xs:restriction>
227 </xs:simpleType>
228 </xs:element>
229 <xs:element name="MessageId" xdb:defaultTable="">
230 <xs:complexType>
231 <xs:sequence>
232 <xs:element ref="SenderAppId"/>
233 <xs:element ref="ProducerId"/>
234 <xs:element ref="MessageSeq"/>
235 </xs:sequence>
236 </xs:complexType>
237 </xs:element>
238 <xs:element name="MessageSeq" xdb:defaultTable="">
239 <xs:simpleType>
240 <xs:restriction base="xs:byte">
241 <xs:enumeration value="53"/>
242 </xs:restriction>
243 </xs:simpleType>
244 </xs:element>
245 <xs:element name="MiddleName" xdb:defaultTable="">
246 <xs:simpleType>
247 <xs:restriction base="xs:string">
248 <xs:enumeration value="S"/>
249 </xs:restriction>
250 </xs:simpleType>
251 </xs:element>
252 <xs:element name="Minute" xdb:defaultTable="">
253 <xs:simpleType>
254 <xs:restriction base="xs:byte">
255 <xs:enumeration value="47"/>
256 </xs:restriction>
257 </xs:simpleType>
258 </xs:element>
259 <xs:element name="Month" xdb:defaultTable="">
260 <xs:simpleType>
261 <xs:restriction base="xs:byte">
262 <xs:enumeration value="1"/>
263 <xs:enumeration value="3"/>
264 </xs:restriction>
265 </xs:simpleType>
266 </xs:element>
267 <xs:element name="Name" xdb:defaultTable="">
268 <xs:complexType>
269 <xs:sequence>
270 <xs:element ref="LastName"/>
271 <xs:element ref="FirstName"/>
272 <xs:element ref="MiddleName"/>
273 </xs:sequence>
274 </xs:complexType>
275 </xs:element>
276 <xs:element name="NewData" xdb:defaultTable="">
277 <xs:complexType>
278 <xs:sequence>
279 <xs:element ref="BasicStudent"/>
280 </xs:sequence>
281 </xs:complexType>
282 </xs:element>
283 <xs:element name="PrimaryLanguage" xdb:defaultTable="">
284 <xs:simpleType>
285 <xs:restriction base="xs:string">
286 <xs:enumeration value="English"/>
287 </xs:restriction>
288 </xs:simpleType>
289 </xs:element>
290 <xs:element name="ProducerId" xdb:defaultTable="">
291 <xs:simpleType>
292 <xs:restriction base="xs:string">
293 <xs:enumeration value="a72af712-90ea-43be-b958-077a87a29bfb"/>
294 </xs:restriction>
295 </xs:simpleType>
296 </xs:element>
297 <xs:element name="Race" xdb:defaultTable="">
298 <xs:simpleType>
299 <xs:restriction base="xs:string">
300 <xs:enumeration value="Hispanic"/>
301 </xs:restriction>
302 </xs:simpleType>
303 </xs:element>
304 <xs:element name="Second" xdb:defaultTable="">
305 <xs:simpleType>
306 <xs:restriction base="xs:byte">
307 <xs:enumeration value="30"/>
308 </xs:restriction>
309 </xs:simpleType>
310 </xs:element>
311 <xs:element name="Sender" xdb:defaultTable="">
312 <xs:complexType>
313 <xs:sequence>
314 <xs:element ref="MessageId"/>
315 <xs:element ref="Authentication"/>
316 </xs:sequence>
317 </xs:complexType>
318 </xs:element>
319 <xs:element name="SenderAppId" xdb:defaultTable="">
320 <xs:simpleType>
321 <xs:restriction base="xs:string">
322 <xs:enumeration value="com.openii.SyncRouter"/>
323 </xs:restriction>
324 </xs:simpleType>
325 </xs:element>
326 <xs:element name="State" xdb:defaultTable="">
327 <xs:simpleType>
328 <xs:restriction base="xs:string">
329 <xs:enumeration value="CA"/>
330 </xs:restriction>
331 </xs:simpleType>
332 </xs:element>
333 <xs:element name="StateIdNumber" xdb:defaultTable="">
334 <xs:simpleType>
335 <xs:restriction base="xs:int">
336 <xs:enumeration value="123456"/>
337 </xs:restriction>
338 </xs:simpleType>
339 </xs:element>
340 <xs:element name="Street" xdb:defaultTable="">
341 <xs:simpleType>
342 <xs:restriction base="xs:string">
343 <xs:enumeration value="123 Any Street"/>
344 </xs:restriction>
345 </xs:simpleType>
346 </xs:element>
347 <xs:element name="StudentNumber" xdb:defaultTable="">
348 <xs:simpleType>
349 <xs:restriction base="xs:hexBinary">
350 <xs:enumeration value="052589F201"/>
351 </xs:restriction>
352 </xs:simpleType>
353 </xs:element>
354 <xs:element name="SubSecond" xdb:defaultTable="">
355 <xs:simpleType>
356 <xs:restriction base="xs:short">
357 <xs:enumeration value="223"/>
358 </xs:restriction>
359 </xs:simpleType>
360 </xs:element>
361 <xs:element name="Timezone" xdb:defaultTable="">
362 <xs:simpleType>
363 <xs:restriction base="xs:string">
364 <xs:enumeration value="6:00-GMT"/>
365 </xs:restriction>
366 </xs:simpleType>
367 </xs:element>
368 <xs:element name="Year" xdb:defaultTable="">
369 <xs:simpleType>
370 <xs:restriction base="xs:short">
371 <xs:enumeration value="1995"/>
372 <xs:enumeration value="2001"/>
373 </xs:restriction>
374 </xs:simpleType>
375 </xs:element>
376 <xs:element name="ZipCode" xdb:defaultTable="">
377 <xs:simpleType>
378 <xs:restriction base="xs:int">
379 <xs:enumeration value="90071"/>
380 </xs:restriction>
381 </xs:simpleType>
382 </xs:element>
383 <xs:element name="com.welligent.Student.BasicStudent.Create" xdb:defaultTable="STUDENT_TABLE">
384 <xs:complexType>
385 <xs:sequence>
386 <xs:element ref="ControlAreaSync"/>
387 <xs:element ref="DataArea"/>
388 </xs:sequence>
389 </xs:complexType>
390 </xs:element>
391 </xs:schema>');
392 begin
393 if (dbms_xdb.existsResource(:schemaPath)) then
394 dbms_xdb.deleteResource(:schemaPath);
395 end if;
396 res := dbms_xdb.createResource(:schemaPath,xmlSchema);
397 end;
398 /
PL/SQL procedure successfully completed.
SQL> begin
2 dbms_xmlschema.registerSchema
3 (
4 :schemaURL,
5 xdbURIType(:schemaPath).getClob(),
6 TRUE,TRUE,FALSE,TRUE
7 );
8 end;
9 /
PL/SQL procedure successfully completed.
SQL> insert into STUDENT_TABLE values (xmltype(
2 '<com.welligent.Student.BasicStudent.Create>
3 <ControlAreaSync messageCategory="com.welligent.Student" messageObject="BasicStudent" messageAction="Create" messageRelease="1.0" me
ssagePriority="1" messageType="Sync">
4 <Sender>
5 <MessageId>
6 <SenderAppId>com.openii.SyncRouter</SenderAppId>
7 <ProducerId>a72af712-90ea-43be-b958-077a87a29bfb</ProducerId>
8 <MessageSeq>53</MessageSeq>
9 </MessageId>
10 <Authentication>
11 <AuthUserId>Router</AuthUserId>
12 </Authentication>
13 </Sender>
14 <Datetime>
15 <Year>2001</Year>
16 <Month>3</Month>
17 <Day>23</Day>
18 <Hour>13</Hour>
19 <Minute>47</Minute>
20 <Second>30</Second>
21 <SubSecond>223</SubSecond>
22 <Timezone>6:00-GMT</Timezone>
23 </Datetime>
24 </ControlAreaSync>
25 <DataArea>
26 <NewData>
27 <BasicStudent mealCode="" usBorn="Yes" migrant="No" workAbility="No" ellStatus="">
28 <StudentNumber>052589F201</StudentNumber>
29 <ExternalIdNumber>1234567890</ExternalIdNumber>
30 <StateIdNumber>123456</StateIdNumber>
31 <Name>
32 <LastName>Lopez</LastName>
33 <FirstName>Maria</FirstName>
34 <MiddleName>S</MiddleName>
35 </Name>
36 <Gender>Female</Gender>
37 <BirthDate>
38 <Month>1</Month>
39 <Day>1</Day>
40 <Year>1995</Year>
41 </BirthDate>
42 <Race>Hispanic</Race>
43 <Ethnicity>Hispanic</Ethnicity>
44 <PrimaryLanguage>English</PrimaryLanguage>
45 <HouseholdLanguage>Spanish</HouseholdLanguage>
46 <Address>
47 <Street>123 Any Street</Street>
48 <ApartmentNumber>12-D</ApartmentNumber>
49 <City>Los Angeles</City>
50 <County>Los Angeles</County>
51 <State>CA</State>
52 <ZipCode>90071</ZipCode>
53 </Address>
54 </BasicStudent>
55 </NewData>
56 </DataArea>
57 </com.welligent.Student.BasicStudent.Create>'))
58 /
1 row created.
SQL>
SQL>
SQL> -
Passing dynamic internal table into ALV
I have made one ALV report where i had created one button 'GENERATE'. ON CLICKING THIS BUTTON the data in the ALV report is downloaded to excel file.
i have used this:-
CALL METHOD cl_gui_frontend_services=>file_save_dialog
EXPORTING
window_title = l_title
default_extension = 'XLS'
initial_directory = 'C:\'
CHANGING
filename = filename
path = path
fullpath = fullpath
user_action = user_action
EXCEPTIONS
cntl_error = 1
error_no_gui = 2
not_supported_by_gui = 3
OTHERS = 4.
IF sy-subrc <> 0.
EXIT.
ENDIF.
Check which button is pressed
IF user_action <> cl_gui_frontend_services=>action_ok.
EXIT.
ENDIF.
Download error data collected from the internal table
CALL METHOD cl_gui_frontend_services=>gui_download
EXPORTING
filename = fullpath
filetype = 'ASC'
write_field_separator = '#'
codepage = '4103'
write_bom = c_true
CHANGING
data_tab = gi_final
EXCEPTIONS
file_write_error = 1
no_batch = 2
gui_refuse_filetransfer = 3
invalid_type = 4
no_authority = 5
unknown_error = 6
header_not_allowed = 7
separator_not_allowed = 8
filesize_not_allowed = 9
header_too_long = 10
dp_error_create = 11
dp_error_send = 12
dp_error_write = 13
unknown_dp_error = 14
access_denied = 15
dp_out_of_memory = 16
disk_full = 17
dp_timeout = 18
file_not_found = 19
dataprovider_exception = 20
control_flush_error = 21
not_supported_by_gui = 22
error_no_gui = 23
OTHERS = 24.
If selection is successful
IF sy-subrc EQ 0.
MESSAGE s004 . " File created successfully
ELSE.
MESSAGE i005 . " File is not created successfully
ENDIF.
In the table i have passed the internal table . this is working fine.
<b>But,
The problem is if i want to display the data in diferent layout based on selection screen criteria the data downloaded are same as default layout.
how to pass a dynamic internal table in the
CALL METHOD cl_gui_frontend_services=>gui_download</b>Hi ,
here is the Program for Download
REPORT yrs_download_transport_request.
PARAMETERS:
p_reqest TYPE trkorr OBLIGATORY,
p_folder(255) TYPE c LOWER CASE, p_sepr OBLIGATORY.
DATA:
folder TYPE string,
retval LIKE TABLE OF ddshretval WITH HEADER LINE,
fldvalue LIKE help_info-fldvalue,
transdir TYPE text255,
filename(255),
trfile(20) TYPE c,
datatab TYPE TABLE OF text8192 WITH HEADER LINE,
len TYPE i,
flen TYPE i.
TYPE-POOLS: sabc, stms, trwbo.
INITIALIZATION.
CONCATENATE sy-sysid 'K*' INTO p_reqest.
IF sy-opsys = 'Windows NT'.
p_sepr = ''.
ELSE.
p_sepr = '/'.
ENDIF.
* CALL FUNCTION 'WSAF_BUILD_SEPARATOR'
* IMPORTING
* separator = p_sepr
* EXCEPTIONS
* separator_not_maintained = 1
* wrong_call = 2
* wsaf_config_not_maintained = 3
* OTHERS = 4.
* IF sy-subrc NE 0.
* MESSAGE s001(00)
* WITH
* 'Unable to find out the separator symbol for the system.'(011).
* ENDIF.
AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_reqest.
DATA:
tt_system TYPE TABLE OF tmscsys WITH HEADER LINE,
es_selected_request TYPE trwbo_request_header,
es_selected_task TYPE trwbo_request_header,
iv_organizer_type TYPE trwbo_calling_organizer,
is_selection TYPE trwbo_selection.
iv_organizer_type = 'W'. is_selection-reqstatus = 'R'.
CALL FUNCTION 'TR_PRESENT_REQUESTS_SEL_POPUP'
EXPORTING
iv_organizer_type = iv_organizer_type
is_selection = is_selection
IMPORTING
es_selected_request = es_selected_request
es_selected_task = es_selected_task.
p_reqest = es_selected_request-trkorr.
AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_folder.
DATA: title TYPE string.
title = 'Select target folder'(005).
CALL METHOD cl_gui_frontend_services=>directory_browse
EXPORTING
window_title = title
CHANGING
selected_folder = folder
EXCEPTIONS
cntl_error = 1
error_no_gui = 2
OTHERS = 3.
CALL FUNCTION 'CONTROL_FLUSH'
EXCEPTIONS
cntl_system_error = 1
cntl_error = 2
OTHERS = 3.
p_folder = folder.
AT SELECTION-SCREEN ON p_reqest.
DATA: request_info TYPE stms_wbo_request,
request_infos TYPE stms_wbo_requests.
REFRESH request_infos.
CALL FUNCTION 'TMS_MGR_READ_TRANSPORT_REQUEST'
EXPORTING
iv_request = p_reqest
iv_header_only = 'X'
IMPORTING
et_request_infos = request_infos
EXCEPTIONS
read_config_failed = 1
table_of_requests_is_empty = 2
system_not_available = 3
OTHERS = 4.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
CLEAR request_info.
READ TABLE request_infos INTO request_info INDEX 1.
IF sy-subrc NE 0
OR request_info-e070-trkorr IS INITIAL.
MESSAGE e398(00) WITH 'Request'(006) p_reqest 'not found'(007).
ELSEIF request_info-e070-trstatus NE 'R'.
MESSAGE e398(00)
WITH 'You must release request'(008)
request_info-e070-trkorr
'before downloading'(009).
ENDIF.
START-OF-SELECTION.
folder = p_folder.
CONCATENATE p_reqest+3(7) '.' p_reqest(3) INTO trfile.
CALL FUNCTION 'RSPO_R_SAPGPARAM'
EXPORTING
name = 'DIR_TRANS'
IMPORTING
value = transdir
EXCEPTIONS
error = 0
OTHERS = 0.
PERFORM copy_file USING 'cofiles' trfile.
trfile(1) = 'R'.
PERFORM copy_file USING 'data' trfile.
trfile(1) = 'D'.
PERFORM copy_file USING 'data' trfile.
* FORM copy_file *
* --> SUBDIR * * --> FNAME *
FORM copy_file USING subdir fname.
DATA:
auth_filename TYPE authb-filename,
gui_filename TYPE string.
CONCATENATE transdir subdir fname
INTO filename
SEPARATED BY p_sepr.
REFRESH datatab.
CLEAR flen.
auth_filename = filename.
CALL FUNCTION 'AUTHORITY_CHECK_DATASET'
EXPORTING
activity = sabc_act_read
filename = auth_filename
EXCEPTIONS
no_authority = 1
activity_unknown = 2
OTHERS = 3.
IF sy-subrc <> 0.
FORMAT COLOR COL_NEGATIVE.
WRITE: / 'Read access denied. File'(001),
filename.
FORMAT COLOR OFF. EXIT.
ENDIF.
OPEN DATASET filename FOR INPUT IN BINARY MODE.
IF sy-subrc NE 0.
FORMAT COLOR COL_TOTAL.
WRITE: / 'File open error'(010), filename.
FORMAT COLOR OFF. EXIT.
ENDIF.
DO.
CLEAR len.
READ DATASET filename INTO datatab LENGTH len.
flen = flen + len.
IF len > 0. APPEND datatab. ENDIF.
IF sy-subrc NE 0.
EXIT.
ENDIF.
ENDDO.
CLOSE DATASET filename.
CONCATENATE p_folder '' fname INTO gui_filename.
CALL METHOD cl_gui_frontend_services=>gui_download
EXPORTING
bin_filesize = flen
filename = gui_filename
filetype = 'BIN'
CHANGING
data_tab = datatab[]
EXCEPTIONS
file_write_error = 1
no_batch = 2
gui_refuse_filetransfer = 3
invalid_type = 4
no_authority = 5
unknown_error = 6
header_not_allowed = 7
separator_not_allowed = 8
filesize_not_allowed = 9
header_too_long = 10
dp_error_create = 11
dp_error_send = 12
dp_error_write = 13
unknown_dp_error = 14
access_denied = 15
dp_out_of_memory = 16
disk_full = 17
dp_timeout = 18
file_not_found = 19
dataprovider_exception = 20
control_flush_error = 21
OTHERS = 24.
IF sy-subrc = 0.
WRITE: / 'File'(002), filename, 'downloaded. Length'(003), flen.
ELSE.
FORMAT COLOR COL_NEGATIVE.
WRITE: / 'File download error. Filename:'(004), filename.
FORMAT COLOR OFF.
ENDIF.
ENDFORM. "copy_file
Reward points if it is usefull....
Girish -
Passing PL/SQL table type as IN Parameter to DB Adapter
Hi,
I have an requirement to pass multiple record values(array of values) to an API from BPEL process.
For this,
1) I have created a package procedure having PL/SQL table type variable as IN Parameter.
2) In the BPEL process, created a DB adpater pointing to the above API.(Created wrapper API impicitly)
When I intiated the BPEL process passing multiple values, the API is taking only the first value, ignoring rest of the values.
Any reason, why only the first value is accepted by the API ?
Thanks,
Rapp.If I understand correctly, JPublisher generates a wrapper API for an underlying API that takes a PL/SQL table as an IN parameter. The wrapper will generate and use a SQL nested table as the type for the IN parameter of the wrapper procedure.
The DB adapter DOES support nested tables, varrays, and objects as IN parameters of an API. The problem you are seeing is most likely due to the way you are modeling your BPEL process, specifically with respect to your Assign activities.
When you Assign TO an IN parameter, make sure that you drill down all the way and choose the parameter name in the InputParameters root element. Similarly, when you Assign FROM the API value, you must drill down and choose the name of the OUT parameter in the OutputParameters root element.
In a Transform activity, you would use the FOR construct on the target side to get the values of the nested table or varray from the source side. -
How to pass a internal table into Java Bean
Hi Experts,
I created a JSPDyn page to display Sales orders form R/3 using bapi_sales_order_getlist.
I used JCO to establish connectivity between JSP Dynpage and R/3. I executed the bapi successfully, i want to move the sales orders retrieved from the Bapi to a Java Bean. So that i can use the bean to populate the value as a table.
with regards,
James.
Valuable answers will be rewarded.....Hi Bala,
If you want to pass this internal table between different methods of the same view then write the contents of this internal table to a context node of your view using BIND_TABLE. You can then read the contents of this internal table from the other method using the reference of that node & the GET_STATIC_ATTRIBUTES_TABLE method.
However if you want to pass the internal table between methods of different views then create a context node at the COMPONENTCONTROLLER level & then do a context mapping of this node to your local views context in both your views. You can follow the same BIND_TABLE & GET_STATIC_ATTRIBUTES_TABLE methods approach.
Regards,
Uday -
How can i pass multiple values by a single variable to EXECUTE IMMEDIATE
Hi All,
I want to pass multiple values for where condition for execute immediate. Something Like this:-
bold
Declare
v_cond varchar(1000);
Begin
v_cond := '''INR','USD'''; --(OPTION 1)
v_cond := 'INR,USD'; --(OPTION 2)
EXECUTE IMMEDIATE 'Delete from table where colm in (:v_cond)' using v_cond;
END;
bold
I am using this into a procedure
Now option 1 gives an error ie a syntax error (; expected or something like that)(I am sorry, i can't tell the exact error here as i am not in the office right now)
and option 2 makes the procedure execute but obviously doesn't delete the records, as it takes the whole as one.
Please Help
Regards
Neeraj BansalSee the links containing examples under
*7. List of values in an IN clause?*
SQL and PL/SQL FAQ
from the SQL and PL/SQL FAQ. -
Returning (bulk collect) clause with execute immediate
db version 11.1.0.7
trying to do a returning bulk collect but it is not working:
-- my test table
create table t as
with f as (select rownum rn from dual connect by rownum <= 10)
select
rn,
lpad('x',10,'x') pad
from f;
-- works as expected
declare
type aat is table of t%rowtype;
aay aat;
begin
delete from t returning rn,pad bulk collect into aay;
rollback;
end;
-- but the table I really want to do has many columns so I want to dynamically build list of columns for the
-- returning clause. This way if the table changes the stored proc will not have to be modified
-- fails PLS-00429: unsupported feature with RETURNING clause
declare
type aat is table of t%rowtype;
aay aat;
s varchar2(4000);
begin
s := 'delete from t returning rn,pad into :1';
execute immediate s returning bulk collect into aay;
rollback;
end;
-- tried a few other things:
create or replace type t_obj as object (rn number,pad varchar2(10));
-- PLS-00497: cannot mix between single row and multi-row (BULK) in INTO list
declare
nt t_obj;
s varchar2(4000);
begin
s := 'delete from t returning t_obj(rn,pad) into :1';
execute immediate s returning bulk collect into nt;
rollback;
end;
-- works, but would require store proc changes if the table changes
declare
type t is table of number;
type v is table of varchar2(10);
vt v;
nt t;
s varchar2(4000);
begin
s := 'update t set rn = 10 returning rn,pad into :1,:2';
execute immediate s returning bulk collect into nt,vt;
rollback;
end;
/basically I want to dynamically build the list of columns with all_tab_cols and put the list into the returning clause
but seems like I will have to hard code the column lists. This means whenever the table changes I will have to
modify the store proc .. Any way around this?
ThanksAnd with object type you were almost there. You forgot to create table of objects type:
SQL> create or replace type t_obj as object (rn number,pad varchar2(10));
2 /
Type created.
SQL> declare
2 type aat is table of nt;
3 aay aat;
4 s varchar2(4000);
5 begin
6 s := 'delete from t returning
SQL> declare
2 type aat is table of t_obj;
3 aay aat;
4 s varchar2(4000);
5 begin
6 s := 'delete from t returning t_obj(rn,pad) into :1';
7 execute immediate s returning bulk collect into aay;
8 rollback;
9 end;
10 /
PL/SQL procedure successfully completed.
SQL> SY. -
Passing pl/sql table to Java using Oracle JDBC and vice - versa
A small article on the given topic with sample code and comments, to make code crystal:
http://mukx.blogspot.com/2007/12/passing-plsql-table-to-java-using.html
--MukulTapash,
I have seen people using Rosetta in almost all projects in previous years, frequently in couple of projects. I was not aware that Rosetta is an internal thing, anyways if that is the case y oracle is shipping rosetta jar file to customers?
--Mukul -
Passing Pl/Sql variables into shell variables.
I have written a file that ftp information from one pc to another in unix.
All you have to do is supply a user_name/password and machine name to which ftp program will connect to.
All connection information like user_id,password, machine name are stored in an oracle table FTP_TBL.
It has the following fields:
FTP_TBL
================
USER_ID NOT NULL VARCHAR2(100);
USR_PASSWD NOT NULL VARCHAR2(50);
TO_MACHINE NOT NULL VARCHAR2(50);
I have called a pl/sql script in unix shell.
This script selects all the connection information from FTP_TBL and populates the pl/sql variables with the
information.
Now i want the pl/sql variables like V_TO_MACHINE,V_USR_ID,V_USR_PASSWD to be passed on to unix variables
To_MACHINE, USR_ID AND USR_PASSWD.
How can i do this?
============================================================================================================
sqlplus -s <<+++ >> $LOG_FILE
$USER/$PASSWD
set serverout on SIZE 1000000
DECLARE
V_TO_MACHINE VARCHAR2(100);
V_USR_ID VARCHAR2(50);
V_USR_PASSWD VARCHAR2(50);
BEGIN
BEGIN
SELECT TO_MACHINE, USER_ID, USR_PASSWD
INTO V_TO_MACHINE,V_USR_ID,V_USR_PASSWD
FROM FTP_TBL;
EXCEPTION
when others then
dbms_output.put_line('ERROR|SQLPLUS|'||ERROR||'|'||sqlcode||'|Failed during selecting configuration information.'||sqlerrm );
END;
END;
+++
#======================== VARIABLES =====================
TO_MACHINE=$1
USR_ID=$2
USR_PASSWD=$3
#========================== MAIN ========================
ftp -vnd $TO_MACHINE << ++ 1>>$STA_LOG_FILE 2>&1
user $USR_ID $USR_PASSWD
prompt off
get $OR_DATA_DIR/ASC.STADATA $HOME_DIR/ASC.STADATA
bye
++
# testing the exit status of FTP
egrep "Transfer complete" $STA_LOG_FILE >/dev/null
if [ $? = 0 ]
then
echo >> $STA_LOG_FILE
echo "FTP Successfully Done" >> $STA_LOG_FILE
else
echo >> $STA_LOG_FILE
echo "FTP UnSuccessfull" >> $STA_LOG_FILE
exit 1
fiHere an example of how to pass variables to the shell script :
TEST@db102 SQL> select ename, job, dname from emp,dept
2 where empno = 7902
3 and emp.deptno = dept.deptno;
ENAME JOB DNAME
FORD ANALYST RESEARCH
TEST@db102 SQL> exit
Disconnected from Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production
With the Partitioning, OLAP and Data Mining options
[ora102 work db102]$ cat disp_var.sh
set `sqlplus -s test/test << EOF
set pages 0
select ename, job, dname from emp,dept
where empno = 7902
and emp.deptno = dept.deptno;
exit
EOF`
echo $1 $2 $3
[ora102 work db102]$ ./disp_var.sh
FORD ANALYST RESEARCH
[ora102 work db102]$ -
Using RETURNING clause with Execute Immediate
I wrote a query to update a table and return the column in to a nested table type variable using returning clause but its not working I am getting error like
ORA-06550: line 66, column 22:
PLS-00306: wrong number or types of arguments in call to '||'
ORA-06550: line 66, column 4:
PL/SQL: Statement ignored
I am getting error in following part of my query
|| 'RETURNING if_row_status bulk collect INTO '
|| v_if_row_status;
v_if_row_status is defined as -
TYPE v_count IS TABLE OF varchar2(50) INDEX BY BINARY_INTEGER;
v_if_row_status v_count;I am trying to update a table for diffrent column if they are null and want no of column updated for each column.
I wrote following query but I am not getting the correct output.
UPDATE
Temp_Bulk_Col_POC
SET if_row_status = 'VALIDATED',
if_row_processed_date = sysdate,
if_row_error_msg =
CASE
WHEN record_type IS NULL
THEN 'RECORD_TYPE is a required column and cannot be NULL'
WHEN source_system IS NULL
THEN 'SOURCE_SYSTEM is a required column and cannot be NULL'
WHEN record_company IS NULL
THEN 'RECORD_COMPANY is a required column and cannot be NULL'
WHEN record_system IS NULL
THEN 'RECORD_SYSTEM is a required column and cannot be NULL'
WHEN txn_flag IS NULL
THEN 'TXN_FLAG is a required column and cannot be NULL'
WHEN create_date IS NULL
THEN 'CREATE_DATE is a required column and cannot be NULL'
WHEN UPDATE_date IS NULL
THEN 'UPDATE_DATE is a required column and cannot be NULL'
WHEN source_customer_id IS NULL
THEN 'SOURCE_CUSTOMER_ID is a required column and cannot be NULL'
WHEN source_product_id IS NULL
THEN 'SOURCE_PRODUCT_ID is a required column and cannot be NULL'
WHEN az_product_id IS NULL
THEN 'AZ_PRODUCT_ID is a required column and cannot be NULL'
WHEN decile IS NULL
THEN 'DECILE is a required column and cannot be NULL'
END
WHERE if_row_status IS NULL
AND (record_type IS NULL
OR source_system IS NULL
OR record_company IS NULL
OR record_system IS NULL
OR txn_flag IS NULL
OR create_date IS NULL
OR UPDATE_date IS NULL
OR source_customer_id IS NULL
OR source_product_id IS NULL
OR az_product_id IS NULL
OR decile IS NULL)
RETURNING if_row_status,record_type,source_system,record_company,record_system,
txn_flag,create_date,UPDATE_date,source_customer_id,source_product_id,az_product_id,
decile
BULK COLLECT INTO
v_if_row_status,v_record_type,v_source_system,
v_record_company,v_record_system,v_txn_flag,v_create_date,v_UPDATE_date,
v_source_customer_id,v_source_product_id,v_az_product_id,v_decile;
its showing same number for all the column.
how I can collect based on the coulmn updated -
PL/SQL WEB Toolkit: Using BUTTON to execute PL/SQL procedure
I am trying to execute a PL/SQL procedure with a "SUBMIT" button from a WEB page. I have several URLs that execute perfectly, but I do not want endusers to have to type the URL themselves. I want to display a web page with multiple URLs in a drop_down list. User chooses a member of the list, clicks the "SUBMIT" buttom and that specific URL executes and produces the proper result. I am NOT a web developer, but this is what I've written sofar:
CREATE OR REPLACE PROCEDURE html_list
IS
BEGIN
HTP.PRINT ('<html>');
HTP.PRINT ('<head>');
HTP.PRINT ('<meta http-equiv="Content-Type" content="text/html">');
HTP.PRINT ('<title>Title of the HTML File</title>');
HTP.PRINT ('</head>');
HTP.PRINT ('<body TEXT="#000000" BGCOLOR="#FFFFFF">');
HTP.PRINT ('<h1>List of Valid URLs</h1>');
HTP.PRINT ('<p>Choose your desired URL from the list below.');
HTP.PRINT ('<FORM method="post" action="WHATEVER_COUNTS_WEB">');
HTP.PRINT ('<FORM method="post" action="REQUEST_OBJECTS?PARAM1=MY_SCHEMA_ID">');
HTP.PRINT ( '<SELECT name="URL">
<option value="http://asai01.ffxlab.net:8080/me_epg_dad/WHATEVER_COUNTS_WEB">Count of Rows in Whatever Tables
<option value="http://asai01.ffxlab.net:8080/me_epg_dad/REQUEST_OBJECTS?PARAM1=ME">Request Objects for MY_SCHEMA_ID
<input type="submit" value="Submit"/>
</SELECT>');
HTP.PRINT ('</FORM>');
HTP.PRINT ('</body>');
HTP.PRINT ('</html>');
END;
Any help would be greatly appreciated. I've been writing PL/SQL code since 1989, but have never had to execute code via a WEB page until this week.
Thanks so muchHi,
Welcome to Oracle Forums!
Please acquaint yourself with the FAQ and forum etiquette if you haven't already done so.
Always post code snippets enclosed in a pair of {code} tags as explained in FAQ
This Forum is dedicated to Oracle Forms. Unfortunately there is no Forum for WebToolKit that I know of. The closest is Oracle Application Express (APEX).
If you objective is to have the User Navigate to the URL clicked then the easiest way is to use anchor tag with href attribute
CREATE OR REPLACE PROCEDURE html_list
IS
BEGIN
HTP.PRINT ('<html>');
HTP.PRINT ('<head>');
HTP.PRINT ('<meta http-equiv="Content-Type" content="text/html">');
HTP.PRINT ('<title>Title of the HTML File</title>');
HTP.PRINT ('</head>');
HTP.PRINT ('<body TEXT="#000000" BGCOLOR="#FFFFFF">');
HTP.PRINT ('<h1>List of Valid URLs</h1>');
HTP.PRINT ('<p>Choose your desired URL from the list below.</p>');
HTP.PRINT ('<a href="http://asai01.ffxlab.net:8080/me_epg_dad/WHATEVER_COUNTS_WEB" target="_blank">Count of Rows in Whatever Tables</a>');
HTP.PRINT('<a "http://asai01.ffxlab.net:8080/me_epg_dad/REQUEST_OBJECTS?PARAM1=ME" target="_blank">Request Objects for MY_SCHEMA_ID</a>');
HTP.PRINT ('<FORM method="post" action="WHATEVER_COUNTS_WEB">');
HTP.PRINT ('<FORM method="post" action="REQUEST_OBJECTS?PARAM1=MY_SCHEMA_ID">');
HTP.PRINT ( '<SELECT name="URL">
<option value="http://asai01.ffxlab.net:8080/me_epg_dad/WHATEVER_COUNTS_WEB">Count of Rows in Whatever Tables
<option value="http://asai01.ffxlab.net:8080/me_epg_dad/REQUEST_OBJECTS?PARAM1=ME">Request Objects for MY_SCHEMA_ID
<input type="submit" value="Submit"/>
</SELECT>');
HTP.PRINT ('</FORM>'); */
HTP.PRINT ('</body>');
HTP.PRINT ('</html>');
END;Change the target attribute to suite your needs. More here http://www.w3schools.com/tags/att_a_target.asp
Or, maybe explore Apex !
Cheers, -
Hi All,
Is it possible to build a dynamic using clause in execute immediate command.
EXECUTE IMMEDIATE <dynamic query> USING <dynamic clause>;
If not, is there any alteranate approach there?
Regards
Swaminathan"there is no such thing as a dynamically generated USING clause."
Ask Tom &quot;Returning cursor from stored procedure u...&quot;
Tom's referring to the following approach as an alternive: http://asktom.oracle.com/pls/asktom/f?p=100:11:::::P11_QUESTION_ID:1288401763279
Maybe you are looking for
-
hi all. I have here a jsp code that generates XML.. how can i save the XML output to file instead of displaying it to the browser? pls. help. thanks. <%@ page contentType="text/xml" %> <?xml version="1.0" encoding="ISO-8859-1"?> <%@ taglib uri="http:
-
Dynamic inmternal table content O/P in BGD ?
Dear All, I've content in my dynamic Internal Table. When I'm trying to print the values of that table on the List the output is not proper . The problem is not with the values but the alignment of each of the column. It's giving some absurd output a
-
Implement Caching across multiple transactions in EJB3.0
Hi, I need to implement caching of entities using JPA in EJB3.0. I am using Jboss 4.2.x for implementing this. The requirement is that the entities remain cached across different method calls. Regards, Deepak Dabas
-
Help With Installing Photoshop CS3 Extended!
After the installation I get the message Component Install Failed. I have uninstalled Google desktop, disabled A/V and Firewall and ran the setup from my HDD. I have ran CCleaner after the uninstallation to clean up the registry. But still the proble
-
Brain-strom Profit Center Question
Hi All, I have a question on "How to Handle Wrong Profit Center from Material" For instance, we have different Profit center for finished goods. We found that, one of the material assigned to a wrong profit center after few month. And that finished g