Logic for inserting values from Pl/sql table
Hi I'm using Forms 6i and db 10.2.0.1.0
I am reading an xml file using text_io, and extracting the contents to Pl/sql table.
Suppose, the xml
<?xml version="1.0" encoding="UTF-8" ?>
<XML>
<File name="S2_240463.201002170044.Z">
<BookingEnvelope>
<SenderID>KNPROD</SenderID>
<ReceiverID>NVOCC</ReceiverID>
<Password>TradingPartners</Password>
</BookingEnvelope>
</File>
</XML>From this xml, i'm extracting contents to a table of records, say bk_arr, which look like
Tag Val
File name S2_240463.201002170044.Z
SenderID KNPROD
ReceiverID NVOCC
Password TradingPartnersAnd now from this i've to insert into table, say bk_det .
The tag may come in different order, sometimes some additional tags may also come in between,
So i cannot access it sequentially and insert like
Insert into bk_det(file,sndr,rcvr,pswd) values(bk_arr(1).val,bk_arr(2).val....)
The tag name is constant ir for sender id, it will always be SenderID , not something like sndrid or sndid etc..
So if i've to insert to senderid column, then i've to match the tag = SenderID, and take the value at that index in the array.
How best i can do this?
Thanks
I am referring to how you are parsing the XML - as you can extract values from the XML by element name. And as the name is known, it's associated value can be inserted easily.
Basic example:
SQL> with XML_DATA as(
2 select
3 xmltype(
4 '<?xml version="1.0" encoding="UTF-8" ?>
5 <XML>
6 <File name="S2_240463.201002170044.Z">
7 <BookingEnvelope>
8 <SenderID>KNPROD</SenderID>
9 <ReceiverID>NVOCC</ReceiverID>
10 <Password>TradingPartners</Password>
11 </BookingEnvelope>
12 </File>
13 </XML>' ) as XML_DOM
14 from dual
15 )
16 select
17 extractValue( xml_dom, '/XML/File/@name' ) as FILENAME,
18 extractValue( xml_dom, '/XML/File/BookingEnvelope/SenderID' ) as SENDER_ID,
19 extractValue( xml_dom, '/XML/File/BookingEnvelope/ReceiverID' ) as RECEIVER_ID,
20 extractValue( xml_dom, '/XML/File/BookingEnvelope/Password' ) as PASSWORD
21 from xml_data
22 /
FILENAME SENDER_ID RECEIVER_I PASSWORD
S2_240463.201002170044.Z KNPROD NVOCC TradingPartners
SQL> Now this approach can be used as follows:
create or replace procedure AddFile( xml varchar2 ) is
begin
insert into foo_files(
filename,
sender_id,
receiver_id,
password
with XML_DATA as(
select
xmltype( xml ) as XML_DOM
from dual
select
extractValue( xml_dom, '/XML/File/@name' ),
extractValue( xml_dom, '/XML/File/BookingEnvelope/SenderID' ),
extractValue( xml_dom, '/XML/File/BookingEnvelope/ReceiverID' ),
extractValue( xml_dom, '/XML/File/BookingEnvelope/Password' )
from xml_data;
end;
/No need for a fantasy called PL/SQL "+tables+".
Similar Messages
-
How to retrieve the values from PL/SQL table types.
Hi Every one,
I have the following procedure:
DECLARE
TYPE t1 IS TABLE OF emp%ROWTYPE
INDEX BY BINARY_INTEGER;
t t1;
BEGIN
SELECT *
BULK COLLECT INTO t
FROM emp;
END;
This procedure works perfectly fine to store the rows of employee in a table type. I am not able to retrieve the values from Pl/SQL table and display it using dbms_output.put_line command.
Can anybody help me please!!!!!
Thanks
Ahmed.You mean, you can't add this
for i in t.first..t.last loop
dbms_output.put_line(t(i).empno||' '||t(i).ename||' '||t(i).job);
end loop;or you can't add this
set serveroutput onor maybe, you are working in third party application where dbms_output is not applicable at all?
You see, not able like very similar it is not working - both are too vague...
Best regards
Maxim -
PL/SQL 10g - Cannot Insert Values from PL/SQL
Hi People,
BACKGROUND (if required):
I'm trying to write a message threading algorithm for uni, I believe it works so far, it's just matching the subjects at the moment I want to expand it to include email addresses but that will be at a later date.
A brief run down, at the moment, a user can generate a list of email addresses to filter the corpus with, these are then inserted (via Java) into the table Sender. These addresses are then used in an IF statement, however they are only used if the table sender is populated. The messges that are identified as threads have their Message ID inserted into another table but they also have their values printed to the DBMS output.
QUESTION:
What I need help with is although the values print out to the DBMS Output after a great deal of time, normally after the DBMS buffer has maxed out (thus the statement ends in error). The values printed are not inserted into the table.
Any help on solving this or optimising if would be greatly appreciated, I'm new to PL/SQL i'm afraid so it's probably a really messy statement.
If this is a badly worded question and I need to supply more information then I gladly will, however i'm not 100% on what information is relevant at the moment.
Below is the statement in question.
Thanks and Regards,
K
LOOP
IF sender_cur1%FOUND THEN
IF sub_One = Sub_two and sub_One_MID != sub_Two_MID and Sub_One_Sender = send_user_cur THEN
INSERT INTO MATCHING_SUB (MID) VALUES (sub_Two_MID);
dbms_output.put_line('MID is: ' || sub_Two_MID);
END IF;
ELSE
IF sub_One = Sub_two and sub_One_MID != sub_Two_MID THEN
INSERT INTO MATCHING_SUB (MID) VALUES (sub_Two_MID);
dbms_output.put_line('MID is: ' || sub_Two_MID);
END IF;
END IF;
Edited by: user8967525 on 01-Mar-2010 07:27
Edited by: user8967525 on 01-Mar-2010 08:08cd,
I will most certainly try.
I have a table of emails that I am attempting to thread by means of comparing the subjects together (for now). However ultimately I want to be able to bring in the recipients as well. However this can be ignored for now.
The main variables from the Messages table are:
MID(number) - 0 - 245000
SENDER(VARCHAR) - Email Address
SUBJECT_CLN6 - VARCAHR - Cleaned email subject.
I am creating two instancs of a cursor that contains the subjects and MID's from Messages. I am then looping through cur1 comparing the value against all values in cur2, this continues until all values in cur1 have been compared against cur2. I use the MID to ensure that I am not comparing the same Message. Furthermore I am also filtering the Emails by Sender (if the table has been populated by the user, via a java applet, otherwise if just uses the subject). The variable Send_User_Cur takes takes its values from the Table called Sender, whilst sub_one_sender takes its values from the column Sender in Messages.
The proposed output of this at the moment is to just have the MID's (and later all the relevant columns, however just for now MID) of all the threaded emails, inserted into the table MATCH_THREAD, such that they can be called upon later for further processing and most likely called from a java applet at some point as well.
I've pasted the entire code below. I understand that it looks a bit messy on the preview and for that I apologise.
Thanks all!
Kev
DECLARE
CURSOR sub_cur1 IS
SELECT MID, Sender, trim(subject_cln6) from MESSAGES;
sub_One MESSAGES.subject_cln6%TYPE;
sub_One_MID MESSAGES.MID%type;
sub_One_Sender MESSAGES.SENDER%type;
CURSOR sub_cur2 IS
SELECT MID, trim(subject_cln6) from Messages;
sub_Two MESSAGES.subject_cln6%TYPE;
sub_Two_MID MESSAGES.MID%type;
CURSOR sender_cur1 IS
SELECT SENDER_ID FROM SENDER;
Send_User_Cur SENDER.SENDER_ID%type;
counter number := 0;
MID_t MESSAGES.MID%TYPE;
i number := 0;
j number := 0;
BEGIN
SELECT count(subject) INTO counter
FROM MESSAGES;
OPEN sub_cur1;
OPEN sub_cur2;
OPEN sender_cur1;
FETCH sub_cur1 INTO sub_One_MID, Sub_One_Sender, Sub_One;
FETCH sender_cur1 INTO Send_User_Cur;
WHILE sub_cur1%FOUND
LOOP
IF sub_cur2%ISOPEN THEN
FETCH sub_cur2 INTO sub_Two_MID, SUB_Two;
dbms_output.put_line('OPEN');
ELSE
OPEN sub_cur2;
FETCH sub_cur2 INTO sub_Two_MID, SUB_Two;
--dbms_output.put_line('OPENED and FETCHED');
END IF;
LOOP
IF sender_cur1%FOUND THEN
IF sub_One = Sub_two and sub_One_MID != sub_Two_MID and Sub_One_Sender = send_user_cur THEN
INSERT INTO MATCH_THREAD (MID) VALUES (sub_Two_MID);
commit;
END IF;
ELSE
IF sub_One = Sub_two and sub_One_MID != sub_Two_MID THEN
INSERT INTO MATCH_THREAD (MID) VALUES (sub_Two_MID);
commit;
END IF;
END IF;
FETCH sub_cur2 INTO sub_Two_MID, SUB_Two;
i := i + 1;
EXIT WHEN i = counter;
END LOOP;
CLOSE sub_cur2;
FETCH sub_cur1 INTO sub_One_MID, Sub_One_Sender, SUB_One;
i := 0;
dbms_output.put_line('sub_One_MID: ' || sub_one_mid);
END LOOP;
CLOSE sub_cur1;
CLOSE sub_cur2;
END; -
Insert value from an interanal table to a table in word
dear all
can anyone tell me how to insert the data from an internal table to the table created in word, i can insert data to the table of word by hard coding it,but finally the data has to come from an internal table, im using OLE concept so code related to that will be highly appreciated. the functionality is the same as ALV gives to excel download,but just in my case it has to be in word,
please help me i m in real need
Regards
SwarnaliHi
If they have the same structure u can use a do cycle:
LOOP AT ITAB_NORMAL.
DO.
ASSIGN COMPONENT SY-INDEX OF STRUCTURE ITAB_NORMAL TO <VALUE_FROM>.
IF SY-SUBRC NE 0. EXIT. ENDIF.
ASSIGN COMPONENT SY-INDEX OF STRUCTURE <DYN_WA> TO <VALUE_TO>.
<VALUE_TO> = <VALUE_FROM>.
ENDDO.
APPEND <DYN_WA> TO <DYN_TABLE>.
ENDLOOP.
If the dynamic table has only certain fields of ITAB_NORMAL, I suppose u have an internal table with the fields of dynamic table (u should use it to generate the dynamic table) so u can loop it instead of DO/ENDO cycle
LOOP AT ITAB_NORMAL.
LOOP AT ITAB_FIELD.
ASSIGN COMPONENT ITAB_FIELD-FIELDNAME OF STRUCTURE ITAB_NORMAL TO <VALUE_FROM>.
ASSIGN COMPONENT ITAB_FIELD-FIELDNAME OF STRUCTURE <DYN_WA> TO <VALUE_TO>.
<VALUE_TO> = <VALUE_FROM>.
ENDLOOP.
APPEND <DYN_WA> TO <DYN_TABLE>.
ENDLOOP.
Anyway u can find out many solutions in SCN, there are many posts with your problem
Max -
How can I insert values from table object into a regular table
I have a table named "ITEM", an object "T_ITEM_OBJ", a table object "ITEM_TBL" and a stored procedure as below.
CREATE TABLE ITEM
ITEMID VARCHAR2(10) NOT NULL,
PRODUCTID VARCHAR2(10) NOT NULL,
LISTPRICE NUMBER(10,2),
UNITCOST NUMBER(10,2),
SUPPLIER INTEGER,
STATUS VARCHAR2(2),
ATTR1 VARCHAR2(80),
ATTR2 VARCHAR2(80),
ATTR3 VARCHAR2(80),
ATTR4 VARCHAR2(80),
ATTR5 VARCHAR2(80)
TYPE T_ITEM_OBJ AS OBJECT
ITEMID VARCHAR2(10),
PRODUCTID VARCHAR2(10),
LISTPRICE NUMBER(10,2),
UNITCOST NUMBER(10,2),
SUPPLIER INTEGER,
STATUS VARCHAR2(2),
ATTR1 VARCHAR2(80),
ATTR2 VARCHAR2(80),
ATTR3 VARCHAR2(80),
ATTR4 VARCHAR2(80),
ATTR5 VARCHAR2(80)
TYPE ITEM_TBL AS TABLE OF T_ITEM_OBJ;
PROCEDURE InsertItemByObj(p_item_tbl IN ITEM_TBL, p_Count OUT PLS_INTEGER);
When I pass values from my java code through JDBC to this store procedure, how can I insert values from the "p_item_tbl" table object into ITEM table?
In the stored procedure, I wrote the code as below but it doesn't work at all even I can see values if I use something like p_item_tbl(1).itemid. How can I fix the problem?
INSERT INTO ITEM
ITEMID,
PRODUCTID,
LISTPRICE,
UNITCOST,
STATUS,
SUPPLIER,
ATTR1
) SELECT ITEMID, PRODUCTID, LISTPRICE,
UNITCOST, STATUS, SUPPLIER, ATTR1
FROM TABLE( CAST(p_item_tbl AS ITEM_TBL) ) it
WHERE it.ITEMID != NULL;
COMMIT;
Also, how can I count the number of objects in the table object p_item_tbl? and how can I use whole-loop or for-loop to retrieve values from the table object?
Thanks.Sigh. I answered this in your other How can I convert table object into table record format?.
Please do not open multiple threads. It just confuses people and makes the trreads hard to follow. Also, please remember we are not Oracle employees, we are all volunteers here. We answer questions if we can, when we can. There is no SLA so please be patient.
Thank you for your future co-operation.
Cheers, APC -
While inserting values from a xml file into the database.
Dear Forum Members,
While using Samp10.java (given in XSU!2_ver1_2_1/oracleXSU12/Sample)for inserting values from xml file Sampdoc.xml into database table xmltest_tab1,the error shown below appears on the DOS prompt.
The code for sam10 is:
import oracle.xml.sql.dml.*;
import java.sql.*;
import oracle.jdbc.driver.*;
import oracle.jdbc.*;
import java.net.*;
public class samp10
public static void main(String args[]) throws SQLException
String tabName = "xmltest_tab1";
String fileName = "sampdoc.xml";
try{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection conn=DriverManager.getConnection("jdbc:odbc:BookingSealinerScott","scott","tiger");
OracleXMLSave sav = new OracleXMLSave(conn, tabName);
URL url = sav.createURL(fileName);
int rowCount = sav.insertXML(url);
System.out.println(" successfully inserted "+rowCount+
" rows into "+ tabName);
conn.close();
}catch (Exception e){e.printStackTrace();}
The Structure of Sampdoc.xml is:
<?xml version="1.0"?>
<ROWSET>
<ROW num="1">
<EMPNO>7369</EMPNO>
<ENAME>SMITH</ENAME>
<JOB>CLERK</JOB>
</ROW>
<ROW num="2">
<EMPNO>7499</EMPNO>
<ENAME>ALLEN</ENAME>
<JOB>SALESMAN</JOB>
</ROW>
<ROW num="3">
<EMPNO>7521</EMPNO>
<ENAME>WARD</ENAME>
<JOB>SALESMAN</JOB>
</ROW>
</ROWSET>
Description of table xmltest_tab1 is:
SQL> desc xmltest_tab1;
Name Null? Type
EMPNO NUMBER(4)
ENAME CHAR(10)
JOB VARCHAR2(9)
Error Displayed is:
A nonfatal internal JIT (3.00.078(x)) error 'Structured Exception(c0000005)' has
occurred in :
'oracle/xml/sql/dml/OracleXMLSave.cleanLobList ()V': Interpreting method.
Please report this error in detail to http://java.sun.com/cgi-bin/bugreport.cgi
oracle.xml.sql.OracleXMLSQLException: sun.jdbc.odbc.JdbcOdbcConnection
at oracle.xml.sql.dml.OracleXMLSave.saveXML(OracleXMLSave.java:1967)
at oracle.xml.sql.dml.OracleXMLSave.saveXML(OracleXMLSave.java:1880)
at oracle.xml.sql.dml.OracleXMLSave.insertXML(OracleXMLSave.java:1013)
at samp10.main(samp10.java:36)
Press any key to continue . . .
Please send me the solution as soon as possible.
Thanks,
Waiting for your Reply,
Bye,
Vineet Choudhary
Email id: [email protected]
nullGo and read about JDBC. You need to know some basics before asking such a st&*id questions.
Paul -
The best way to insert values in a Nested Table
Hi!
I want to insert values from a SQL-query in a Nested Table.What's the best way to do it?
In addition,the only way that I've found is doing a query and when I've got the query result I insert it into the Nested Table.For instance:
FOR cur_row IN (SELECT id,nstreet from example Where id=3) LOOP
--here I'm inserting the values of the query in the nested table.
-- VarNestedTable is a Nested Table of Row_Type.
--Row_Type is an object with two fields:Id,Nstreet
VarNestedTable.extend;
VarNestedTable(Coincidents.Last):= Row_type(cur_row.id,cur_row.nstreet);
END LOOP;How to Use Tables: Creating a Table Model.
very bad example:
class DataObject {
String name, age, numberOfMonkeys;
class DOTableModel extends AbstractTableModel {
final String[] COLUMN_HEADER = { "Name", "Age", Monkeys" };
List dataObjects;
public String getColumnName(int column) {
return COLUMN_HEADER[ column ];
public int getRowCount() {
return dataObjects.size();
public int getColumnCount() {
return COLUMN_HEADER.size();
public Object getValueAt(int row, int column) {
DataObject do = dataObject.get( row );
switch( column ) {
case 0: return do.name;
case 1: return do.age;
case 2: return do.numberOfMonkeys;
} -
Inserting values from a PL SQL table to a database table
Hi,
Here is my dilemma.
I have values inserted to a pl sql table which I have gathered from a web page. Now I need to add these same values to a database table. I see the values as 1-'AA', 2='BB' etc.
I use the following code to insert to a outside table in the database and it seems to be crashing.
for i in app_table.first .. app_table.last loop
r_convention(i).priority_country_code:=app_table(i);
insert into test_countries
values (test_seq,tion(i).r_convention(i).priority_country_code);
commit;
end loop;
WHen I run this code I see the values. But it goes to the first value and then crashes and does not go through the
rest of the values. What am I missing here?
Thanks!Hi,
Why can't you directly insert into the table from the object type....
for i in app_table.first .. app_table.last loop
r_convention(i).priority_country_code:=app_table(i);
insert into test_countries
values (test_seq,app_table(i));
commit;
end loop;Can you give me your complete code, so that we can have a better picture..
Edited by: plsql dev on Sep 10, 2010 10:14 PM -
Reading Data from a SQL table to a Logical file on R/3 appl. Server
Hi All,
We would like to create Master Data using LSMW (direct Input) with source files from R/3 Application Server.
I have created files in the'/ tmp/' directory however I do not know how to read data from the SQL table and insert it into the logical file on the R/3 application server.
I am new to ABAP , please let me know the steps to be done to acheive this .
Regards
- AjayHi,
You can find lot of information about Datasets in SCN just SEARCH once.
You can check the code snippet for understanding
DATA:
BEGIN OF fs,
carrid TYPE s_carr_id,
connid TYPE s_conn_id,
END OF fs.
DATA:
itab LIKE
TABLE OF fs,
w_file TYPE char255 VALUE 'FILE',
w_file2 TYPE char255 VALUE 'FILE2'.
SELECT carrid connid FROM spfli INTO TABLE itab.
OPEN DATASET w_file FOR OUTPUT IN TEXT MODE ENCODING DEFAULT. "Opening a file in Application
" Server to write data
LOOP AT itab INTO fs.
TRANSFER fs TO w_file. "" Writing the data into the Application server file
ENDLOOP.
CLOSE DATASET w_file.
OPEN DATASET w_file FOR INPUT IN TEXT MODE ENCODING DEFAULT. "Opening a file in Application
" server to read data
FREE itab.
DO.
READ DATASET w_file INTO fs.
IF sy-subrc EQ 0.
APPEND fs TO itab.
OPEN DATASET w_file2 FOR APPENDING IN TEXT MODE ENCODING DEFAULT. "Appending more data to the file in the
" application server
TRANSFER fs TO w_file2.
CLOSE DATASET w_file2.
ELSE.
EXIT.
ENDIF.
ENDDO.
Regards
Sarves -
*Urgent*How to insert data from MS SQL to the table that create at the adobe form?
Hi,
I'm using Adobe life cycle designer 8 to do my interactive form. I would like to ask how to insert data from MS SQL to the table that i have created in my adobe interactive form?
I really need the information ASAP as i need to hand in my project by next week... i really appreciate any one who reply this post.
ThanksTou need to do a couple of things
1. On the Essbase server, set up an odbc system connection to your MySQL database
2. In the load rule , go to the file menu and select open SQL data source and in the data source put in your SQL statement . A couple of hints. Where it says Select, don't put in the word select and where it say from don't put in from. The system adds them for you. The easiest way ti enter a SQL statement is to do it all in the select area So if your SQL would normanlly say select * from mytable just enter the code as * from mytable in the select area
The click ol/retrieve and enter in your connection info. Itshould bring data back into the load rule. Save the load rule and use it -
Thanks for answer to my first question. Now I have another problem.
Is there any way to print a report based on virtual table, which is created during some Pl/SQL procedure and can't be easily decribed by Select statementSELECT FROM PL/SQL TABLE IN ORACLE REPORTS 6I
The requirement is to populate a table and then select from that table in a report. The typical solution is to
populate a database table, but for situations where that is undesirable there is a way to select from a PL/SQL
table.
For example - for each employee we want to populate a PL/SQL table and then select from that table.
I used the following records in the emp table:
INSERT INTO Emp VALUES(123,'Bob','Sales',555,'28-JAN-79',35000,12,30);
INSERT INTO Emp VALUES(321,'Sue','Finance',555,'12-MAY-83',42000,12,10);
INSERT INTO Emp VALUES(234,'Mary','Account',555,'14-AUG-82',33000,12,20);
INSERT INTO Emp VALUES(623,'Joe','Sales',555,'28-JAN-79',35000,12,30);
INSERT INTO Emp VALUES(621,'Jim','Finance',555,'12-MAY-83',42000,12,10);
INSERT INTO Emp VALUES(634,'Jane','Account',555,'14-AUG-82',33000,12,20);
INSERT INTO Emp VALUES(723,'Fred','Sales',555,'28-JAN-79',35000,12,30);
INSERT INTO Emp VALUES(721,'Meg','Finance',555,'12-MAY-83',42000,12,10);
INSERT INTO Emp VALUES(734,'Jill','Account',555,'14-AUG-82',33000,12,20);
=============================================================================================
Step 1: Create a package spec in the report:
PACKAGE pkg_table IS
TYPE t_rec IS RECORD (
field1 NUMBER(6),
field2 VARCHAR2(30));
TYPE t_tab IS TABLE OF t_rec INDEX BY BINARY_INTEGER;
gv_tab t_tab;
FUNCTION populate (
p_empno NUMBER) RETURN NUMBER;
END;
Step 2: Create the package body:
PACKAGE BODY pkg_table IS
FUNCTION populate (
p_empno NUMBER) RETURN NUMBER IS
BEGIN
gv_tab.DELETE;
-- populate table as required - for demo purposes put in anything
FOR lv_ind IN 1..MOD(p_empno,20) LOOP
gv_tab(lv_ind).field1 := lv_ind;
gv_tab(lv_ind).field2 := 'row '||TO_CHAR(lv_ind)||' for emp '||TO_CHAR(p_empno);
END LOOP;
RETURN gv_tab.COUNT;
END populate;
END;
Step 3: Create the master query:
SELECT empno,
ename
FROM emp
Step 4: Add a formula column CF_populate to the master query that does:
function CF_populateFormula return Number is
-- for each emp fetched this formula will repopulate the PL/SQL table
-- and return the number of records in the table
begin
return pkg_table.populate(:empno);
end;
Step 5: Create the detail query:
-- we need to join this to the master and then ensure that for each
-- empno there are as many records fetched as there will be
-- records in the PL/SQL table
SELECT e1.empno,rownum
FROM emp e1, emp e2, emp e3
WHERE rownum <= :CF_populate
Step 6: Add formula columns to the detail query for each of the fields in the
PL/SQL table we want to display:
CF_Field1:
function CF_field1Formula return Number is
begin
return pkg_table.gv_tab(:rownum).field1;
end;
CF_Field2:
function CF_field2Formula return Varchar2 is
begin
return pkg_table.gv_tab(:rownum).field2;
end;
Step 7: Create the repeating frame and layout items to display the formula columns.
=============================================================================================
The same technique can be used to populate a master query. In a report level formula column
CF_Populate populate the PL/SQL table as required. In the master query we just need the rownum:
SELECT rownum
FROM emp, emp, emp
WHERE rownum <= :CF_Populate
Add the formula columns to display Field1 and Field2.
=============================================================================================
Hugh Nelson
26/04/2005 -
Script fails when passing values from pl/sql to unix variable
Script fails when passing values from pl/sql to unix variable
Dear All,
I am Automating STATSPACK reporting by modifying the sprepins.sql script.
Using DBMS_JOB I take the snap of the database and at the end of the day the cron job creates the statspack report and emails it to me.
I am storing the snapshot ids in the database and when running the report picking up the recent ids(begin snap and end snap).
From the sprepins.sql script
variable bid number;
variable eid number;
begin
select begin_snap into :bid from db_snap;
select end_snap into :eid from db_snap;
end;
This fails with the following error:
DB Name DB Id Instance Inst Num Release Cluster Host
RDMDEVL 3576140228 RDMDEVL 1 9.2.0.4.0 NO ibm-rdm
:ela := ;
ERROR at line 4:
ORA-06550: line 4, column 17:
PLS-00103: Encountered the symbol ";" when expecting one of the following:
( - + case mod new not null <an identifier>
<a double-quoted delimited-identifier> <a bind variable> avg
count current exists max min prior sql stddev sum variance
execute forall merge time timestamp interval date
<a string literal with character set specification>
<a number> <a single-quoted SQL string> pipe
The symbol "null" was substituted for ";" to continue.
ORA-06550: line 6, column 16:
PLS-00103: Encountered the symbol ";" when expecting one of the following:
( - + case mod new not null <an identifier>
<a double-quoted delimited-identifier> <a bind variable> avg
count current exists max min prior sql stddev su
But when I change the select statements below the report runs successfully.
variable bid number;
variable eid number;
begin
select '46' into :bid from db_snap;
select '47' into :eid from db_snap;
end;
Even changing the select statements to:
select TO_CHAR(begin_snap) into :bid from db_snap;
select TO_CHAR(end_snap) into :eid from db_snap;
Does not help.
Please Help.
TIA,
NischalHi,
could it be the begin_ and end_ Colums of your query?
Seems SQL*PLUS hs parsing problems?
try to fetch another column from that table
and see if the error raises again.
Karl -
How to insert data from different internal table into a data base table
hi all,
I want to insert a particular field in an internal table to a field in a data base table.Note that the fields in the internal table and database table are not of the same name since i need to insert data from different internal tables.can some one tell me how to do this?
in short i want to do something like the foll:
INSERT INTO ZMIS_CODES-CODE VALUE '1'.
*INSERT INTO ZMIS_CODES-COL1 VALUE DATA_MTD-AUFNR .(zmis_codes is the db table and data_mtd is the int.table)REPORT ZINSERT.
tables kna1.
data: itab LIKE KNA1.
data lv_kUNAG LIKE KNA1-KUNNR.
lv_kuNAG = '0000010223'.
ITAB-kuNNR = lv_kuNAG.
ITAB-name1 = 'XYZ'.
INSERT INTO KNA1 VALUES ITAB.
IF SY-SUBRC = 0.
WRITE:/ 'SUCCESS'.
ELSE.
WRITE:/ 'FAILED'.
ENDIF.
Here lv_kunag is ref to kna1 kunnr passed in different name
In internal table .
Try and let me know if this logic dint work. -
How to Insert data from notepad to Table
Hi,
I have one table with nodata.i need to insert data into table.but i have records in one notepad.if i enter manually
like using insert statement it will take more time.
Any one know insert data from notepad to table or i need sql script that will use for all the records.Here im using sqldeveloper.Hi dude,
We can use below 2 types.
1) Sql loader
2) utl file
SQL*Loader utility?
One can load data into an Oracle database by using the sqlldr (sqlload on some platforms) utility. Invoke the utility without arguments to get a list of available parameters. Look at the following example:
sqlldr username@server/password control=loader.ctl
sqlldr username/password@server control=loader.ctlThis sample control file (loader.ctl) will load an external data file containing delimited data:
load data
infile 'c:\data\mydata.csv'
into table emp
fields terminated by "," optionally enclosed by '"'
( empno, empname, sal, deptno )
{code}
The mydata.csv file may look like this:
{code}
10001,"Scott Tiger", 1000, 40
10002,"Frank Naude", 500, 20
{code}
Optionally, you can work with tabulation delimited files by using one of the following syntaxes:
{code}
fields terminated by "\t"
fields terminated by X'09'
{code}
Additionally, if your file was in Unicode, you could make the following addition.
{code}
load data
CHARACTERSET UTF16
infile 'c:\data\mydata.csv'
into table emp
fields terminated by "," optionally enclosed by '"'
( empno, empname, sal, deptno )Another Sample control file with in-line data formatted as fix length records. The trick is to specify "*" as the name of the data file, and use BEGINDATA to start the data section in the control file:
load data
infile *
replace
into table departments
( dept position (02:05) char(4),
deptname position (08:27) char(20)
begindata
COSC COMPUTER SCIENCE
ENGL ENGLISH LITERATURE
MATH MATHEMATICS
POLY POLITICAL SCIENCEPlease refer the below link.. it will useful for you.
http://psoug.org/reference/sqlloader.html
http://docs.oracle.com/cd/B10500_01/server.920/a96652/ch05.htm
Regards,
N.Senthil. -
Distinct values from dynamic internal tabls
Hi All,
I have a dynamic internal tables like <dy_table> , i want to get distinct values from this internal tables,
how to do that, structure of dynamic internal tables is dynamic acc. to user conditions.
regards,
AnujHi Anuj
Just try this,
CALL METHOD cl_alv_table_create=>create_dynamic_table
EXPORTING
it_fieldcatalog = tb_fields_for_it
IMPORTING
ep_table = gp_dyn_table.
ASSIGN gp_dyn_table->* TO <gt_table>.
ASSIGN LOCAL COPY OF INITIAL LINE OF <gt_table> TO <fs_table>.
LOOP AT tb_output.
*To assign value for serial number.
ASSIGN COMPONENT 1 OF STRUCTURE <fs_table> TO <ls_field>.
<ls_field> = tb_output-sno.
UNASSIGN <ls_field>.
*To assign value for Sales Organization.
ASSIGN COMPONENT 2 OF STRUCTURE <fs_table> TO <ls_field>.
<ls_field> = tb_output-vkorg.
UNASSIGN <ls_field>.
*To assign Rate for its respective Condition type.
LOOP AT tb_konp WHERE knumh = tb_output-knumh.
READ TABLE tb_fieldcat1 WITH KEY fieldname = tb_output-kschl.
IF sy-subrc EQ 0.
lv_count = tb_fieldcat1-col_pos.
ASSIGN COMPONENT lv_count OF STRUCTURE <fs_table> TO <ls_field>.
IF tb_konp-konwa EQ '%'.
tb_konp-kbetr = tb_konp-kbetr / co_10.
<ls_field> = tb_konp-kbetr.
ELSE.
<ls_field> = tb_konp-kbetr.
ENDIF.
ENDIF.
ENDLOOP.
lv_count = lv_count + 1.
APPEND <fs_table> TO <gt_table>.
CLEAR <fs_table>.
ENDLOOP.
Hope this proves helpful to you.
Maybe you are looking for
-
How can I import my home movies (.dv) into iTunes?
I'm getting frustrated with the lack of information about converting movies with all the recent upgrades. I have many short home movies in a variety of formats (.dv, .mov. Mp4, etc) - how in the world can I get them into iTunes (and ultimately on my
-
Why can't I view metadata added in Photoshop CS4 in Windows XP's explorer?
I'm using Photoshop CS4 on Windows XP. I've been editing the Title and Description fields in Photoshop (and yes, I've been saving things). When I try to view the metadata in Photoshop at a later point I can see everything just fine. When I try to
-
Excel Application-defined or object-defined error 32809
This error occurs on files that are received from outside our company network. A file created on our company network, sent to customers (a technical questionnaire) who then complete and return them, no longer works correctly. This occurs when the fil
-
Hi all, Is there possible to display account alias in Journal? The default is Member Name and I can't find how to display the alias. Thanks
-
Install program in special folder
In the CC Desktop App you can select a folder for your CC programs. But there are e few program's, like Lightroom which will not be installed there. How can I solve this problem. But maybe it is en feature request...?