About case when and the sql clause
Hi:
The following is my sql clause:
SELECT t.*,b.name
FROM dbtest1 t
LEFT OUTER JOIN dbtest b ON t.NO = b.empno
WHERE t.ChineseName like '%'||:ChineseName||'%' AND b.name like '%'||:name||'%'
ORDER BY t.ChineseName
The main problem is I hope to check the b.name if it is null it can be passed as NVL function, so I try using case when, but it not working.
When b.name exist in where clause, the result columns will not include the data without b.name(or implies the b.name is NULL); And that
make the result data not exactly right.
is it possible to use case when to make the following snippet implemented:
case when b.name is not NULL then b.name like '%'||:name||'%'
else b.name = NULL(b.name=b.name seems not work to parsing null data)
end
Thanks a lot.
962769 wrote:
Hi:
The following is my sql clause:
SELECT t.*,b.name
FROM dbtest1 t
LEFT OUTER JOIN dbtest b ON t.NO = b.empno
WHERE t.ChineseName like '%'||:ChineseName||'%' AND b.name like '%'||:name||'%'
ORDER BY t.ChineseName
The main problem is I hope to check the b.name if it is null it can be passed as NVL function, so I try using case when, but it not working.
When b.name exist in where clause, the result columns will not include the data without b.name(or implies the b.name is NULL); And that
make the result data not exactly right.
is it possible to use case when to make the following snippet implemented:
case when b.name is not NULL then b.name like '%'||:name||'%'
else b.name = NULL(b.name=b.name seems not work to parsing null data)
end
Thanks a lot.Your question isn't very clear. But below is the statement as I make a meaning out of it.
SELECT t.*,b.name
FROM dbtest1 t
LEFT OUTER JOIN dbtest b ON t.NO = b.empno
WHERE t.ChineseName like '%'||:ChineseName||'%'
AND b.name like '%'||NVL(:name, b.name)||'%'
ORDER BY t.ChineseNameIf you want to use case, then:
SELECT t.*,b.name
FROM dbtest1 t
LEFT OUTER JOIN dbtest b ON t.NO = b.empno
WHERE t.ChineseName like '%'||:ChineseName||'%'
AND b.name like '%'|| case when b.name is not null then :name else b.name end ||'%'
ORDER BY t.ChineseNameIf this is not what you are looking for then, read {message:id=9360002} and post the relevant details with an example (Create Table script, Sample Data creation script and the Expected output of the sample data).
Similar Messages
-
Query Tuning - using CASE statement in the WHERE clause
Hi All,
My query has been modified to use a CASE statement in the WHERE clause to consider data from certain columns based on a parameter value. This modified query is doing a full table scan and running endlessly. Please suggest what may be done to improve its performance:
Query:
SELECT LAST_DAY(TRUNC(TO_TIMESTAMP(os.requestdatetime, 'yyyymmddhh24:mi:ss.ff4'))) AS summary_date,
os.acctnum,
os.avieworigin_refid,
COUNT(1) cnt_articleview,
SUM(NVL(autocompletedterm,0)) cnt_autocompletedterm
FROM TABLE1 os
WHERE os.acctnum IS NOT NULL
AND os.avieworigin_refid IS NOT NULL
AND os.requestdatetime IS NOT NULL
AND UPPER(os.success_ind) = 'S'
AND CASE WHEN
Param_ValueToCheck = 'FULL' AND get_date_timestamp(os.requestdatetime) BETWEEN
TO_DATE('01-MAY-2011 00:00:00','DD-MON-YYYY HH24:MI:SS') AND
TO_DATE('31-MAY-2011 00:00:00','DD-MON-YYYY HH24:MI:SS')
THEN 1
WHEN
Param_ValueToCheck = 'INCR' AND os.entry_createddate BETWEEN
TO_DATE('01-MAY-2011 00:00:00','DD-MON-YYYY HH24:MI:SS') AND
TO_DATE('31-MAY-2011 00:00:00','DD-MON-YYYY HH24:MI:SS')
THEN 1
END = 1
AND CASE WHEN
Param_ValueToCheck = 'FULL' AND os.entry_CreatedDate BETWEEN
TO_DATE('01-APR-2011 00:00:00','DD-MON-YYYY HH24:MI:SS') AND
TO_DATE('07-JUN-2011 00:00:00','DD-MON-YYYY HH24:MI:SS')
THEN 1
WHEN
Param_ValueToCheck = 'INCR' THEN 1
END = 1
GROUP BY LAST_DAY(TRUNC(TO_TIMESTAMP(os.requestdatetime, 'yyyymmddhh24:mi:ss.ff4'))), os.acctnum,os.avieworigin_refid;Table Description:
(Number of rows : approx > 600,000,000)
Name Null Type
ARTICLEID NOT NULL NUMBER(20)
USERKEY NUMBER(10)
AVIEWORIGIN_REFID VARCHAR2(10)
SUCCESS_IND VARCHAR2(2)
ENTRY_CREATEDDATE DATE
CREATED_BY VARCHAR2(10)
FILENUMBER NUMBER(10)
LINENUMBER NUMBER(10)
ACCTNUM VARCHAR2(10)
AUTOCOMPLETEDTERM NUMBER(2)
REQUESTDATETIME VARCHAR2(19)Explain Plan
SQL> select * from table(dbms_xplan.display);
PLAN_TABLE_OUTPUT
Plan hash value: 2224314832
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time | Pstart| Pstop |
| 0 | SELECT STATEMENT | | 590 | 33040 | 2501K (1)| 08:20:15 | | |
| 1 | HASH GROUP BY | | 590 | 33040 | 2501K (1)| 08:20:15 | | |
| 2 | PARTITION RANGE ALL| | 590 | 33040 | 2501K (1)| 08:20:15 | 1 |1048575|
|* 3 | TABLE ACCESS FULL | TABLE1 | 590 | 33040 | 2501K (1)| 08:20:15 | 1 |1048575|
PLAN_TABLE_OUTPUT
Predicate Information (identified by operation id):
3 - filter(UPPER("OS"."SUCCESS_IND")='S' AND CASE WHEN ('FULL'='FULL' AND
"OS"."ENTRY_CREATEDDATE">=TO_DATE(' 2011-04-01 00:00:00', 'syyyy-mm-dd hh24:mi:ss') AND
"OS"."ENTRY_CREATEDDATE"<=TO_DATE(' 2011-06-07 00:00:00', 'syyyy-mm-dd hh24:mi:ss')) THEN 1 WHEN
'FULL'='INCR' THEN 1 END =1 AND "OS"."REQUESTDATETIME" IS NOT NULL AND CASE WHEN ('FULL'='FULL'
AND "ODS"."GET_DATE_TIMESTAMP"("REQUESTDATETIME")>=TO_DATE(' 2011-05-01 00:00:00', 'syyyy-mm-dd
hh24:mi:ss') AND "ODS"."GET_DATE_TIMESTAMP"("REQUESTDATETIME")<=TO_DATE(' 2011-05-31 00:00:00',
'syyyy-mm-dd hh24:mi:ss')) THEN 1 WHEN ('FULL'='INCR' AND "OS"."ENTRY_CREATEDDATE">=TO_DATE('
2011-05-01 00:00:00', 'syyyy-mm-dd hh24:mi:ss') AND "OS"."ENTRY_CREATEDDATE"<=TO_DATE('
PLAN_TABLE_OUTPUT
2011-05-31 00:00:00', 'syyyy-mm-dd hh24:mi:ss')) THEN 1 END =1 AND "OS"."ACCTNUM" IS NOT NULL AND
"OS"."AVIEWORIGIN_REFID" IS NOT NULL)Edited by: Chaitanya on Jun 9, 2011 2:44 AM
Edited by: Chaitanya on Jun 9, 2011 2:47 AMHi Dom,
Modified Query:
SELECT LAST_DAY(TRUNC(TO_TIMESTAMP(os.requestdatetime, 'yyyymmddhh24:mi:ss.ff4'))) AS summary_date,
os.acctnum,
os.avieworigin_refid,
COUNT(1) cnt_articleview,
SUM(NVL(autocompletedterm,0)) cnt_autocompletedterm
FROM TABLE1 os
WHERE os.acctnum IS NOT NULL
AND os.avieworigin_refid IS NOT NULL
AND os.requestdatetime IS NOT NULL
AND UPPER(os.success_ind) = 'S'
AND (('FULL' = 'FULL'
AND (get_date_timestamp(os.requestdatetime) BETWEEN TO_DATE('01-MAY-2011 00:00:00','DD-MON-YYYY HH24:MI:SS')
AND TO_DATE('31-MAY-2011 00:00:00','DD-MON-YYYY HH24:MI:SS')
AND os.entry_CreatedDate BETWEEN TO_DATE('01-APR-2011 00:00:00','DD-MON-YYYY HH24:MI:SS')
AND TO_DATE('07-JUN-2011 00:00:00','DD-MON-YYYY HH24:MI:SS')
OR ('FULL' = 'INCR'
AND os.entry_createddate BETWEEN TO_DATE('01-MAY-2011 00:00:00','DD-MON-YYYY HH24:MI:SS')
AND TO_DATE('31-MAY-2011 00:00:00','DD-MON-YYYY HH24:MI:SS') ))
GROUP BY LAST_DAY(TRUNC(TO_TIMESTAMP(os.requestdatetime, 'yyyymmddhh24:mi:ss.ff4'))), os.acctnum,os.avieworigin_refid;Execute Plan:
PLAN_TABLE_OUTPUT
Plan hash value: 3615447714
| Id | Operation | Name | Rows | Bytes |TempSpc| Cost (%CPU)| Time | Pstart| Pstop |
| 0 | SELECT STATEMENT | | 25125 | 1374K| | 407K (1)| 01:21:36 | | |
| 1 | HASH GROUP BY | | 25125 | 1374K| 3768K| 407K (1)| 01:21:36 | | |
| 2 | PARTITION RANGE ITERATOR| | 25125 | 1374K| | 407K (1)| 01:21:32 | 29 | 31 |
|* 3 | TABLE ACCESS FULL | TABLE1 | 25125 | 1374K| | 407K (1)| 01:21:32 | 29 | 31 |
PLAN_TABLE_OUTPUT
Predicate Information (identified by operation id):
3 - filter("OS"."ENTRY_CREATEDDATE">=TO_DATE(' 2011-04-01 00:00:00', 'syyyy-mm-dd hh24:mi:ss') AND
UPPER("OS"."SUCCESS_IND")='S' AND "OS"."REQUESTDATETIME" IS NOT NULL AND
"ODS"."GET_DATE_TIMESTAMP"("REQUESTDATETIME")>=TO_DATE(' 2011-05-01 00:00:00', 'syyyy-mm-dd hh24:mi:ss') AND
"ODS"."GET_DATE_TIMESTAMP"("REQUESTDATETIME")<=TO_DATE(' 2011-05-31 00:00:00', 'syyyy-mm-dd hh24:mi:ss') AND
"OS"."ACCTNUM" IS NOT NULL AND "OS"."AVIEWORIGIN_REFID" IS NOT NULL AND "OS"."ENTRY_CREATEDDATE"<=TO_DATE('
2011-06-07 00:00:00', 'syyyy-mm-dd hh24:mi:ss'))Edited by: Chaitanya on Jun 9, 2011 4:51 AM -
How to get cm:search to use the max attribute when creating the SQL query?
When we use the max attribute in the cm:search tag, it does not seem to honor the max attribute when creating the SQL query. However, the result returned from the tag is limited to the number specified by the max attribute. Then the tag seems to work as intended, but the performance will be sub optimal when the SQL query returns unnecessary rows to the application.
We use the cm:search tag to list the latest news (ordered by date), and with the current implementation we have to expect a decrease in performance over time as more news is published. But we can’t live with that. We need to do the constraint in the SQL query, not in the application.
The sortBy attribute of cm:search is translated to “order by” in the SQL query, as expected.
Is it possible to get cm:search to generate the SQL query with an addition of “where rownum <= maxRows”?Hi Erik,
The behavior of a repository in regards to the search tag's max results parameter is dependent on the underlying repository's implementation. That said, the OOTB repository in WLP does augment the generated SQL to limit the number of rows returned from the database. This is done in the parsing logic. This behavior may differ with other repository implementations.
-Ryan -
hey iphone an iphone 3g and i only have about 13 apps and the yellow bar on itunes for my phone is way to big i deleted all my photos all my music every thing i ryed restoring ans all it still takes up space for sum reason ?? please someone help me
If Other (the yellow bar) is too big something is corrupted. The only solution (that I know of) is to restore from your most recent backup using iTunes (see http://support.apple.com/kb/ht1766).
-
I will be playing some 3d games and it says the battery is 90% but I'll turn off and turn in back on it about 30 minutes and the battery is only 70%. Why is the reading so inaccurate? I understand that 3d games on high brightness will drain my battery quickly, but why doesn't it tell be how low it is to begin with? The other night it said it was around 35% and I turned it on in the morning and it was only 3%?
Sorry there are some typos above, but you should be able to figure out what I'm asking. Let me know if you have tha same problem, know how to fix it, or know if apple is aware of the problem and is adressing it in a future update.
-
How do I fix my ipod?
It is an ipod touch 5th generation. I've had it about a year and the home button doesn't work. Right now it doesn't want to turn on.
-
Query Tuning - using CASE statement in the WHERE clause - Duplicate Post
Duplicate Post by mistake.
Please check
Query Tuning - using CASE statement in the WHERE clause
Edited by: Chaitanya on Jun 9, 2011 2:45 AM
Edited by: Chaitanya on Jun 9, 2011 2:46 AMDuplicate Post by mistake.
Please check
Query Tuning - using CASE statement in the WHERE clause
Edited by: Chaitanya on Jun 9, 2011 2:45 AM
Edited by: Chaitanya on Jun 9, 2011 2:46 AM -
Brief report of about 2 months for the sqls run under a specific user ?
Hi,
Is there a way i can get the brief report of about 2 months for the sqls run under a specific user in Oracle 11g.
thanks in advance913410 wrote:
Yes,
auditing is enabled
SQL> show parameter audit;
NAME TYPE VALUE
audit_file_dest string /u01/app/oracle/admin/PRCMTDB/
adump
audit_sys_operations boolean FALSE
audit_syslog_level string
audit_trail string DBthen how to get the informationabove is necessary, but not SUFFICIENT
default Oracle behavior is that NO specific actions are audited.
You would have had to manually enable AUDIT for all SQL statement by single user -
Can anybody tell me about SD Functionality and the main tables used in SD
Hi,
Can anybody tell me about SD Functionality and the main tables used in SD.
Thanks,
bsv.Hi
SD FLOW
SD Flow Cycle:
INQUIRY ( VA11)
|
QUOTATION (VA21)
|
PURCHASE ORDER (ME21)
|
ORDER CONFIRMATION (VA01)
|
PICKING LIST (VL36)
|
PACKING LIST - (VL02, VL01)
|
SHIPPING (VT01)
|
INVOICE (VF21, VF01)
|
AR
Enquiry - Customer enquires about the Products services that were sold by a company - VA11
Quotation - Company Gives a Quotation for the products and Services to a Customer
Sales Order - Customer gives a Purchase order to the company agaionst which a Sales order will be raised to Customer in SAP.
VBAK: Sales Document(Header Data) (VBELN)
VBAP: Sales Document(Item Data) (VBELN,POSNR,MATNR,ARKTX,CHARG)
Enquiry, Quotation, Sales Order are differentiated based on Doc.
Type(VBTYP field) in VBAK,VBAP Tables( for Enquiry VBTYP = A,
for Quotation 'B' & for Order it is 'C'.)
Delivery(Picking, Packing, Post Goods Issue and Shipment)->
Company sends the material after picking it from Godown and Packing it in a Handling Unit(box) and Issues the goods
LIKP: Delivery Table (Header Data)(VBELN,LFART,KUNNR,WADAT,INCO1)
LIPS: Delivery Table (Item Data)(VBELN,POSNR,WERKS,LGORT,MATNR,VGBEL)
(LIPS-VGBEL = VBAK-VBELN, LIPS-VGPOS = VBAP-POSNR)
Billing - Also company bills to the customer for those deliveries
And in FI against this billing Accounting doc is created.
VBRK: Billing Table(Header Data)(VBELN,FKART,BELNR)
VBRP: Billing Table(Item Data)(VBELN,POSNR,FKIMG,NETWR,VGBEL,VGPOS)
(VBRP-AUBEL = VBAK-VBELN, VBRP-VGBEL = LIKP-VBELN)
Apart from these tables there are lot of other tables which starts with
V, but we use the following tables frequently.
other tables and imp fields
VBUK: All Sales Documents status & Admn. Data(Header)(VBELN,VBTYP)
VBTYP= C(Sales Order) VBTYP=J(Delivery) VBTYP=M(Invoice)
VBUP: Sales Documents status & Admn. Data(Item)(VBELN,POSNR)
VBEP: Sales Doc. Schedule Lines Data(VBELN,POSNR,EDATU,WMENG)
VBKD: To get sales related Business data like Payment terms etc.(VBELN,ZTERM)
VBFA: sales document flow data(VBELV,VBELN,POSNV,VBTYP)
VBPA: Partner functions Data(VBELN,PARVW,KUNNR,LIFNR)
VEDA: Contract Data(VBELN,VPOSN)
VEDAPO: Contract Data(VBELN,VPOSN)
KONA: Rebate Agreements (KNUMA,VKORG,VTWEG,SPART)
VBRL: SD Document: Invoice List(VBELN,POSNR,VBELN_VF,NETWR,KUNAG)
VKDFS: SD Index: Billing Indicator(FKTYP,VBELN,FKART,VKORG)
VBSK: Collective Processing for a Sales Document Header(SAMMG,SMART)
VBSS: Collective Processing: Sales Documents(SAMMG,VBELN,SORTF)
VRKPA: Sales Index: Bills by Partner Functions(VBELN,BELNR,KUNDE,PARVW)
VRPMA: SD Index: Billing Items per Material(MATNR,VBELN,BELNR,KUNNR)
TVLKT: Delivery Type: Texts(LFART,VTEXT)
KNA1: Customer Master-General(KUNNR,NAME1,LAND1)
KNB1: Customer Master(Company Code)(KUNNR,BUKRS,PERNR)
KNC1: Customer Master Data (Transaction Figures)(KUNNR,BUKRS,GJAHR)
KNVK: Customer Master Contact Partner(PARNR,KUNNR,NAME1)
KNVV: Customer Master sales data(KUNNR,VKORG,VTWEG,KDGRP)
KNBK: Customer Bank Details(KUNNR,BANKS,BANKL,BANKN)
KNVH: Customer Hierarchy (HITYP,KUNNR,VKORG,VTWEG,SPART)
KNVP: Customer Master Partner Functions(KUNNR,PARVW,KUNN2)
KNVS: Customer Shipment data(KUNNR,VSTEL,TRANS)
KNVI: Customer Tax data(KUNNR,ALAND,TATYP)
LFA1: Vendor Master-General (LIFNR,NAME1,ORT01)
LFB1: Vendor Master(Company Code)(LIFNR,BUKRS,PERNR)
LFC1: Vendor Master (Transaction Figures)(LIFNR,BUKRS,GJAHR)
MARA: Material Master-General (MATNR,MTART,MATKL)
MARC: Material Master-Plant data(MATNR,WERKS,EKGRP)
MARD: Material Master- St.Location Data(MATNR,WERKS,LGORT,LABST)
EBEW: Sales Order Stock Valuation(MATNR,VBELN,BWKEY,BWTAR)
TVKO: Sales Organizations(VKORG)
TVTW: Distribution Channel(VTWEG)
TSPA: Divisions(SPART)
TVKOV: Distribution Channels for S.Orgn(VKORG,VTWEG)
TVKOS: Divisions for S.Orgn(VKORG,SPART)
TVTA: Sales Areas(VKORG,VTWEG,SPART)
TVBUR: Sales Offices(VKBUR,ADRNR)
TVKBT: Sales Office Texts(VKBUR,SPRAS,BEZEI)
TVKBZ: Sales Office Assign.to Sales Area(VKORG,VTWEG,VKBUR)
TVKGR: Sales Group(VKGRP)
TVGRT: Sales Group Texts(VKGRP,SPRAS,BEZEI)
TVBVK: Sales Group to Sales office(VKBUR,VKGRP)
TVKWZ: Plants Assign.to S.Orgn(WERKS,VKORG)
T171T: Sales District Texts(BZIRK,BZTXT,SPRAS)
TVLA: Loading Points(LSTEL)
TVST: Shipping Points (VSTEL)
TVSWZ: Shipping Point to Plant(VSTEL,WERKS)
TVPT: Item Categories (PSTYV)
TINC: Customer Incoterms(INCO1)
T077D: Customer Account Group (KTOKD)
T001W: Plants (WERKS)
T001L: Storage Locations (LGORT)
T499S: Locations(WERKS,STAND,KTEXT)
TWLAD: To get address of Storage Location and Plant(LGORT,ADRNR)
TVAK: Sales Document (Order) Types (AUART)
TVAU: Sales Documents: Order Reasons (AUGRU)
TVFK: Billing Document Types (FKART)
TVLK: Delivery Types(LFART)
TVSB: Shipping Conditions (VSBED)
TTDS: Transportation Points(TPLST)
TVKT: Account Assignment Groups (KTGRD)
KONV: Condition Types pricing)(KNUMV,KSCHL,KWETR)
ADRC: To get Addresses of Partners(ADDRNUMBER,NAME1)
VBBE: Sales Requirements: Individual records(VBELN,POSNR,MATNR)
VBBS: Sales Requirement totals Record(MATNR,WERKS,LGORT,CHARG)
VBKA: Sales Activities Data(VBELN,KTAAR)
VBPV: Sales Document Product Proposal(VTWEG,MATNR,KUNNR,CHARG)
T682: Access Sequences (KOZGF)
T682T: Access Sequence Texts (KOZGF,VTXTM)
T683: Pricing Procedures (KALSM)
T683T: Pricing Procedures Texts(KALSM,KAPPL,SPRAS,VTEXT)
T685: Pricing Condition Types (KSCHL)
T685T: Condition Type Texts(KSCHL,SPRAS,KAPPL,VTEXT)
KONH: Conditions (Header)(KNUMH,KAPPL,KSCHL)
KONP: Conditions (Item)(KNUMH,KOPOS,KAPPL,KSCHL)
KONV: Conditions (Transaction Data)(KNUMV,KSCHL,KBERT,KWERT)
KOND: Conditions (KNUMD,ZUSKO,KSCHL)
for sd go through the links
http://www.sapgenie.com/abap/tables_sd.htm
Please check this SD online documents.
http://help.sap.com/printdocu/core/Print46c/en/data/pdf/CAARCSD/CAARCSD.pdf
http://help.sap.com/printdocu/core/Print46c/en/data/pdf/MYSAP/SR_SD.pdf
http://help.sap.com/printdocu/core/Print46c/en/data/pdf/BCBMTWFMSD/BCBMTWFMSD.pdf
http://help.sap.com/printdocu/core/Print46c/en/data/pdf/LOLISPLN/LOLISPLN.pdf
Also please check this SD links as well.
http://help.sap.com/saphelp_47x200/helpdata/en/92/df293581dc1f79e10000009b38f889/frameset.htm
http://help.sap.com/saphelp_erp2005/helpdata/en/dd/55f33e545a11d1a7020000e829fd11/frameset.htm
http://www.sap-basis-abap.com/sapsd.htm
http://www.sap-img.com/sap-sd.htm
http://www.sapgenie.com/abap/tables_sd.htm
http://searchsap.techtarget.com/featuredTopic/0,290042,sid21_gci961718,00.html
http://www.sapbrain.com/TUTORIALS/FUNCTIONAL/SD_tutorial.html
All help ebooks are in PDF format here
http://www.easymarketplace.de/online-pdfs.php
Reward points if useful
Regards
Anji -
Is the lower case L and the upper case I different sizes?
Does the upper case I and the lower case L have a slightly different font on the iphone?
In the Mail and Messages apps, the upper case I (eye) looks slightly 'wider' than the lower case l (el).
FWIW, I have Bold Text on. -
I took my iphone 5 off charger this morning after it said 100% charged. went to use it and it promptly died and has not come back on. I have had it on the charger now for about 8 hrs and the pic of the battery shows up on screen but the charge status never changes. I have never had an issue like this and dont know what to do with it.
Hi there stace12171,
You may find the troubleshooting steps in the article below helpful.
iOS: Not responding or does not turn on
http://support.apple.com/kb/ts3281
-Griff W. -
So what do I do about my iPhone5 and the way my batterie dies?
So what do I do about my iPhone5 and the way my batterie dies?
perhaps you might have gone to the Apple Service Center to spend a BIG 1000 bucks on it !
-
Thank you for your attention
I want to check the status of application No. W439602096
For it is written in my account was canceled and I did not do so
I urgent news about his condition and the reason for canceled
I redial the same time as the sender before you
We are waiting for youThis is a user to user forum. You are not talking to Apple here. We cannot help you; you will need to contact wherever the order was placed.
-
Mm.mysql JDBC Driver and the WHERE clause
Anybody has succesfully performed a MySQL/JDBC query in a JSP application using more than one variable in the WHERE clause?
It works fine when I run queries with one fixed value assigned to a column and one variable assigned to the other column in the WHERE clause; but when I do it with more than one variable in the WHERE clause, it screws up throwing an error.
I wonder if it is a code error, a syntax error or if it is something tricky about the mm.mysql JDBC Driver. Following is a section of the code and the error. The variables are s_description and s_status. I read some examples in a book but they use SQL Server. Thank you in advance for any information.
CODE:
<% String sqlStatement = "" ; %>
<% String s_description = "Mexican Style Rice" ; %>
<% String s_status = "available" ; %>
<% java.sql.Statement stmt = con.createStatement(java.sql.ResultSet.TYPE_SCROLL_INSENSITIVE, java.sql.ResultSet.CONCUR_UPDATABLE); %>
<% java.sql.ResultSet rs ; %>
<% sqlStatement = "SELECT code, description, status FROM products WHERE products.description =" + s_description + " AND products.status =" + s_status + ";" ;%>
<% rs = stmt.executeQuery(sqlStatement); %>
<% rs.beforeFirst(); %>
<% while (rs.next()) { %>
<% rs.updateString(3, "sold"); %>
<% rs.updateRow(); %>
<% }%>
<% rs.close(); %>
This is the ERROR it throws
java.sql.SQLException: Column not found: Unknown column 'available' in 'where clause'
at org.gjt.mm.mysql.MysqlIO.sendCommand(MysqlIO.java:497)
at org.gjt.mm.mysql.MysqlIO.sqlQueryDirect(MysqlIO.java:550)
at org.gjt.mm.mysql.MysqlIO.sqlQuery(MysqlIO.java:635)
at org.gjt.mm.mysql.Connection.execSQL(Connection.java:882)
at org.gjt.mm.mysql.Connection.execSQL(Connection.java:815)
at org.gjt.mm.mysql.Statement.executeQuery(Statement.java:169)
at org.gjt.mm.mysql.jdbc2.Statement.executeQuery(Statement.java:78)
at pagecompile._GetFood_xjsp._jspService(_GetFood_xjsp.java:45)
at com.newatlanta.servletexec.JSP10HttpJspPage.service(JSP10HttpJspPage.java:41)
at com.newatlanta.servletexec.JSP10Servlet.service(JSP10Servlet.java:779)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at com.newatlanta.servletexec.ServletExec.CallServletService(ServletExec.java:1679)
at com.newatlanta.servletexec.ServletExec.processServletRequest(ServletExec.java:1654)
at com.newatlanta.servletexec.ServletExec.processServletAlias(ServletExec.java:1602)
at com.newatlanta.servletexec.ServletExec.ProcessRequest(ServletExec.java:1343)
at com.newatlanta.servletexec.ServletExec.ProcessRequest(ServletExec.java:1113)I think perhaps this sentence has problems:
<% sqlStatement = "SELECT code, description, status FROM products WHERE products.description =" + s_description + " AND products.status =" + s_status + ";" ;%>
You can
<% sqlStatement = "SELECT code, description, status FROM products WHERE products.description ='" + s_description + "' AND products.status = '" + s_status + "'" ;%>
You perhaps ignore the ���� when using String variable s_description and s_status.
Hope this will help you. Good lucky! -
Using CASE WHEN in PL/SQL package
I am trying to convert the values in a selected column into 1 and 0 so that I can display all 1s in one column, all 0s in another. I am doing this in a PL/SQL package. However ORACLE compiler does not like the CASE construct.
Does anyone know how to group values in a column into several new columns. If CASE WHEN construct is not doable in PL/SQL, what alternatives are there? Thanks.
/******* My package starts here *******/
CREATE OR REPLACE PACKAGE TEST_NEED AS
PROCEDURE procTEST_NEED(STARTING_DATE IN VARCHAR2);
END CVRR_MON_NEED;
CREATE OR REPLACE PACKAGE BODY TEST_NEED
AS
PROCEDURE procTEST_NEED(STARTING_DATE IN VARCHAR2)
IS
TEST_START DATE := TO_DATE(STARTING_DATE,'MM/DD/YYYY');
CURSOR v_Cursor IS
SELECT A.D_CODE, A.M_CODE, TEST_START , C.C_NAME,C.P_ID,
SUM(CASE WHEN MONTHS_BETWEEN(SYSDATE, D.P_DOB)/12 > 40 AND MONTHS_BETWEEN(SYSDATE, D.P_DOB)/12 <85 AND B.B_CODE IN '11.1','222.2','272.4') THEN 1 ELSE 0 END) QUALIFIED
FROM A, B, C, D
WHERE A.ID = B.B_ID
AND RTRIM(A.P_CODE) = C.P_CODE
AND A.P_ID = D.P_ID
AND A.P_ID < 99999999999999999999
AND A.E_DATETIME < SYSDATE
GROUP BY A.D_CODE, A.M_CODE, TEST_START , C.C_NAME,C.P_ID;
v_RecordHolder v_Cursor%ROWTYPE;
BEGIN
OPEN v_Cursor;
FETCH v_CursorINTO v_RecordHolder ;
WHILE v_Cursor%FOUND LOOP
look for records in another table with matching keys of the cursor
if found then update by incrementing the existing values in the matching records with values of the current currsor row
else insert the current cursor row
FETCH v_Cursor INTO v_RecordHolder ;
END LOOP;
END procTEST_NEED;
END TEST_NEED;I am trying to convert the values in a selected
column into 1 and 0 so that I can display all 1s in
one column, all 0s in another. I am doing this in a
PL/SQL package. However ORACLE compiler does not
like the CASE construct.
Does anyone know how to group values in a column into
several new columns. If CASE WHEN construct is not
doable in PL/SQL, what alternatives are there?
Thanks.
CURSOR v_Cursor IS
SELECT A.D_CODE, A.M_CODE, TEST_START ,
, C.C_NAME,C.P_ID,
SUM(CASE WHEN MONTHS_BETWEEN(SYSDATE, D.P_DOB)/12 >
40 AND MONTHS_BETWEEN(SYSDATE, D.P_DOB)/12 <85 ANDB.B_CODE IN '11.1','222.2','272.4') THEN 1 ELSE 0
END) QUALIFIEDUse the Decode function. This has been around in oracle SQL for ages and works like a case construct.
You would do something like
select ...
sum( decode (MONTHS_BETWEEN(SYSDATE, D.P_DOB)/12 >
40 AND MONTHS_BETWEEN(SYSDATE, D.P_DOB)/12 <85 AND
B.B_CODE IN ('11.1','222.2','272.4') 1,0 )
Maybe you are looking for
-
Hi All, I will soon be exporting my first APEX application from a development database to a test database. I do not want to export the data which the application is built on as the development database contains sample data instead of the "real" data.
-
What is the maximum level that a role can be resolved to?
hi folks can anyone tell me what is the maximum level at which expand role works. for example if i have a role which is then having 3 roles, each role has 2-3 users. will expand role work in this scenario? Also plz tell me why expand role does not wo
-
Just bought a new mac mini i7, do i have to buy mountain lion from app store to get a back up image in case i want to reinstall. or is there a way to reset to factory settings.
-
A Toplink Java code example in Jdev 10.1.2
Hello every body I have just begun using Toplink 10g in Jdev 10.1.2, and I want examples of Java code to insert, edit and show information from struts application whose model is Toplink. Thanks
-
Flash player ~12 on windows 8.1 insane lag
got a laptop.. Dell Inspiron 3737 it has 8gb ram and a i7 4th gen cpu. (seen a few palces its mentioned that 8,1 + i7 = bad performance while i was on windows 8 it was fine.. but since upgrading to 8.1 the flash player lags like crazy.. 1fps IF that.