Cannot query on a date range (where the date is in a varchar format)
Hi All
Here is my SQL query:
select unique(a.SAP_PO_NUMBER), a.ISSUE_CODE, a.PO_CREATION_DATE
from sspe.vendor_purchase_order a
where a.po_creation_date between to_date('2007-02-01', 'yyyy-mm-dd') and to_date ('2007-08-01', 'yyyy-mm-dd')
and a.ISSUE_CODE like 'OK%'
the po_creation_date field is a varchar(12) field and i get the following error:
ORA-01861: literal does not match format string.
Appreciate any help
Gautam
Try this
<p><font face="Courier New" size="2">select <br>
DISTINCT(a.SAP_PO_NUMBER),<br>
a.ISSUE_CODE,<br>
a.PO_CREATION_DATE<br>
from <br>
sspe.vendor_purchase_order a<br>
where <br>
TO_DATE(a.po_creation_date,'<DATE_FORMAT>')<br>
between<br>
to_date('2007-02-01', 'yyyy-mm-dd') and<br>
to_date('2007-08-01', 'yyyy-mm-dd')<br>
and <br>
a.ISSUE_CODE like 'OK%'<br>
</font></p>
Good Luck
Similar Messages
-
Report with date range where the daily customer receipt profit centre wise
Hi Experts,
Could you please suggest me is there any developed standard report or t-cod eis available with which i can get date range where the daily customer receipt profit centre wise can be obtained............
Thanks in Advance........
Santosh Gupta...Hi:
For this purpose you can develop Z report. There is no such standard report for it. Copy FBL5N to make a Z copy of it and use the table FAGLFLEXA for each document posted in BSEG/BKPF. You can also make use of BTE 1650.
Regards -
How to write a query to select a column where the column value ends with %
Hii people!!
I want to select bag_code where bag_code ends with %, e.g. A2389% from the table bags using the following
query:
select bag_code from bags where bag_id in
(select bag_id from store where store_id = 3266)
and bag_code like '%_%'
Now the problem's it returns all the possible bag codes in the store with store_id 3266.
how should i write such a query?
Abhishek.I could even imagine
SQL> create index r on emp(reverse(ename));
Index created.
SQL> select empno,ename from emp where reverse(ename) like 'T%';
EMPNO ENAME
7788 SCOTT It is too sad that we have to use fbi, since reverse index does exists, but it does not get use for range scan :-(
SQL> create index r on emp(ename) reverse;
SQL> select * from emp where ename like '%T';to tune thomas query, if you are only looking for %, then you could do
where ... decode(substr(bags.bag_code, -1),'%',1) is not null
and
create [bitmap] index fbi_pct on bags(decode(substr(bag_code, -1),'%',1));
Regards
Laurent -
Morning all,
I've just been assigned a report-related project but I have not created much of anything in C# or .Net before!
I was wondering if someone could help me get started. Here are the specifications:
Basically, I am to create an automated report application. I have the query and I will include it further down
in this post. The page is to have a couple blanks to specify the Start Date and End Date and replace those dates in the query, and generate the report. What I need some help on is how to make the SQL query work in the application which I will connect to the
intended database to generate the report (basic I know, but I'm new at this) on Visual Studio 2010. I also need some help on programming the Start Date blank and End Date blank so that what the user types in for those blanks will replace the date fields in
the SQL query, then generate the report with the new dates.
I appreciate the help!
The SQL query and what the dates are replacing:
select
PTH.INST_ID ,
PTH.EMPLOYEE_ID,
DBH.HR_DEDUCTION_AND_BENEFITS_CODE,
replace(DB.DESCRIPTION,',',''),
DB.WITHHOLDING_LIABILITY_ACCOUNT_MASK,
DBH.HR_DEDUCTION_AND_BENEFITS_ID,
DBH.CHECK_DATE,
DBH.CHECK_NO,
DBH.FIN_INST_ACCT_ID,
replace(replace (DBH.COMMENT,CHAR(10),' '),CHAR(13),' '),
DBH.HR_DEDUCTION_AND_BENEFIT_CYCLE_CODE,
DBH.LENGTH,
DBH.EMPLOYEE_COMPUTED_AMOUNT,
DBH.EMPLOYEE_BANK_ROUTING_NUMBER,
DBH.EMPLOYEE_ACCOUNT_TYPE,
DBH.EMPLOYEE_ACCOUNT_NUMBER,
DBH.EMPLOYER_COMPUTED_AMOUNT,
DBH.EMPLOYEE_GROSS_AMOUNT,
DBH.EMPLOYER_GROSS_AMOUNT,
DBH.PAYROLL_EXCLUDE,
PTH.VOID_DATE,
PTH.BATCH_QUEUE_ID,
B.BATCH_CODE,
BQ.FY,
BQ.END_DATE,
BQ.COMMENTS,
BQ.BATCH_CRITERIA_USED,
BP.COLUMN_VALUE,
PTH.REPLACEMENT,
P.LAST_NAME,
P.FIRST_NAME,
P.MIDDLE_NAME
from PY_EMPLOYEE_TAX_HISTORY PTH
INNER JOIN PERSON_EMPLOYEE PE ON
PE.INST_ID=PTH.INST_ID AND
PE.EMPLOYEE_ID=PTH.EMPLOYEE_ID
INNER JOIN PERSON P ON
PE.INST_ID=P.INST_ID AND
PE.PERSON_ID=P.PERSON_ID
LEFT JOIN HR_EMPLOYEE_DEDUCTIONS_AND_BENEFITS_HISTORY DBH ON
PTH.INST_ID=DBH.INST_ID AND
PTH.CHECK_DATE=DBH.CHECK_DATE AND
PTH.CHECK_NO=DBH.CHECK_NO AND
PTH.EMPLOYEE_ID=DBH.EMPLOYEE_ID
LEFT JOIN HR_DEDUCTION_AND_BENEFITS DB ON
DB.INST_ID=DBH.INST_ID AND
DB.HR_DEDUCTION_AND_BENEFITS_CODE=DBH.HR_DEDUCTION_AND_BENEFITS_CODE
LEFT JOIN BATCH_QUEUE BQ ON
PTH.BATCH_QUEUE_ID=BQ.BATCH_QUEUE_ID
LEFT JOIN BATCH B ON
B.BATCH_CODE=BQ.BATCH_CODE
LEFT JOIN BATCH_PARAMETER BP ON
BQ.BATCH_QUEUE_ID=BP.BATCH_QUEUE_ID
AND BP.COLUMN_NAME = 'SUPPRESS_DIRECT_DEPOSIT'
------Please change the WHERE condition for date range of the month you need to run this for.
WHERE PTH.CHECK_DATE >='07/01/2013'
AND PTH.CHECK_DATE <='07/31/2013'
and BQ.BATCH_CODE='BAT_PY_PAYCALC'
and bq.fy=2014
ORDER BY PTH.INST_ID ,
PTH.EMPLOYEE_ID,
DBH.HR_DEDUCTION_AND_BENEFITS_CODE,
DBH.CHECK_DATETry this code. The Server name will be the same name when you use SQL Server Management Studio (SSMS). It is in the login window for SSMS. I assume you are using SQLSTANDARD (not SQLEXPRESS) which is in the connection string in the code
below. I also assume you have remote connection allowed in the database.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using System.Data.SqlClient;
namespace ConsoleApplication1
class Program
const string DATABASE = "Enter Database Name Here";
const string SERVER = "Enter Server Name Here";
static void Main(string[] args)
DateTime startDate = DateTime.Parse("07/01/2013");
string startDateStr = startDate.ToString("MM/dd/yyyy");
DateTime endDate = new DateTime(startDate.Year, startDate.Month + 1, 1).AddDays(-1);
string endDateStr = endDate.ToString("MM/dd/yyyy");
string connStr = string.Format("Server={0}\\SQLSTANDARD;Database={1};Trusted_Connection= True;", SERVER,DATABASE);
string SQL = string.Format(
"select\n" +
" PTH.INST_ID\n" +
",PTH.EMPLOYEE_ID\n" +
",DBH.HR_DEDUCTION_AND_BENEFITS_CODE,\n" +
",replace(DB.DESCRIPTION,',','')\n" +
",DB.WITHHOLDING_LIABILITY_ACCOUNT_MASK\n" +
",DBH.HR_DEDUCTION_AND_BENEFITS_ID\n" +
",DBH.CHECK_DATE\n" +
",DBH.CHECK_NO\n" +
",DBH.FIN_INST_ACCT_ID\n" +
",replace(replace (DBH.COMMENT,CHAR(10),' '),CHAR(13),' ')\n" +
",DBH.HR_DEDUCTION_AND_BENEFIT_CYCLE_CODE\n" +
",DBH.LENGTH\n" +
",DBH.EMPLOYEE_COMPUTED_AMOUNT\n" +
",DBH.EMPLOYEE_BANK_ROUTING_NUMBER\n" +
",DBH.EMPLOYEE_ACCOUNT_TYPE\n" +
",DBH.EMPLOYEE_ACCOUNT_NUMBER\n" +
",DBH.EMPLOYER_COMPUTED_AMOUNT\n" +
",DBH.EMPLOYEE_GROSS_AMOUNT\n" +
",DBH.EMPLOYER_GROSS_AMOUNT\n" +
",DBH.PAYROLL_EXCLUDE\n" +
",PTH.VOID_DATE\n" +
",PTH.BATCH_QUEUE_ID\n" +
",B.BATCH_CODE\n" +
",BQ.FY\n" +
",BQ.END_DATE\n" +
",BQ.COMMENTS\n" +
",BQ.BATCH_CRITERIA_USED\n" +
",BP.COLUMN_VALUE\n" +
",PTH.REPLACEMENT\n" +
",P.LAST_NAME\n" +
",P.FIRST_NAME\n" +
",P.MIDDLE_NAME\n" +
" from PY_EMPLOYEE_TAX_HISTORY PTH\n" +
" INNER JOIN PERSON_EMPLOYEE PE ON\n" +
" PE.INST_ID=PTH.INST_ID AND\n" +
" PE.EMPLOYEE_ID=PTH.EMPLOYEE_ID\n" +
" INNER JOIN PERSON P ON\n" +
" PE.INST_ID=P.INST_ID AND\n" +
" PE.PERSON_ID=P.PERSON_ID\n" +
" LEFT JOIN HR_EMPLOYEE_DEDUCTIONS_AND_BENEFITS_HISTORY DBH ON\n" +
" PTH.INST_ID=DBH.INST_ID AND\n" +
" PTH.CHECK_DATE=DBH.CHECK_DATE AND\n" +
" PTH.CHECK_NO=DBH.CHECK_NO AND\n" +
" PTH.EMPLOYEE_ID=DBH.EMPLOYEE_ID\n" +
" LEFT JOIN HR_DEDUCTION_AND_BENEFITS DB ON\n" +
" DB.INST_ID=DBH.INST_ID AND\n" +
" DB.HR_DEDUCTION_AND_BENEFITS_CODE=DBH.HR_DEDUCTION_AND_BENEFITS_CODE\n" +
" LEFT JOIN BATCH_QUEUE BQ ON\n" +
" PTH.BATCH_QUEUE_ID=BQ.BATCH_QUEUE_ID\n" +
" LEFT JOIN BATCH B ON\n" +
" B.BATCH_CODE=BQ.BATCH_CODE\n" +
" LEFT JOIN BATCH_PARAMETER BP ON\n" +
" BQ.BATCH_QUEUE_ID=BP.BATCH_QUEUE_ID\n" +
" AND BP.COLUMN_NAME = 'SUPPRESS_DIRECT_DEPOSIT'\n" +
" WHERE PTH.CHECK_DATE >='{0}'\n" +
" AND PTH.CHECK_DATE <='{1}'\n" +
" and BQ.BATCH_CODE='BAT_PY_PAYCALC'\n" +
" and bq.fy=2014\n" +
" ORDER BY PTH.INST_ID\n" +
",PTH.EMPLOYEE_ID\n" +
",DBH.HR_DEDUCTION_AND_BENEFITS_CODE\n" +
",DBH.CHECK_DATE", startDateStr, endDateStr);
SqlDataAdapter adapter = new SqlDataAdapter(SQL, connStr);
DataTable dt = new DataTable();
adapter.Fill(dt);
jdweng
Could you elaborate more on what this code does in general?
Does it generate a table with the data between specified dates? If so, where is the table shown?
Where does one enter in the specified start and end dates on the Web Application? Do I have to create start and end date blanks and link them to the code for it to work?
Sorry for the inconvenience - I'm just really new at this. Thanks! -
CAML query to select data in specfic range
CAML query to select data in specfic range.
I have a list-A and it has a column 'Col1' which has thousands records, I want to fetch data in a specific range as:
select Col1,Col2 from list-A where Col1 > 100 and Col1 < 600Hi,
The following code with the CAML query for your reference:
using (SPSite site = new SPSite("http://spsite/"))
using (SPWeb web = site.OpenWeb())
string sQuery = @"<where><and><gt><fieldref name='Col1' /><value type='number'>100</value></gt><lt><fieldref name='Col1' /><value type='number'> 600 </value></lt></and></where>";
string sViewFields = @"<fieldref name='Col1' /><fieldref name='Col2' />";
string sViewAttrs = @"Scope='Recursive'";
var oQuery = new SPQuery();
oQuery.Query = sQuery;
oQuery.ViewFields = sViewFields;
oQuery.ViewAttributes = sViewAttrs;
SPList oList = web.Lists["ListName"];
SPListItemCollection collListItems = oList.GetItems(oQuery);
foreach (SPListItem oListItem in collListItems)
More information about the CAML:
http://msdn.microsoft.com/en-us/library/office/ms467521(v=office.15).aspx
http://msdn.microsoft.com/en-us/library/office/ms462365(v=office.15).aspx
Here is a tool will help you to build and test SharePoint CAML Queries:
https://spcamlqueryhelper.codeplex.com/
Best Regards
Dennis Guo
TechNet Community Support -
Query taking long time for EXTRACTING the data more than 24 hours
Hi ,
Query taking long time for EXTRACTING the data more than 24 hours please find the query and explain plan details below even indexes avilable on table's goe's to FULL TABLE SCAN. please suggest me.......
SQL> explain plan for select a.account_id,round(a.account_balance,2) account_balance,
2 nvl(ah.invoice_id,ah.adjustment_id) transaction_id,
to_char(ah.effective_start_date,'DD-MON-YYYY') transaction_date,
to_char(nvl(i.payment_due_date,
to_date('30-12-9999','dd-mm-yyyy')),'DD-MON-YYYY')
due_date, ah.current_balance-ah.previous_balance amount,
decode(ah.invoice_id,null,'A','I') transaction_type
3 4 5 6 7 8 from account a,account_history ah,invoice i_+
where a.account_id=ah.account_id
and a.account_type_id=1000002
and round(a.account_balance,2) > 0
and (ah.invoice_id is not null or ah.adjustment_id is not null)
and ah.CURRENT_BALANCE > ah.previous_balance
and ah.invoice_id=i.invoice_id(+)
AND a.account_balance > 0
order by a.account_id,ah.effective_start_date desc; 9 10 11 12 13 14 15 16
Explained.
SQL> select * from table(dbms_xplan.display);
PLAN_TABLE_OUTPUT
| Id | Operation | Name | Rows | Bytes |TempSpc| Cost (%CPU)|
| 0 | SELECT STATEMENT | | 544K| 30M| | 693K (20)|
| 1 | SORT ORDER BY | | 544K| 30M| 75M| 693K (20)|
|* 2 | HASH JOIN | | 544K| 30M| | 689K (20)|
|* 3 | TABLE ACCESS FULL | ACCOUNT | 20080 | 294K| | 6220 (18)|
|* 4 | HASH JOIN OUTER | | 131M| 5532M| 5155M| 678K (20)|
|* 5 | TABLE ACCESS FULL| ACCOUNT_HISTORY | 131M| 3646M| | 197K (25)|
| 6 | TABLE ACCESS FULL| INVOICE | 262M| 3758M| | 306K (18)|
Predicate Information (identified by operation id):
2 - access("A"."ACCOUNT_ID"="AH"."ACCOUNT_ID")
3 - filter("A"."ACCOUNT_TYPE_ID"=1000002 AND "A"."ACCOUNT_BALANCE">0 AND
ROUND("A"."ACCOUNT_BALANCE",2)>0)
4 - access("AH"."INVOICE_ID"="I"."INVOICE_ID"(+))
5 - filter("AH"."CURRENT_BALANCE">"AH"."PREVIOUS_BALANCE" AND ("AH"."INVOICE_ID"
IS NOT NULL OR "AH"."ADJUSTMENT_ID" IS NOT NULL))
22 rows selected.
Index Details:+_
SQL> select INDEX_OWNER,INDEX_NAME,COLUMN_NAME,TABLE_NAME from dba_ind_columns where
2 table_name in ('INVOICE','ACCOUNT','ACCOUNT_HISTORY') order by 4;
INDEX_OWNER INDEX_NAME COLUMN_NAME TABLE_NAME
OPS$SVM_SRV4 P_ACCOUNT ACCOUNT_ID ACCOUNT
OPS$SVM_SRV4 U_ACCOUNT_NAME ACCOUNT_NAME ACCOUNT
OPS$SVM_SRV4 U_ACCOUNT CUSTOMER_NODE_ID ACCOUNT
OPS$SVM_SRV4 U_ACCOUNT ACCOUNT_TYPE_ID ACCOUNT
OPS$SVM_SRV4 I_ACCOUNT_ACCOUNT_TYPE ACCOUNT_TYPE_ID ACCOUNT
OPS$SVM_SRV4 I_ACCOUNT_INVOICE INVOICE_ID ACCOUNT
OPS$SVM_SRV4 I_ACCOUNT_PREVIOUS_INVOICE PREVIOUS_INVOICE_ID ACCOUNT
OPS$SVM_SRV4 U_ACCOUNT_NAME_ID ACCOUNT_NAME ACCOUNT
OPS$SVM_SRV4 U_ACCOUNT_NAME_ID ACCOUNT_ID ACCOUNT
OPS$SVM_SRV4 I_LAST_MODIFIED_ACCOUNT LAST_MODIFIED ACCOUNT
OPS$SVM_SRV4 I_ACCOUNT_INVOICE_ACCOUNT INVOICE_ACCOUNT_ID ACCOUNT
OPS$SVM_SRV4 I_ACCOUNT_HISTORY_ACCOUNT ACCOUNT_ID ACCOUNT_HISTORY
OPS$SVM_SRV4 I_ACCOUNT_HISTORY_ACCOUNT SEQNR ACCOUNT_HISTORY
OPS$SVM_SRV4 I_ACCOUNT_HISTORY_INVOICE INVOICE_ID ACCOUNT_HISTORY
OPS$SVM_SRV4 I_ACCOUNT_HISTORY_ADINV INVOICE_ID ACCOUNT_HISTORY
OPS$SVM_SRV4 I_ACCOUNT_HISTORY_CIA CURRENT_BALANCE ACCOUNT_HISTORY
OPS$SVM_SRV4 I_ACCOUNT_HISTORY_CIA INVOICE_ID ACCOUNT_HISTORY
OPS$SVM_SRV4 I_ACCOUNT_HISTORY_CIA ADJUSTMENT_ID ACCOUNT_HISTORY
OPS$SVM_SRV4 I_ACCOUNT_HISTORY_CIA ACCOUNT_ID ACCOUNT_HISTORY
OPS$SVM_SRV4 I_ACCOUNT_HISTORY_LMOD LAST_MODIFIED ACCOUNT_HISTORY
OPS$SVM_SRV4 I_ACCOUNT_HISTORY_ADINV ADJUSTMENT_ID ACCOUNT_HISTORY
OPS$SVM_SRV4 I_ACCOUNT_HISTORY_PAYMENT PAYMENT_ID ACCOUNT_HISTORY
OPS$SVM_SRV4 I_ACCOUNT_HISTORY_ADJUSTMENT ADJUSTMENT_ID ACCOUNT_HISTORY
OPS$SVM_SRV4 I_ACCOUNT_HISTORY_APPLIED_DT APPLIED_DATE ACCOUNT_HISTORY
OPS$SVM_SRV4 P_INVOICE INVOICE_ID INVOICE
OPS$SVM_SRV4 U_INVOICE CUSTOMER_INVOICE_STR INVOICE
OPS$SVM_SRV4 I_LAST_MODIFIED_INVOICE LAST_MODIFIED INVOICE
OPS$SVM_SRV4 U_INVOICE_ACCOUNT ACCOUNT_ID INVOICE
OPS$SVM_SRV4 U_INVOICE_ACCOUNT BILL_RUN_ID INVOICE
OPS$SVM_SRV4 I_INVOICE_BILL_RUN BILL_RUN_ID INVOICE
OPS$SVM_SRV4 I_INVOICE_INVOICE_TYPE INVOICE_TYPE_ID INVOICE
OPS$SVM_SRV4 I_INVOICE_CUSTOMER_NODE CUSTOMER_NODE_ID INVOICE
32 rows selected.
Regards,
Bathula
Oracle-DBAI have some suggestions. But first, you realize that you have some redundant indexes, right? You have an index on account(account_name) and also account(account_name, account_id), and also account_history(invoice_id) and account_history(invoice_id, adjustment_id). No matter, I will suggest some new composite indexes.
Also, you do not need two lines for these conditions:
and round(a.account_balance, 2) > 0
AND a.account_balance > 0
You can just use: and a.account_balance >= 0.005
So the formatted query isselect a.account_id,
round(a.account_balance, 2) account_balance,
nvl(ah.invoice_id, ah.adjustment_id) transaction_id,
to_char(ah.effective_start_date, 'DD-MON-YYYY') transaction_date,
to_char(nvl(i.payment_due_date, to_date('30-12-9999', 'dd-mm-yyyy')),
'DD-MON-YYYY') due_date,
ah.current_balance - ah.previous_balance amount,
decode(ah.invoice_id, null, 'A', 'I') transaction_type
from account a, account_history ah, invoice i
where a.account_id = ah.account_id
and a.account_type_id = 1000002
and (ah.invoice_id is not null or ah.adjustment_id is not null)
and ah.CURRENT_BALANCE > ah.previous_balance
and ah.invoice_id = i.invoice_id(+)
AND a.account_balance >= .005
order by a.account_id, ah.effective_start_date desc;You will probably want to select:
1. From ACCOUNT first (your smaller table), for which you supply a literal on account_type_id. That should limit the accounts retrieved from ACCOUNT_HISTORY
2. From ACCOUNT_HISTORY. We want to limit the records as much as possible on this table because of the outer join.
3. INVOICE we want to access last because it seems to be least restricted, it is the biggest, and it has the outer join condition so it will manufacture rows to match as many rows as come back from account_history.
Try the query above after creating the following composite indexes. The order of the columns is important:create index account_composite_i on account(account_type_id, account_balance, account_id);
create index acct_history_comp_i on account_history(account_id, invoice_id, adjustment_id, current_balance, previous_balance, effective_start_date);
create index invoice_composite_i on invoice(invoice_id, payment_due_date);All the columns used in the where clause will be indexed, in a logical order suited to the needs of the query. Plus each selected column is indexed as well so that we should not need to touch the tables at all to satisfy the query.
Try the query after creating these indexes.
A final suggestion is to try larger sort and hash area sizes and a manual workarea policy.alter session set workarea_size_policy = manual;
alter session set sort_area_size = 2147483647;
alter session set hash_area_size = 2147483647; -
Dynamically built query on execution How to save the data in Object Type
Hi,
In pl/sql I am building and executing a query dynamically. How can I stored the output of the query in object type. I have defined the following object type and need to store the
output of the query in it. Here is the Object Type I have
CREATE OR REPLACE TYPE DEMO.FIRST_RECORDTYPE AS OBJECT(
pkid NUMBER,
pkname VARCHAR2(100);
pkcity VARCHAR2(100);
pkcounty VARCHAR2(100)
CREATE OR REPLACE TYPE DEMO.FIRST_RECORDTYPETAB AS TABLE OF FIRST_RECORDTYPE;Here is the query generated at runtime and is inside a LOOP
--I initialize my Object Type*
data := new FIRST_RECORDTYPETAB();
FOR some_cursor IN c_get_ids (username)
LOOP
x_context_count := x_context_count + 1;
-- here I build the query dynamically and the same query generated is
sql_query := 'SELECT pkid as pid ,pkname as pname,pkcity as pcity, pkcounty as pcounty FROM cities WHERE passed = <this value changes on every iteration of the cursor>'
-- and now I need to execute the above query but need to store the output
EXECUTE IMMEDIATE sql_query
INTO *<I need to save the out put in the Type I defined>*
END LOOP;
How can I save the output of the dynamically built query in the Object Type. As I am looping so the type can have several records.
Any help is appreciated.
Thankshai ,
solution for Dynamically built query on execution How to save the data in Object Type.
Step 1:(Object creation)
SQL> ED
Wrote file afiedt.buf
1 Create Or Replace Type contract_details As Object(
2 contract_number Varchar2(15),
3 contrcat_branch Varchar2(15)
4* );
SQL> /
Type created.
Step 2:(table creation with object)
SQL> Create Table contract_dtls(Id Number,contract contract_details)
2 /
Table created.
Step 3:(execution Of procedure to insert the dynamic ouput into object types):
Declare
LV_V_SQL_QUERY Varchar2(4000);
LV_N_CURSOR Integer;
LV_N_EXECUTE_CURSOR Integer;
LV_V_CONTRACT_BR Varchar2(15) := 'TNW'; -- change the branch name by making this as input parameter for a procedure or function
OV_V_CONTRACT_NUMBER Varchar2(15);
LV_V_CONTRACT_BRANCH Varchar2(15);
Begin
LV_V_SQL_QUERY := 'SELECT CONTRACT_NUMBER,CONTRACT_BRANCH FROM CC_CONTRACT_MASTER WHERE CONTRACT_BRANCH = '''||LV_V_CONTRACT_BR||'''';
LV_N_CURSOR := Dbms_Sql.open_Cursor;
Dbms_Sql.parse(LV_N_CURSOR,LV_V_SQL_QUERY,2);
Dbms_Sql.define_Column(LV_N_CURSOR,1,OV_V_CONTRACT_NUMBER,15);
Dbms_Sql.define_Column(LV_N_CURSOR,2,LV_V_CONTRACT_BRANCH,15);
LV_N_EXECUTE_CURSOR := Dbms_Sql.Execute(LV_N_CURSOR);
Loop
Exit When Dbms_Sql.fetch_Rows (LV_N_CURSOR)= 0;
Dbms_Sql.column_Value(LV_N_CURSOR,1,OV_V_CONTRACT_NUMBER);
Dbms_Sql.column_Value(LV_N_CURSOR,2,LV_V_CONTRACT_BRANCH);
Dbms_Output.put_Line('CONTRACT_BRANCH--'||LV_V_CONTRACT_BRANCH);
Dbms_Output.put_Line('CONTRACT_NUMBER--'||OV_V_CONTRACT_NUMBER);
INSERT INTO contract_dtls VALUES(1,CONTRACT_DETAILS(OV_V_CONTRACT_NUMBER,LV_V_CONTRACT_BRANCH));
End Loop;
Dbms_Sql.close_Cursor (LV_N_CURSOR);
COMMIT;
Exception
When Others Then
Dbms_Output.put_Line('SQLERRM--'||Sqlerrm);
Dbms_Output.put_Line('SQLERRM--'||Sqlcode);
End;
step 4:check the values are inseted in the object included table
SELECT * FROM contract_dtls;
Regards
C.karukkuvel -
Where the new data's are placed first ?
Hi,
I have created the database of TimesTen as per the steps in
http://download.oracle.com/otn_hosted_doc/timesten/1121/quickstart/html/admin/db_ops_createdb.html
using Data Source Name (DSN )
Placed data in C:\TimesTen\Database
Placed log in D:\TimesTen\Log
Command> connect "dsn=my_ttdb";
Connection successful: DSN=my_ttdb;UID=*******;DataStore=C:\TimesTen\Database\my_ttdb;DatabaseCharacterSet=AL32UTF8;ConnectionChar
=D:\TimesTen\Log;PermSize=700;TempSize=300;TypeMode=0;OracleNetServiceName=orcl_db;
(Default setting AutoCommit=1)
If the tables are created it will be data file that is in C:\TimesTen\Database path
If the data's are populated(inserted/updated) then the log will be in D:\TimesTen\Log path and data's will be C:\TimesTen\Database
Here what ever command which is issued will be logged in D:\TimesTen\Log
Where the new or incoming data's are placed , first in-memory or where ,if it is placing in memory when it will be writing to disk. I couldn't be able to see any data's in memory when the new data is inserted.
I am using bulk command to insert the data
ttBulkCp -i DSN=my_ttdb mytable C:\TimesTen\Database\test.txt
When the data's are inserted it writes the log in the log directory D:\TimesTen\Log and the new log files are generated my_ttdb.logXX ,then what is the difference in general Oracle database and Oracle TimesTen database?
If the logs are going to happen when we use the ttBulkCp command then we can opt for Oracle database and why we need to go for Oracle TimesTen if all the operations are similar.What differs here with normal Oracle database.
Thanks!Hi,
In the link
http://docs.oracle.com/cd/E21901_01/doc/timesten.1122/e21633/comp.htm#BABHBICB
under Database persistence topic it is said as Databases are created in two ways :
Permanent databases are stored to disk automatically through a procedure called checkpointing. TimesTen automatically performs background checkpoints based on the settings of the connection attributes CkptFrequency and CkptLogVolume. TimesTen also checkpoints the database when the last application disconnects. Applications can also checkpoint a database directly to disk by invoking the ttCkptBlocking built-in procedures
Temporary databases are not stored to disk. A temporary database is automatically destroyed when no applications are connected to it; that is, when the last connection disconnects or when there is a system or application failure. TimesTen removes all disk-based files when the last application disconnects.
A temporary database cannot be backed up or replicated. Temporary databases are never fully checkpointed to disk*, although Checkpoint operations can have significant overhead for permanent databases, depending on database size and activity, but have very little impact for temporary databases. Checkpoints are still necessary to remove transaction log files.
If the Temporary databases are never fully checkpointed to disk then how cum the full data are written to disk
How to Setup a Permanent database
How to Setup a Temporary database (http://docs.oracle.com/cd/E21901_01/doc/timesten.1122/e21633/using.htm#BCGJAJDI)
But the statements are not clear
I need to check how it works on a Permanent database and Temporary database, so it would be helpful if you could provide alternate link how to configure Permanent/Temporary database.
My aim to keep the data in memory (i have not installed Oracle database,only TimesTen has been installed)and replicate the data to another server.For this requirement whether TT will a suitable.using Windows 2003 and 32 bit OS -
Query Based on Date & Time Range
Hello Users,
There is a requirement to display weekly report from saturday 8:00 AM to previous saturday 08:00 AM.
I have a table "Downtime"
IPADDRESS First Occurrence Last Occurrence Downtime
172.29.10.12 31-JUL-10 08:12:50 01-AUG-10 09:00:00 1
172.29.11.54 01-AUG-10 11:12:00 01-AUG-10 01:10:00 3
172.29.58.7 07-AUG-10 04:10:00 07-AUG-10 05:00:00 2I will not have problem when I run the report on saturday as I can give condition as sysdate - 7.
First problem is how will I default to 8 AM.
Second if the report is run on sunday or in between before next saturdya I have to query the records only from satuday 8 AM to previous saturday 8 AM.
Can anyone please help me on this?
Thanks.
Ravi.Hi,
hoek wrote:
That's a great hint, Solomon, thanks.
I always end up getting frustrated because trunc on a date returns a NULL for 'midnight'....and the ability to perform date arithmetic is gone all of a sudden. Why isn't Oracle just resetting to '00:00:00' when truncating a date, I wonder?I must not understand what you're asking.
It sounds as if you're saying that TRUNC (dt) sometimes returns something that is NULL (or somehow partially NULL), but I'm sure you don't really think that.
For other readers who may be wondering:
TRUNC (dt), where dt is a DATE (and not NULL) , always returns a DATE, and DATEs always have a time. Either the whole DATE is NULL or none of it is; you can't have a year-month-day in a DATE column and not have a time, or have a NULL time.
TRUNC(dt, x) may return a DATE where the time is not midnight, but only if x is a format string like 'MI' that specifies an interval less than a day. When x indicates a longer interval (e,g, 'IW'), or when x is omitted, the time is always midnight. In any event, you can do date arithmetic on the results.
I'm sure you understand this, but your question makes it sound like you don't.
This should illustrate my point:
-- generating hours, starting 14 days ago:
with t as (
select trunc(sysdate-14)+ level/24-1 dt
from dual
connect by level <= 24*14
-- querying generated data:
select dt
--, trunc(dt,'iw') - 5/3 -- great workaround, but why can't we just work with 00:00:00 for the time component?
from t;
-- generating hours, starting 14 days ago:
with t as (
select trunc(sysdate-14)+ level/24-1 dt
from dual
connect by level <= 24*14
-- querying data between saturday and previous saturday
-- from the same resultset and 'it doesn't work'
select dt
from t
where dt between trunc(dt-7)+8/24 and trunc(sysdate)+8/24;
Is this a parody of a poorly written question?
Are you trying to make the point that no one should ever say "it doesn't work" without explaining exactly what doesn't work, and what the expected output is?
I get the same 336 rows when I run either of the queries above.
As you've often said, posters should always show exactly what results they want. -
Display of date range in the top-of-page of report
have a question like this.
i have a date range selection on the selection screen where the user will enter the range from this to this.
now whatever period he will enter,that range should be displayed on the output of the report in the top-of page.
can we do like this.
plz explain.
thanks!Hi,
Use the below logic.
data: events type slis_t_event,
event type slis_alv_event,
heading type slis_t_listheader,
hline type slis_listheader,
start-of-selection.
"get the data into the internal table and fill your fieldcatalog table.
then fill the event ... ie top of page like this.
CLEAR event.
event-name = slis_ev_top_of_page.
event-form = form_name.
APPEND event TO events.
then fill the comments to display in the top of page event.
DATA: text(50).
CLEAR hline.
hline-typ = 'H'.
hline-info = "report title".
APPEND hline TO heading.
CLEAR: hline,text.
read table s_pernr index 1.
IF s_pernr-low IS NOT INITIAL.
WRITE: 'Sal Code:' TO text.
WRITE: s_pernr-low TO text+15.
ENDIF.
IF s_pernr-high IS NOT INITIAL.
WRITE: 'to' TO text+25.
WRITE: s_pernr-high TO text+28.
ENDIF.
hline-typ = 'S'.
hline-info = text.
APPEND hline TO heading.
and then...
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
i_callback_program = sy-repid
it_fieldcat = ist_fcat[]
it_events = events[]
TABLES
t_outtab = ist_main[]
EXCEPTIONS
program_error = 1
OTHERS = 2
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
and then create a subroutine for top of page.
FORM top_of_page.
CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
EXPORTING
it_list_commentary = heading[]
I_LOGO =
I_END_OF_LIST_GRID =
I_ALV_FORM =
ENDFORM. "TOP_OF_PAGE
regards,
Santosh Thorat -
Excel query/macro , delete records where the aggregate value is not over 100
I have a spreadsheet with about 5000 records. I need to delete out the records where the Amount column is less than $10.00 unless the aggregate of the amount column is greater than or equal to $100. I have an ID column that matches to the name on the record.
So is it possible to create something that for each ID number in the ID column if the Amount column is less than $10 delete it unless the same ID appears again and is greater than $100? TIAHI mkozz28,
>> I need to delete out the records where the Amount column is less than $10.00 unless the aggregate of the amount column is greater than or equal to $100.
In my option, you could sort the data by column ID, then loop through the column Amount, if the value of the Amount is less than 10, then find the cell according the same ID, if the Amout is less than 100, delete the enterRow.
For more information about Find method, you could turn to the link below
# Range.Find Method (Excel)
https://msdn.microsoft.com/en-us/library/office/ff839746.aspx
For the row delete, the link below might be useful to you
# Delete Method [Excel 2003 VBA Language Reference]
https://msdn.microsoft.com/en-us/library/office/aa223863(v=office.11).aspx
A simple demo as below, you need to modify it to your own requirement.
Sub test1()
For i = 2 To 8 'row number
Debug.Print ActiveSheet.Cells(i, 2).Value
'ActiveSheet.Cells(i, 2).Select
If (ActiveSheet.Cells(i, 2).Value <= 10) Then
Set cell = ActiveSheet.Range("A1:A8").Find(ActiveSheet.Cells(i, 1).Value, After:=ActiveSheet.Cells(i, 1), LookIn:=xlValues)
If cell Is Nothing Then
ActiveSheet.Cells(i, 2).EntireRow.Delete
Else
Debug.Print ActiveSheet.Cells(cell.Row, 2).Value
If ActiveSheet.Cells(cell.Row, 2).Value < 100 Then
ActiveSheet.Cells(i, 2).EntireRow.Delete
End If
End If
End If
Next i
End Sub
Best Regards,
Edward
We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
Click HERE to participate the survey. -
Hello All,
We are using a two tier architecture.
Our Corp server calls the refinery server.
Our CORP MII server uses user id abc_user to connect to the refinery data server.
The user id abc_user has the SAP_xMII_Dynamic_Query role.
The data server also has the checkbox for allow dynamic query enabled.
But we are still getting the following error
Error has occurred while processing data stream
Dynamic Query role is not assigned to the Data Server; Use query template
Once we add the SAP_xMII_Dynamic_Query role to the data server everything works fine. Is this feature by design ?
Thanks,
KiranThanks Anushree !!
I thought that just adding the role to the user and enabling the dynamic query checkbox on the data server should work.
But we even needed to add the role to the data server.
Thanks,
Kiran -
Table where the Delivery date is stored in Confirmation tab on Me23n
Hello ABAB Gurus,
Can anyone give me the table name where the Delivery date is stored in Confirmation tab in Item in ME23n.
If anyone is aware of it then please let me know .
SagarHi,
Check the table EKES and field name is EINDT..
Thanks,
Naren -
I've attached a sample VI that I just cannot figure out how to get working the way that I want. I've labeled the some sections with black-on-yellow text boxes for clarity during the description that follows in the next few sentences. Here's what I want:
1) overall -- i'm intend for this to be a subVI that will do data acquisition and write the data to a file. I want it to use a producer/consumer approach. The producer construct is the 'parallel for loop' that runs an exact number of times depending on user input (which will come from the mainVI that is not included). For now I've wired a 1-D array w/ 2 elements as a test case. During the producer loop, the data is acquired and put into a queue to be delt with in the consumer loop (for now, i just add a random number to the queue).
2) the consumer construct is the 'parallel while loop'. It will dequeue elements and write them to a file. I want this to keep running continuously and parallel until two conditions are met.
i. the for loop has finished execution
ii. the queue is empty.
when the conditions are met, the while loop will exit, close the queue, and the subVI will finish. (and return stuff to mainVI that i can deal with on my own)
Here's the problems.
1) in the "parallel for loop" I have a flat sequence structure.. I haven't had time to incorporate some data dependency into these two sequential sections, but basically, I just care that the "inner while loop" condition is met before the data is collected and queued. I think I can do this on my own, but if you have suggestions, I'm interested.
2) I can easily get the outer for and while loops to run sequentially, but I want them to run in parallel. My reasoning for this is that that I anticipate the two tasks taking very different amounts of time. .. basically, I want the while loop to just keep polling the queue to get everything out of it (or I suppose I could somehow use notifiers - suggestions welcome)... the thing is, this loop will probably run faster than the for loop, so just checking to see that the queue is empty will not work... I need to meet the additional condition that nothing else will be placed in the queue - and this condition is met when the for loop is complete. basically, I just can't figure out how to do this.
3) for now, I've placed a simple stop button in the 'parallel while loop', but I must be missing something fundamental here, because the stop button is totally unresponsive. i.e. - when I press it, it stays depressed, and nothing happens.
suggestions are totally welcome!
thanks,
-Z
Attachments:
daq01v1.vi 59 KBI'd actually like to add a little more, since I thought about it a bit and I'm still not quite certain I understand the sequence of events...
altenbach wrote:
zskillz wrote:
So i read a bit more about the 'dequeue element' function, and as I understand it, since there is no timeout wired to the dequeue element function, it will wait forever, thus the race condition I suggested above can never happen!
Yes, you got it!
As I've thought about it a bit more, there's a few things that surprise me... first, the reason the 'dequeue element while loop' errors is not because there's nothing in the queue, it's becaues the queue has been released and it's trying to access that released queue... However the problem I have is this --- Even though there's no timeout wired to the dequeue element, I still would think that the while loop that contains it would continue to run at whatever pace it wanted -- and as i said before.. most of the time, it would find that there is nothing to dequeue, but once in a while, something is there. however, it seems that this loop only runs when something has been enqueued. the reason I say this is illustrated in the next code sample MODv2 that's attached below. I've added a stop button to the "queue size while loop" so the program runs until that is pressed. I've also added a simple conditional in the "dequeue while loop" that generates a random number if it a button is pressed... but this button is totally non-responsive... which means to me that the "dequeue while loop" isn't actually continuously running, but only when an element is added to the queue. this still seems almost like the 'dequeue while loop" waits for a notifier from the queue telling it to run. can you explain this to me? because it is different from what I expect to be happening.
rasputin wrote:
I tried to open your VIs but it doesn't work. LV
is launched, the dialog box (new, open, configure...) opens and then...
nothing. Not even an error message. I guess it isn't a problem of LV
version or a dialog box would appear saying this. Could you, please,
send a image of the code?
Thanks,
Hi Rasputin, I'm using LV8. I assume that was your problem, but who knows. I've attached a pic of of altenbach's solution since it's what I needed.
thanks
-Z
Message Edited by zskillz on 10-20-2006 11:49 AM
Attachments:
daq01v1MODv2.vi 63 KB
daq01v1MODpic.JPG 116 KB -
How can I show a 0% range in the data value label on a bar chart thanks?
How can I show a 0% range in the data value label on a bar chart thanks?
I'm not sure what the question is.
I know that if you have a bar chart and one of the categories (X-axis) has bar (Y value) equal to 0%, no bar is plotted for that category. Even the addition of a stroke (line) around the bars doesn't make one appear for 0%. The only automatic way I know of to make it look like there is data in that category is to add the value labels to the bars. Inspector/Chart/Series, select one of the bars on the chart, click on "value labels". Another method that is a workaround is to fudge the number a little in your table so that instead of 0% it is a very small %. This will get you a thin line on the chart.
But if your question is about the value labels (the numbers that display on or in the bars) and you are not getting one for a bar that is supposed to be 0%, it probably means your table doesn't actually have a 0% in the corresponding cell. A blank cell in the table will not get a value label.
Maybe you are looking for
-
Third party sales- why MIGO in our system?
Why we do MIGO in third party sales scenario, as we dont have stock movement in our plant? In the case- third party vendor delivers the goods directly to customer? Please clear me? Edited by: arshad ahamad on Feb 4, 2008 9:28 AM
-
Variable in derived class more public
Hello, I thought variables in a derived class could not be more public than the variables they hide (in the base class) e.g. the "var" variable in "DerivedDemo" could not be more public than the "var" variable in Demo. (which would be the opposite to
-
10.5.1. bootcamp - date / time funky and and wireless goes dead
two funky issues I've experienced on my core 2 duo macbook Model Name: MacBook Model Identifier: MacBook3,1 Processor Name: Intel Core 2 Duo Processor Speed: 2.2 GHz first thing I noticed when switching back and forth from XP to Leopard was that the
-
When I print a web page firefox will only print the first page, all of the content to the first page break and nothing past that. How can I change the settings so that it will print more than on page?
-
I am trying to import the following XSD as an External Definition in Repository. I am getting the following Error. Please help me. Error Activation of the change list canceled Check result for External Definition Request | http://ABC.COM: Document ch