How do I... Read a single SQL record... Without a data grid...
Flash Builder 4 is connected ok to ColdFusion and MySQL via the generative FB CFC.
I'm trying to put the key in the table of users in a TextInput field and click a button [Get] to obtain registration.
protected function get_clickhandler (event. MouseEvent): void
{
getusersResult.token = usersService.getusers (users. USER NAME)
}
Network Monitor indicates that the getusers method works.
Then... I don't know what to do with this thing of token. How to get the data in the record so that FlashBuilder can show it.
Help would be appreciated. Reference information would be appreciated.
Kind regards
-Bill
I just figure that out last week. Here's an example, suppose there is a 'contacts' table with a 'name' and a 'name' a field 'email '...
(1) establish a connection with your SQLite DB if you have not already:
sqlConnection = new SQLConnection(); sqlConnection.open(File.applicationStorageDirectory.resolvePath("yourdbfile.db")); var sql:SQLStatement = new SQLStatement(); sql.sqlConnection = sqlConnection; getAccountInfo();
(2) the information and put them in a table:
var sql:SQLStatement = new SQLStatement(); sql.sqlConnection = sqlConnection; sql.text = "SELECT first_name, last_name, email FROM contacts WHERE id = 1 LIMIT 1;"; sql.execute(); var contactInfo:Array = sql.getResult().data;
3) direct access to the data or assign to variables:
var firstName:String = contactInfo[0].first_name; var lastName:String = contactInfo[0].last_name; var email:String = contactInfo[0].email;
I hope this helps...
Tags: Flash Builder
Similar Questions
-
Mr President.
Any body give me advice step by step that how can I use my pl/sql below procedure to take the small schema oracle backup with a touch of the adf.
DECLARE h1 NUMBER; dt VARCHAR2 (20); myschema VARCHAR2(32):='SCOTT'; BEGIN SELECT TO_CHAR (SYSDATE, 'YYYYMMDD') INTO dt FROM DUAL; h1 := DBMS_DATAPUMP.OPEN (operation => 'EXPORT', job_mode => 'SCHEMA', job_name => myschema||'_EXP_' || dt, VERSION => 'COMPATIBLE' ); DBMS_DATAPUMP.set_parallel (handle => h1, DEGREE => 1); DBMS_DATAPUMP.add_file (handle => h1, filename => myschema||'_EXP.LOG', DIRECTORY => 'ADMIN_DIR', filetype => 3 ); DBMS_DATAPUMP.set_parameter (handle => h1, NAME => 'KEEP_MASTER', VALUE => 0 ); DBMS_DATAPUMP.metadata_filter (handle => h1, NAME => myschema||'_EXPR', VALUE => 'IN('''||myschema||''')' ); DBMS_DATAPUMP.add_file (handle => h1, filename => myschema||'_EXP_' || dt || '.DMP', DIRECTORY => 'DATA_PUMP_DIR', filetype => 1 ); DBMS_DATAPUMP.set_parameter (handle => h1, NAME => 'INCLUDE_METADATA', VALUE => 1 ); DBMS_DATAPUMP.set_parameter (handle => h1, NAME => 'DATA_ACCESS_METHOD', VALUE => 'AUTOMATIC' ); DBMS_DATAPUMP.set_parameter (handle => h1, NAME => 'ESTIMATE', VALUE => 'BLOCKS' ); DBMS_DATAPUMP.start_job (handle => h1, skip_current => 0, abort_step => 0); DBMS_DATAPUMP.detach (handle => h1); END; /
Concerning
Hello world!
It's the simple code to call an appModule procedure
public void callStoreprocedureWithoutInput() { String stmt = "BEGIN\n" + " \"dbBackup\"();\n" + "--rollback; \n" + "END;"; PreparedStatement st = null; try { st = getDBTransaction().createPreparedStatement(stmt, 0); st.executeUpdate(); st.close(); } catch (Exception e) { e.printStackTrace(); } }
Concerning
-
How to extract a value of sql xml column clob data
Hi guys,.
I need help with the following. I have a column with data type xml (clob data). I need to extract the information in the < RI4 > tag and the < RI6 > tag.
I truncated the data, but there is a repetition of the < RI4 > tag and consequenty internal to that tag RI6. However, each tag RI4 and RI6 has different data.I would be grateful if you can help me with this:
<a xsi:schemaLocation="som location.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="urn:somlocation"> <b>Some stuff here</b> <c> <someinfo>blah</someinfo> <someinfo2>blah2</someinfo2> </c> <EffectiveDateTime>2015-10-01T00:00:00+10:00</EffectiveDateTime> <CurrencyCode>AUD</CurrencyCode> <RequiredInformation> <RequiredInformation2> <RequiredInformation3> <RI4>someinfo</RI4> <RI5> <RI6> <a1>1</a1> <b1>9.13</b1> </RI6> <RI6> <a1>2</a1> <b1>8.75</b1> </RI6> <RI6> <a1>3</a1> <b1>78.90</b1> </RI6> <RI6> <a1>4</a1> <b1>200</b1> </RI6> <RI6> <a1>5</a1> <b1>17.59</b1> </RI6> </RI5> </RequiredInformation3> </RequiredInformation2> </RequiredInformation> </a>
I think that since it's the repetition I might need to make some sort of PL/SQL programming, but I really need help here to build this announcement also a way to extract the information.
Any help would be greatly appreciated.
Kind regards
You can parse your XML like this
SQL> with t 2 as 3 ( 4 select 5 ' 6 Some stuff here 7
8 11blah 9blah2 102015-10-01T00:00:00+10:00 12AUD 1314 42 ' xml_str 43 from dual 44 ) 45 select t1.ri4, t2.a1, t2.b1 46 from t 47 , xmltable 48 ( 49 xmlnamespaces(default 'urn:somlocation', 'http://www.w3.org/2001/XMLSchema-instance' as "xsi") 50 , '/a/RequiredInformation/RequiredInformation2/RequiredInformation3' passing xmltype(t.xml_str) 51 columns 52 ri4 varchar2(10) path 'RI4' 53 , ri5 xmltype path 'RI5' 54 ) t1 55 , xmltable 56 ( 57 xmlnamespaces(default 'urn:somlocation') 58 , '/RI5/RI6' passing t1.ri5 59 columns 60 a1 number path 'a1' 61 , b1 number path 'b1' 62 ) t2; RI4 A1 B1 ---------- ---------- ---------- someinfo 1 9.13 someinfo 2 8.75 someinfo 3 78.9 someinfo 4 200 someinfo 5 17.59 SQL>15 4116 40someinfo 1718 3919 221 209.13 2123 262 248.75 2527 303 2878.90 2931 344 32200 3335 385 3617.59 37 -
How to upgrade more than 5 million records without error ORA-00257:
Hello
I need to update some of the columns in my table which is contains approximately 5 million records
I already tried this
Update AAA_CDR
Set RoamFload = Null;
but the problem is that I have the error message ("ORA-00257: archiver error.") Connect internal only, until this that released.) and the update consume about 6 hours with no results,
can I make orders (Alter system set db_recovery_file_dest_size = 50G) and the problem resolved.
but I need to be updated about 15 columns of this table to be null, what should I do to overcome this message and update the table within a reasonable
Please help me,Hello
You can consider the following option.
1. create a new table AAA_CDR_BKP as being equal to the structure of table AAA_CDR
Create Table AAA_CDR_BKP as Select * from AAA_CDR where 1=2;
2. check the original array (AAA_CDR) as of the clues in this regard. Make sure you take the DDL of these indices, because you will need it later.
3. now you can insert records from AAA_CDR to AAA_CDR_BKP
Insert /*+APPEND */ into AAA_CDR_BKP select col1,col2,col3,null,null,null,null,null,col9,null,col11 from AAA_CDR; Commit;
where you will pass nulls for the required columns. Also make sure you have space on the tablespace as equal to table AAA_CDR
You can get the size of the table in
select bytes/(1024*1024*1024) size_in_GB from user_segments where segment_name = 'AAA_CDR';
Once finished insert please post the transaction.
4 delete the index (if any) of the original table (AAA_CDR)
5. rename the original in AAA_CDR_ORG table
6. Rename AAA_CDR_BKP to AAA_CDR
7 run the DDL scripts on step 2 to re-create the index.
8. delete the AAA_CDR_ORG table after investigating the whole operation.Using this method, you'll generate less archive logs and the process will be faster.
See you soon
LIX. -
Single SQL query for the analysis of the date of customs declaration under the table of Stock codes
Dear all,
Please tell us a single SQL query for the below,
We have a Table of Stock as shown below,
STOCK_TABLE
ITEM_CODE
(item code)
BAT_NO
(lot no.)
TXN_CODE
(transaction code)
DOC_NO
(number)
BOE_DT
(date of the customs declaration)
I1
B1
I1
I2
I3
B70
I4
B80
I5
B90
T102
1234
JULY 2, 2015
I6
B100
We have to find the date of customs declaration (i.e. the date when the items have come under this particular table) for items that are not attached to any document (that is, who have TXN_CODE, DOC_NO and BOE_DT fields with a NULL value).
For each item in the table of actions, which is not attached to any document, the customs declaration date is calculated as follows.
- If (code section, lot number) combination is present under HISTORY_TABLE, the date of customs declaration will receive the UPDT_DT, the transaction code (TXN_CODE) is an IN or transactions (which can be analyzed from the TRANSACTIONS table).
- If (code section, lot number) combination is NOT currently at the HISTORY_TABLE (or) the transaction code respective to item - batch number combination code is an operation then customs declaration date will be the date of the document (DOC_DT) that we receive from one of the 3 tables IN_TABLE_HEAD that contains the element of that particular lot.
- If the case 1 and case 2 fails, our customs declaration date will be the last date of document (DOC_DT) that we receive from one of the 3 tables IN_TABLE_HEAD containing that particular item and the BAT_NO in expected results will be that corresponding to this document, as appropriate, to another NULL.
- If the case 1 or case 2 is successful, the value of the last field (in the output expected, shown further below) BATCH_YN will be 'Y', because it fits the lot. Otherwise it will be 'n'.
-
How to run DBMS_SQLTUNE.report_sql_monitor of SQL Developer 4.0
Hello-
We have new SQL Developer 4.0 as a single stop for all reports of performance tuning.
(So far, we know how to generate the AWR and ASH ADDM directly from SQL DEV 4.0 and we can do as a NON-privileged user)
Now, the question is how to run DBMS_SQLTUNE.report_sql_monitor API SQL DEV 4.0?
I tried this way:
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
SELECT DBMS_SQLTUNE.report_sql_monitor)
sql_id = >: SQL_ID
Type = > 'TEXT ',.
report_level = > 'ALL') AS myreport
DOUBLE;
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
and then right button click of the mouse on the line "myreport" and the EXPORT of 'text' in the menu drop down and save in the. FichierTSV on the local file system.
It works this way, as expected, but seems to be a lot of hassle: too many steps.
Then I tried the HTML format:
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
SELECT DBMS_SQLTUNE.report_sql_monitor)
sql_id = >: SQL_ID
Type = > 'HTML. "
report_level = > 'ALL') AS myreport
DOUBLE;
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
and it didn't work well at all SQL dev 4.0
Any help will be greatly appreciated.
(once again, the idea here is to set up our development and QA groups with full access to performance all reports without having them call DBA for help in the production of any SQL tuning report).
Thank you
VR
There is certainly a 'room' to improve the interface, just tell me what you would like to be like him. For example, you want an overview of the SGS of all SQLIDs running on the nodes you could then select this option to run a report for? Don't say it is what we would do, but I was wondering what it is that you ask for.
-
Reading BLOB to SQL Server 2005 using DB Oracle 10 g Link
Hi all
I'm reading the data from a table in SQL Server 2005 by using ODBC DB link created in Oracle database 10 g (10.2.0.3/4). I do not use oracle gateway.
I am able to read all the data except data BLOB of SQL server 2005. It gives an below error when I try to run the query SELECT * from T_TRANSACTION_DATA@sdeslink within a stored procedure:
ORA-22992: cannot use LOB Locators selected remote tables
Kindly help how to read BLOB from SQL server 2005 within Oracle 10 g.
Best regards!
IrfanIrfan,
In fact, you hit a restriction of RDBMS and is not a problem HSODBC. You will get the same error if you try to select a BLOB in a remote Oracle database.
There are workrounds, but you must first verify that you can select the remote blob using SQLPLUS as there are some restrictions on the types of data that can be managed by HSODBC.
What is the data type of the column in SQL * Server can you select using SQLPLUS?The other point is that 10.2 HSODBC was desupported for awhile and you need to install and use the replacement product that is the 11g database for ODBC (DG4ODBC) gateway.
Kind regards
Mike -
How to validate that a single check box is checked in detail block
Hi all
I am using oracle 10 G on windows forms.
I need help on how to validate that a single checkbox is checked in the retail block. I have multiple records in the block of detail and I have checkboxes for each record in the detail block.
I have a button to select values in the detail records where the check box is checked. But I want to make sure that only one record is not more than one check.
How to validate this on a shutter release button?
Thank youWhen I did this sort of thing, I create a variable of TYPE number form level and then add or subtract the variable I to check and uncheck the boxes. If the value of the variable is 1, then you know that only check box is selected. If the value is greater than 1, then you know that the user has selected more than one checkbox. You could also add the code to your trigger when-box-changed to test the variable and tell the user to uncheck selected record before selecing a new record.
Regarding the variable level of form, you can use a GLOBAL package specification, PARAMETER or program unit. I prefer to use the specification of CENTRAL unit package, because this method has a smaller memory footprint. For example, in the node of the unity of the object browser program create the following:
/* Form variables package spec */ PACKAGE Form_Vars IS CheckBox_Cnt NUMBER := 0; END;
Now in your trigger when-box-change...
BEGIN IF ( Form_Vars.CheckBox_Cnt = 0 ) THEN Form_Vars.CheckBox_Cnt := Form_Vars.CheckBox_Cnt + 1; ELSE /* it's assumed the value is greater than 0 */ Message('Please uncheck selec ted record before choosing a new record.'); RAISE Form_Trigger_Failure; END IF; END;
Hope this helps,
Craig B-)If someone useful or appropriate, please mark accordingly.
Published by: Silvere on February 3, 2011 10:15
-
Return lines for pl - sql record type
We have a requirement to create the function that returns the java application cursor. This slider will have data of type pl - sql record.
Tried with function in pipeline. I wrote the code below.
Copy the following code returns no data found exceptional function. How to achieve outcome 1 and test1 on top of code?CREATE or replace PACKAGE test_pkg IS TYPE tp_rec IS RECORD(tt_id INTEGER,tt_text VARCHAR2(40)); TYPE obj_tp_recs IS TABLE OF tp_rec; TYPE obj_tp_recs1 IS TABLE OF tp_rec; FUNCTION test_func RETURN tp_rec; function type_out return obj_tp_recs1 PIPELINED; PROCEDURE test_type (result out sys_refcursor); END; / CREATE OR REPLACE PACKAGE BODY OMS.test_pkg IS FUNCTION test_func RETURN tp_rec AS currec tp_rec; BEGIN currec.tt_id := 1; currec.tt_text := 'test1'; END; FUNCTION type_out RETURN obj_tp_recs1 PIPELINED AS currec1 test_pkg.tp_rec; begin currec1 := test_pkg.test_func; PIPE ROW(currec1); dbms_output.put_line(currec1.tt_id); end; PROCEDURE test_type (result out sys_refcursor) AS BEGIN OPEN RESULT FOR SELECT * FROM TABLE(test_pkg.type_out()); END; END; / SQL> VARIABLE x REFCURSOR SQL> exec test_pkg.test_type(:x); PL/SQL procedure successfully completed. SQL> print x
Thanks in advanceSQL> VARIABLE x REFCURSOR SQL> exec test_pkg.test_type(:x); PL/SQL procedure successfully completed. SQL> print x ERROR: ORA-06503: PL/SQL: Function returned without value ORA-06512: at "SCOTT.TEST_PKG", line 8 ORA-06512: at "SCOTT.TEST_PKG", line 14 no rows selected
If you look at test_func body missing return statement. Now:
SQL> CREATE OR REPLACE PACKAGE BODY test_pkg IS 2 FUNCTION test_func RETURN tp_rec 3 AS 4 currec tp_rec; 5 BEGIN 6 currec.tt_id := 1; 7 currec.tt_text := 'test1'; 8 RETURN currec; 9 END; 10 11 FUNCTION type_out RETURN obj_tp_recs1 PIPELINED 12 AS 13 currec1 test_pkg.tp_rec; 14 begin 15 currec1 := test_pkg.test_func; 16 PIPE ROW(currec1); 17 dbms_output.put_line(currec1.tt_id); 18 end; 19 20 PROCEDURE test_type (result out sys_refcursor) 21 AS 22 BEGIN 23 OPEN RESULT 24 FOR SELECT * FROM TABLE(test_pkg.type_out()); 25 26 END; 27 END; 28 / Package body created. SQL> exec test_pkg.test_type(:x); PL/SQL procedure successfully completed. SQL> print x TT_ID TT_TEXT ---------- ---------------------------------------- 1 test1 SQL>
SY.
-
How can I get a number of records?
I have a dataprovider that points to the results of a query on a SQL database. That is directed to a grid of data. How can I get the number of records in the dataprovider or data grid?
You can try like this,
new XMLList (dataProvider) .length)
-
is it possible or how do I read the XML through PL/SQL?
like how the first name of this XML through PL SQL coding...<?xml version="1.0"?> <company> <employee> <firstname>Tom</firstname> <lastname>Cruise</lastname> </employee> </company>
No need of PL/SQL, SQL is
select t.s.extract ('/company/employee/firstname/text()').getStringVal() from test t
as in
SQL> with test as 2 (select xmltype (' 3
4 ') s from dual) 9 select t.s.extract ('/company/employee/firstname/text()').getStringVal() 10 from test t 11 / T.S.EXTRACT('/COMPANY/EMPLOYEE/FIRSTNAME/TEXT()').GETSTRINGVAL() ------------------------------------------------------------------------------------- Tom SQL>5 8Tom 6Cruise 7 -
How to check null in pl sql values?
Hello
I have a sql query where I read the db column in a number of variables, some columns contain NULL values or empty varchars. How can I check if my variable contains all the data?
Thank you
Jto check to see if your variable contains the value null or use not like that
if v_variable is null
If you are using
if v_variable=NULL
It's just according to the syntax, but it will not give you desired result
SQL> declare 2 v_empname varchar2(20); 3 v_comm number; 4 begin 5 select ename,comm into v_empname,v_comm from emp 6 where empno=7839 and comm is NULL; 7 dbms_output.put_line(v_empname); 8 if v_comm is NULL then 9 dbms_output.put_line(v_empname); 10 end if; 11 end; 12 / KING KING PL/SQL procedure successfully completed.
But if you plan to use = null, then you get no results
SQL> declare 2 v_empname varchar2(20); 3 v_comm number; 4 begin 5 select ename,comm into v_empname,v_comm from emp 6 where empno=7839 and comm is NULL; 7 dbms_output.put_line(v_empname); 8 if v_comm = NULL then 9 dbms_output.put_line(v_empname); 10 end if; 11 end; 12 / KING -------------king will get printed only once. PL/SQL procedure successfully completed.
-
How can I read received automatically
Hello
I recently installed Mozilla thunderbird but I have no idea how to change the signature with a picture and special formats
or how to get read receipts for every mail I send.Help, please.
Thank you and waiting for your response,.
Deborah
Signature:
http://KB.mozillazine.org/signatures _ (Thunderbird)Read receipt:
http://KB.mozillazine.org/Figuring_out_whether_the_recipient_read_your_message -
In Photos, how can I move or copy pictures recorded on a slide show project only, in an album so that I can more easily edit photos, order prints from somewhere that provides same day service, etc.? Thank you.
In Photos, how can I move or copy pictures recorded on a slide show project only, in an album so that I can more easily edit photos, order prints from somewhere that provides same day service, etc.?
In Photos 1.5, you can select all the photos in the Filmstrip of the slide show, and then use the command "file > New Album.
This will create an album on the selected photos.
-
How can I read a pdf with ebook reader Touch samo
How can I read a pdf with ebook reader and where I could put the pdf in the day
> where I could put the pdf in the day
You can put the files on the SD card that can be inserted into the slot for SD card available on the left. Supported file formats are: PDF and EPUB
HISTORY_TABLE
ITEM_CODE | BAT_NO |
TXN_CODE
DOC_NO
UPDT_DT
I1
B1
T1
1234
JANUARY 3, 2015
I1
B20
T20
4567
MARCH 3, 2015
I1
B30
T30
7890
FEBRUARY 5, 2015
I2
B40
T20
1234
JANUARY 1, 2015
TRANSACTION
TXN_CODE | TXN_TYPE |
T1 | IN |
T20 |
OFF
T30
ALL THE
T50
IN
T80
IN
T90
IN
T60
ALL THE
T70
ALL THE
T40
ALL THE
IN_TABLE_HEAD_1
H1_SYS_ID (primary key) | TXN_CODE | DOC_NO |
DOC_DATE
H1ID1
T1
1234
JANUARY 1, 2015
H1ID2
T70
1234
FEBRUARY 1, 2015
IN_TABLE_ITEM_1
I1_SYS_ID |
H1_SYS_ID
(foreign key referencing H1_SYS_ID in IN_TABLE_HEAD_1)
ITEM_CODE
I1ID1
H1ID1
I1
I1ID2
H1ID1
I100
I1ID3
H1ID2
I3
IN_TABLE_BATCH_1
B1_SYS_ID | TXN_CODE DOC_NO (now in IN_TABLE_HEAD_1) | BAT_NO |
B1ID1
T1
1234
B1 / can be empty
B1ID2
T70
1234
B70
IN_TABLE_HEAD_2
H2_SYS_ID (primary key) | TXN_CODE |
DOC_NO
DOC_DATE
H2ID1
T30
4567
FEBRUARY 3, 2015
H2ID2
T60
1234
JANUARY 3, 2015
IN_TABLE_ITEM_2
I2_SYS_ID | H2_SYS_ID (foreign key referencing H2_SYS_ID in IN_TABLE_HEAD_2) | ITEM_CODE |
I2ID1 | H2ID1 |
I1
I2ID2
H2ID1
I200
I2ID3
H2ID2
I2
IN_TABLE_BATCH_2
B2_SYS_ID |
I2_SYS_ID
(foreign key referencing I2_SYS_ID in IN_TABLE_ITEM_2)
BAT_NO
B2ID1
I2ID1
B30 / null
B2ID2
I2ID2
B90
B2ID2
I2ID3
B60
IN_TABLE_HEAD_3
H3_SYS_ID (primary key) | TXN_CODE | DOC_NO | DOC_DATE |
H3ID1 |
T50
1234
JANUARY 2, 2015
H3ID2
T80
1234
JANUARY 3, 2015
H3ID3
T90
1234
JANUARY 4, 2015
H3ID4
T40
1234
AUGUST 5, 2015
IN_TABLE_ITEM_3
I3_SYS_ID |
H3_SYS_ID
(foreign key referencing H3_SYS_ID in IN_TABLE_HEAD_3)
ITEM_CODE
BAT_NO
I3ID1
H31D1
I2
B50
I3ID2
H3ID2
I4
B40
I3ID3
H3ID3
I4
I3ID4
H3ID4
I6
There is no IN_TABLE_BATCH_3
Please find below the expected results.
OUTPUT
ITEM_CODE | BAT_NO | TXN_CODE | DOC_NO |
BOE_DT
BATCH_YN
I1
B1
T1
1234
JANUARY 3, 2015
THERE
I1
B30
T30
7890
FEBRUARY 5, 2015
N
I2
B60
T60
1234
JANUARY 3, 2015
N
I3
B70
T70
1234
FEBRUARY 1, 2015
THERE
I4
T90
1234
JANUARY 4, 2015
N
I6
T40
1234
AUGUST 5, 2015
N
Controls database to create the tables above and insert the records.
CREATE TABLE stock_table()item_code VARCHAR2()80),bat_no VARCHAR2()80),txn_code VARCHAR2()80),
doc_no VARCHAR2 (80), boe_dt DATE );
INSERT EN stock_table
VALUES ('I1', 'B1', '', '', '');
INSERT EN stock_table
VALUES ('I1', '', '', '', '');
INSERT IN stock_table
VALUES ('I2', '', '', '', '');
INSERT EN stock_table
VALUES ('I3', 'B70', '', '', '');
INSERT EN stock_table
VALUES ('I4', 'B80', '', '', '');
INSERT EN stock_table
VALUES ('I5', 'B90', 'T102', '1234', '02-JUL-2015');
INSERT EN stock_table
VALUES ('I6', 'B100', '', '', '');
SELECT *
FROM stock_table
CREATE TABLE history_table()item_code VARCHAR2()80),bat_no VARCHAR2()80),txn_code VARCHAR2()80),
doc_no VARCHAR2 (80), updt_dt DATE );
INSERT IN history_table
VALUES ('I1', 'B1', 'T1', '1234', '03-JAN-2015');
INSERT IN history_table
VALUES ('I1', 'B20', 'T20', '4567', '03-MAR-2015');
INSERT IN history_table
VALUES ('I1', 'B30', 'T30', '7890', '05-FEB-2015');
INSERT IN history_table
VALUES ('I2', 'B40', 'T20', '1234', '01-JAN-2015');
SELECT *
FROM history_table
CREATE TABLE transaction1()txn_code VARCHAR()80),txn_type VARCHAR()80));
INSERT INTO transaction1
VALUES ('T1', 'IN');
INSERT INTO transaction1
VALUES ('T20', 'OUT');
INSERT INTO transaction1
VALUES ('T30', 'ALL');
INSERT INTO transaction1
VALUES ('T40', 'ALL');
INSERT INTO transaction1
VALUES ('T50', 'IN');
INSERT INTO transaction1
VALUES ('T60', 'ALL');
INSERT INTO transaction1
VALUES ('T70', 'ALL');
INSERT INTO transaction1
VALUES ('T80', 'IN');
INSERT INTO transaction1
VALUES ('T90', 'IN');
SELECT *
FROM transaction1
CREATE TABLE in_table_head_1()h1_sys_id VARCHAR2()80) PRIMARY KEY,txn_code VARCHAR2()80),
doc_no VARCHAR2 (80), doc_dt DATE );
CREATE TABLE in_table_head_2()h2_sys_id VARCHAR2()80) PRIMARY KEY,txn_code VARCHAR2()80),
doc_no VARCHAR2 (80), doc_dt DATE );
CREATE TABLE in_table_head_3()h3_sys_id VARCHAR2()80) PRIMARY KEY,txn_code VARCHAR2()80),
doc_no VARCHAR2 (80), doc_dt DATE );
INSERT IN in_table_head_1
VALUES ('H1ID1', 'T1', '1234', '01-JAN-2015');
INSERT IN in_table_head_1
VALUES ('H1ID2', 'T70', '1234', '01-FEB-2015');
INSERT IN in_table_head_2
VALUES ('H2ID1', 'T30', '4567', '03-FEB-2015');
INSERT IN in_table_head_2
VALUES ('H2ID2', 'T60', '1234', '03-JAN-2015');
INSERT IN in_table_head_3
VALUES ('H3ID1', 'T50', '1234', '02-JAN-2015');
INSERT IN in_table_head_3
VALUES ('H3ID2', 'T80', '1234', '03-JAN-2015');
INSERT IN in_table_head_3
VALUES ('H3ID3', 'T90', '1234', '05-JAN-2015');
INSERT IN in_table_head_3
VALUES ('H3ID4', 'T40', '1234', '05-AUG-2015');
CREATE TABLE in_table_item_1()i1_sys_id VARCHAR2()80) PRIMARY KEY,
h1_sys_id VARCHAR2 (80) REFERENCES in_table_head_1()h1_sys_id),item_code VARCHAR2()80));
CREATE TABLE in_table_item_2()i2_sys_id VARCHAR2()80) PRIMARY KEY,
h2_sys_id VARCHAR2 (80) REFERENCES in_table_head_2()h2_sys_id),item_code VARCHAR2()80));
CREATE TABLE in_table_item_3(i3_sys_id VARCHAR2(80) PRIMARY KEY,
h3_sys_id VARCHAR2 (80) REFERENCES in_table_head_3()h3_sys_id),item_code VARCHAR2()80),
bat_no VARCHAR2 (80));
INSERT IN in_table_item_1
VALUES ('I1ID1', 'H1ID1', 'I1');
INSERT IN in_table_item_1
VALUES ('I1ID2', 'H1ID1', 'I100');
INSERT IN in_table_item_1
VALUES ('I1ID3', 'H1ID2', 'I3');
INSERT IN in_table_item_2
VALUES ('I2ID1', 'H2ID1', 'I1');
INSERT IN in_table_item_2
VALUES ('I2ID2', 'H2ID1', 'I200');
INSERT IN in_table_item_2
VALUES ('I2ID3', 'H2ID2', 'I2');
INSERT IN in_table_item_3
VALUES ('I3ID1', 'H3ID1', 'I2','B50');
INSERT IN in_table_item_3
VALUES ('I3ID2', 'H3ID2', 'I4','B40');
INSERT IN in_table_item_3
VALUES ('I3ID3', 'H3ID3', 'I4','');
INSERT IN in_table_item_3
VALUES ('I3ID4', 'H3ID4', 'I6','');
SELECT *
FROM in_table_item_1
SELECT *
FROM in_table_item_2
SELECT *
FROM in_table_item_3
CREATE TABLE in_table_batch_1()b1_sys_id VARCHAR2()80) PRIMARY KEY,
txn_code VARCHAR2 (80), doc_no VARCHAR2 (80), bat_no VARCHAR2 (80));
CREATE TABLE in_table_batch_2()b2_sys_id VARCHAR2()80) PRIMARY KEY,
i2_sys_id VARCHAR2 (80) REFERENCES in_table_item_2()i2_sys_id),bat_no VARCHAR2()80));
INSERT IN in_table_batch_1
VALUES ('B1ID1', 'T1', '1234', 'B1');
INSERT IN in_table_batch_1
VALUES ('B1ID2', 'T70', '1234', 'B70');
INSERT IN in_table_batch_2
VALUES ('B2ID1', 'I2ID1', 'B30');
INSERT IN in_table_batch_2
VALUES ('B2ID2', 'I2ID2', 'B90');
INSERT IN in_table_batch_2
VALUES ('B2ID3', 'I2ID3', 'B60');
Please advise a solution for the same.
Thank you and best regards,
Séverine Suresh
very forced (question subfactoring used to allow easy testing/verification - could work with these test data only)
with
case_1 as
(select s.item_code,
s.bat_no,
h.txn_code,
h.doc_no,
h.updt_dt boe_dt,
cases where s.bat_no = h.bat_no then 'Y' else ' n end batch_yn.
cases where h.txn_code is not null
and h.doc_no is not null
and h.updt_dt is not null
then 'case 1' '.
end refers_to
from (select item_code, bat_no, txn_code, doc_no, boe_dt
of w_stock_table
where bat_no is null
or txn_code is null
or doc_no is null
or boe_dt is null
) s
left outer join
w_history_table h
On s.item_code = h.item_code
and s.bat_no = h.bat_no
and exists (select null
of w_transaction1
where txn_code = nvl (s.txn_code, h.txn_code)
and txn_type in ('IN', 'ALL')
)
),
case_2 as
(select s.item_code,
NVL (s.bat_no, h.bat_no) bat_no.
NVL (s.txn_code, h.txn_code) txn_code.
NVL (s.doc_no, h.doc_no) doc_no.
NVL (s.boe_dt, h.updt_dt) updt_dt.
cases where s.bat_no = h.bat_no then 'Y' else ' n end batch_yn.
cases where h.txn_code is not null
and h.doc_no is not null
and h.updt_dt is not null
then 'case 2'.
end refers_to
from (select item_code, bat_no, txn_code, doc_no, boe_dt
of case_1
where refers_to is null
) s
left outer join
w_history_table h
On s.item_code = h.item_code
and exists (select null
of w_transaction1
where txn_code = nvl (s.txn_code, h.txn_code)
and txn_type in ('IN', 'ALL')
)
and not exists (select null
of case_1
where item_code = h.item_code
and bat_no = h.bat_no
and txn_code = h.txn_code
and doc_no = h.doc_no
and updt_dt = h.updt_dt
)
),
case_31 as
(select s1.item_code,
NVL (S1.bat_no, W1.bat_no) bat_no.
NVL (S1.txn_code, W1.txn_code) txn_code.
NVL (S1.doc_no, W1.doc_no) doc_no.
NVL (S1.updt_dt, W1.doc_dt) updt_dt.
cases where s1.bat_no = w1.bat_no then 'Y' else ' n end batch_yn.
cases where w1.txn_code is not null
and w1.doc_no is not null
and w1.doc_dt is not null
then "case 31'.
end refers_to
from (select item_code, bat_no, txn_code, doc_no, updt_dt, batch_yn, refers_to
of case_2
where refers_to is null
) s1
left outer join
(select i1.item_code, h1.txn_code, h1.doc_no, h1.doc_dt, b1.bat_no
of w_in_table_item_1 i1
inner join
w_in_table_head_1 h1
On i1.h1_sys_id = h1.h1_sys_id
inner join
w_in_table_batch_1 b1
On h1.txn_code = b1.txn_code
and h1.doc_no = b1.doc_no
) w1
On s1.item_code = w1.item_code
),
case_32 as
(select s2.item_code,
NVL (S2.bat_no, W2.bat_no) bat_no.
NVL (S2.txn_code, W2.txn_code) txn_code.
NVL (S2.doc_no, W2.doc_no) doc_no.
NVL (S2.updt_dt, W2.doc_dt) updt_dt.
cases where s2.bat_no = w2.bat_no then 'Y' else ' n end batch_yn.
cases where w2.txn_code is not null
and w2.doc_no is not null
and w2.doc_dt is not null
then "case 32'.
end refers_to
from (select item_code, bat_no, txn_code, doc_no, updt_dt, batch_yn, refers_to
of case_2
where refers_to is null
) s2
left outer join
(select i2.item_code, h2.txn_code, h2.doc_no, h2.doc_dt, b2.bat_no
of w_in_table_item_2 i2
inner join
w_in_table_head_2 h2
On i2.h2_sys_id = h2.h2_sys_id
inner join
w_in_table_batch_2 b2
On i2.i2_sys_id = b2.i2_sys_id
) w2
On s2.item_code = w2.item_code
),
case_33 as
(select s3.item_code,
w3.bat_no,
NVL (S3.txn_code, w3.txn_code) txn_code.
NVL (S3.doc_no, w3.doc_no) doc_no.
NVL (S3.updt_dt, w3.doc_dt) updt_dt.
cases where s3.bat_no = w3.bat_no then 'Y' else ' n end batch_yn.
cases where w3.txn_code is not null
and w3.doc_no is not null
and w3.doc_dt is not null
then "case 33'.
end refers_to
from (select item_code, bat_no, txn_code, doc_no, updt_dt, batch_yn, refers_to
of case_2
where refers_to is null
) s3
left outer join
(select i3.item_code, h3.txn_code, h3.doc_no, h3.doc_dt, i3.bat_no
of w_in_table_item_3 i3
inner join
w_in_table_head_3 h3
On i3.h3_sys_id = h3.h3_sys_id
) w3
On s3.item_code = w3.item_code
)
Select item_code, bat_no, txn_code, doc_no, boe_dt, batch_yn
of case_1
where refers_to is not null
Union of all the
Select item_code, bat_no, txn_code, doc_no, updt_dt, batch_yn
of case_2
where refers_to is not null
Union of all the
Select item_code, bat_no, txn_code, doc_no, updt_dt, batch_yn
from (select item_code, bat_no, txn_code, doc_no, updt_dt, batch_yn,
ROW_NUMBER() over (partition by item_code of updt_dt desc order) rn
from (select item_code, bat_no, txn_code, doc_no, updt_dt, batch_yn
of case_31
where refers_to is not null
Union of all the
Select item_code, bat_no, txn_code, doc_no, updt_dt, batch_yn
of case_32
where refers_to is not null
Union of all the
Select item_code, bat_no, txn_code, doc_no, updt_dt, batch_yn
of case_33
where refers_to is not null
)
)
where rn = 1
ITEM_CODE | BAT_NO | TXN_CODE | DOC_NO | BOE_DT | BATCH_YN |
---|---|---|---|---|---|
I1 | B1 | T1 | 1234 | JANUARY 3, 2015 | THERE |
I1 | B30 | T30 | 7890 | FEBRUARY 5, 2015 | N |
I2 | B60 | T60 | 1234 | JANUARY 3, 2015 | N |
I3 | B70 | T70 | 1234 | FEBRUARY 1, 2015 | THERE |
I4 | - | T90 | 1234 | JANUARY 5, 2015 | N |
I6 | - | T40 | 1234 | AUGUST 5, 2015 | N |
Concerning
Etbin
Maybe you are looking for
-
recover the old data synchronization
Hi all I bought a new laptop, but when I connect anything in sync gets synced so I lost all my passwords!I don't have the key to recovery from the old account to sync. I am able to get my old data sync, which are very important for me. THX
-
Why Firefox 32 suddenly does not recognize a certificate?
Firefox 32 says that https://rcmail.secure.ne.jp/rcmail-05/ is not approved: rcmail. Secure.ne.jp uses an invalid security certificate.The certificate is not trusted because the issuer certificate is unknown.(Error code: sec_error_unknown_issuer) Web
-
Satellite Pro A120 - I need recovery disk
Accidentally all trying to clear up my computer deleted user accounts and so XP has been totally screwed and wouldn't let me in, even the administrator account it says did not exist (which I think is impossible), so I gave up and did a hard drive era
-
In Adobe Captivate 8 exporting a CPVC and CPTX to MP4 video format?Thank you
-
How can I reactivate it Lightroom after upgrade to Windows 10?
I have the plan of photography and it worked very well under Windows 7. After the upgrade to Windows 10? Creative Cloud app works, but she says "Start trial" or "Buy now" next to Photoshop and Lightroom. I tried to connect and again.