In Mysql, FIND_IN_SET is used to find value in a set. I have tried FIND_IN_SET in SQLite, but it is not an SQL keyword. I have Googled, but I did not get an answer. If anybody knows, please tell me the alternative to FIND_IN_SET in SQLite.
If you need just a true / false value rather than index then you can use LIKE clause:
(',' || column_name || ',') LIKE '%,value,%'
we can write query like change into hibernate critearea
my old query
select * FROM game_detail WHERE content_id=176 and FIND_IN_SET(12,group_master_id)
New query
select *
FROM game_detail
WHERE content_id=176
and (group_master_id LIKE '%12,%'|| group_master_id LIKE '%,12,'|| group_master_id LIKE '%12')
This is my old query
String query = "SELECT a.content_id,a.content_name,a.image_name,a.image_path,a.rating,d.content_type_name"
+ "from content_master a, category_content_mapping b, "
+ "game_detail c, content_type_master d "
+ "where a.content_id=b.content_id "
+ "and c.content_id = a.content_id "
+ "and a.content_type_id = d.content_type_id "
+ "and b.category_id = '" + category_id + "' "
+ "and find_in_set('" + group_master_id + "',c.group_master_id) "
+ "and a.is_active='Y' and b.is_active = 'Y' and c.is_active = 'Y'"
+ "order by b.content_mapping_id DESC limit 0,3";
Criteria in hibernate use like alternate of find_in_set
Session session=new Configuration().configure().buildSessionFactory().openSession();
Criteria criteria=session.createCriteria(ContentMaster.class);
criteria.setFetchMode("CategoryContentMapping", FetchMode.JOIN);
criteria.setFetchMode("GameDetail", FetchMode.JOIN);
criteria.createAlias("categoryContentMappings","cat");
criteria.createAlias("contentTypeMaster", "ctm");
criteria.createAlias("gameDetails","game");
criteria.add(Restrictions.eq("cat.categoryMaster.categoryMasterId", 9));
criteria.add(Restrictions.disjunction()
.add(Restrictions.like("game.groupMasterId","%12,%"))
.add(Restrictions.like("game.groupMasterId","%,12,%"))
.add(Restrictions.like("game.groupMasterId","%12%")));
criteria.add(Restrictions.eq("isActive", "y"));
criteria.add(Restrictions.eq("cat.isActive", "y"));
criteria.add(Restrictions.eq("ctm.isActive", "y"));
criteria.addOrder(Order.desc("cat.contentMappingId"));
Every it-codigo has 1 or more es-codigo. I'm trying to find all the es-codigo of the it-codigo input, but it's taking too long. Did I do anything wrong in my code? For what I have seen, it's all right, unless there's something I don't know about that I'm doing wrong. Is QUERY-PREPARE() the best option in this case?
DEF VAR qEstrutura AS CHAR.
IF pi-cod-emitente <> 0 THEN DO:
qEstrutura = " WHERE item-cli.cod-emitente = " + QUOTER(pi-cod-emitente).
END.
IF pc-it-codigo <> "" THEN DO:
IF qEstrutura = "" THEN
qEstrutura = " WHERE estrutura.it-codigo = " + QUOTER(pc-it-codigo).
ELSE
qEstrutura = qEstrutura + " AND estrutura.it-codigo = " + QUOTER(pc-it-codigo).
END.
IF pc-item-cli <> "" THEN DO:
IF qEstrutura = "" THEN
qEstrutura = " WHERE item-cli.item-do-cli = " + QUOTER(pc-item-cli).
ELSE
qEstrutura = qEstrutura + " AND item-cli.item-do-cli = " + QUOTER(pc-item-cli).
END.
cQuery = cQuery + " FOR EACH item-cli, ".
cQuery = cQuery + " EACH estrutura ".
cQuery = cQuery + qEstrutura + " BREAK BY estrutura.es-codigo".
QUERY qConsulta:QUERY-PREPARE(cQuery).
QUERY qConsulta:QUERY-OPEN().
GET FIRST qConsulta.
DO WHILE AVAILABLE item-cli:
IF QUERY qConsulta:FIRST-OF(1) THEN DO:
CREATE tt-estrutura.
ASSIGN
tt-estrutura.it-codigo = estrutura.it-codigo
tt-estrutura.es-codigo = estrutura.es-codigo
.
GET NEXT qConsulta.
END.
END.
QUERY qConsulta:QUERY-CLOSE().
FOR EACH tt-estrutura:
DISP tt-estrutura.
END.
I believe it's the QUERY-OPEN() that takes time. Not QUERY-PREPARE().
Your query is only performing selection (WHERE) and sort (BY) on the second table. That makes is difficult to utilize indizes. The OpenEdge ABL query engine does not support flipping the buffer-sequence. Try turning the query around:
FOR EACH estrutura WHERE ......, FIRST item-cli.
We have custom functionality in PeopleSoft FSCM that generates an email notification with a link to direct users to approve vouchers online. I have found part of the text string variable that compose the email message within the following Record PeopleCode, however I can not seem to find where the actual outbound email object is created and Send method is being called and using the &EMAIL_TEXT variable. I've done Find In searches for the variable but that has not led me to the code that generates the emails. Any suggestions for how to find it is appreciated!
Here is the code snippet with the email body variable:
&EMAIL_TEXT = "Please review and take approval action for the following:" | Char(10) | "Business Unit: " | VCHR_APPRVL.BUSINESS_UNIT.Value | Char(10) | "Voucher ID: " | VCHR_APPRVL.VOUCHER_ID | Char(10) | Char(10) | Char(10);
&EMAIL_TEXT = &EMAIL_TEXT | "The following hyperlink will take you to the voucher approval page:" | Char(10);
&URL = GenerateComponentPortalURL("EMPLOYEE", Node.ERP, MenuName.ENTER_VOUCHER_INFORMATION, "GBL", Component.VCHR_APPROVE, Page.VCHR_APPRVL_WF, "U", VCHR_APPRVL.BUSINESS_UNIT, VCHR_APPRVL.VOUCHER_ID);
&EMAIL_TEXT = &EMAIL_TEXT | &URL | Char(10);
&EMAIL_TEXT = &EMAIL_TEXT | Char(10) | Char(10);
&EMAIL_TEXT = &EMAIL_TEXT | "Questions pertaining to this data should be directed to AccountsPayable_GH#guthrie.org" | Char(10);
&EMAIL_TEXT = &EMAIL_TEXT | Char(10) | Char(10);
&EMAIL_TEXT = &EMAIL_TEXT | "****DO NOT REPLY TO THIS EMAIL AS THIS ACCOUNT IS NOT MONITORED****" | Char(10);
&EMAIL_TEXT = &EMAIL_TEXT | Char(10) | Char(10);
GH_VCHR_APR_WRK.EMAILTEXT.Value = &EMAIL_TEXT;
Here is the entire Record PeopleCode (for context) on the field BUSPROCNAME with the SaveEdit action:
Declare Function virtual_approver PeopleCode APPR_VA0_WRK.FUNCLIB_01 FieldFormula;
Declare Function get_roleuser PeopleCode APPR_VA0_WRK.ROLEUSER FieldChange;
Declare Function get_message_text PeopleCode WF_FUNCLIB_WRK.FUNCLIB_01 FieldFormula;
Component boolean &overrideapprover;
Function get_denial_role();
&SETID = GetSetId(Field.BUSINESS_UNIT, VCHR_APPRVL.BUSINESS_UNIT, Record.BUS_UNIT_OPT_AP, "");
&CURRDATE = %Date;
SQLExec("Select a.rolename from ps_bus_unit_opt_ap a where a.setid = :1 and a.effdt = (Select max(b.effdt) from ps_bus_unit_opt_ap b where b.setid = :2 and b.effdt <= %datein(:3) and b.eff_status = 'A')", &SETID, &SETID, &CURRDATE, APPR_FIELDS_WRK.ROLENAME);
End-Function;
Function get_deptid(&BU, &Voucher_ID, &Dept_Cnt, &DEPTID);
Local SQL &SQL_DEPTID;
&Dept_Cnt = 0;
/* If &VOUCHER_STYLE = "JRNL" Or
&VOUCHER_STYLE = "CORR" Or
&VOUCHER_STYLE = "ADJ" Then
MessageBox(0, "", 0, 0, "Jrnl or Adj or Reversal. So assigning 99999", 0);
&DEPTID = "99999";
&Dept_Cnt = 1;
Else */
SQLExec("SELECT DEPTID FROM PS_GH_VCHAPPR_DEPT WHERE BUSINESS_UNIT = :1 AND VOUCHER_ID = :2", &BU, &Voucher_ID, &DEPTID);
If All(&DEPTID) Then
&Dept_Cnt = 1;
Else
&SQL_DEPTID = CreateSQL("SELECT DISTINCT DEPTID FROM PS_DISTRIB_LINE A, PS_PO_LINE B WHERE A.BUSINESS_UNIT = :1 AND VOUCHER_ID = :2 AND A.BUSINESS_UNIT_PO = B.BUSINESS_UNIT AND A.PO_ID = B.PO_ID AND A.LINE_NBR = B.LINE_NBR AND B.RECV_REQ <> 'Y'", &BU, &Voucher_ID);
While &SQL_DEPTID.Fetch(&DEPTID_Fetch)
&Dept_Cnt = &Dept_Cnt + 1;
&DEPTID = &DEPTID_Fetch;
End-While;
End-If;
rem End-If;
End-Function;
/* ---------------- beginning of mainline --------------------------*/
/* ICE 597971000 - TMG - 06/17/03 */
/* Check if nothing has changed on the approval status */
If Not FieldChanged(VCHR_APPRVL.APPR_STATUS) Then
Error MsgGet(7045, 5, "The approval status has not been changed/updated, page cannot be saved until the approval status has been modified.!");
End-If;
If VCHR_APPRVL.APPR_STATUS = "D" And
VCHR_FS.APPR_INSTANCE = 0 Then
Error MsgGet(7045, 7, "The voucher cannot be Denied until it has been routed.");
End-If;
/* ICE 531713000 - TMG - 12/13/02 */
/* Check if voucher status has changed */
rem SQLExec("SELECT ENTRY_STATUS, CLOSE_STATUS, PROCESS_MAN_CLOSE FROM PS_VOUCHER WHERE BUSINESS_UNIT = :1 AND VOUCHER_ID = :2", VCHR_APPRVL.BUSINESS_UNIT, VCHR_APPRVL.VOUCHER_ID, &ENTRY_STATUS, &CLOSE_STATUS, &PROCESS_MAN_CLOSE);
SQLExec("SELECT ENTRY_STATUS, CLOSE_STATUS, PROCESS_MAN_CLOSE, VOUCHER_STYLE FROM PS_VOUCHER WHERE BUSINESS_UNIT = :1 AND VOUCHER_ID = :2", VCHR_APPRVL.BUSINESS_UNIT, VCHR_APPRVL.VOUCHER_ID, &ENTRY_STATUS, &CLOSE_STATUS, &PROCESS_MAN_CLOSE, &VOUCHER_STYLE);
If &ENTRY_STATUS = "P" And
&CLOSE_STATUS <> "C" And
&PROCESS_MAN_CLOSE <> "Y" Then
/* Check if worklist item has been cancelled */
&INSTANCEID = %WLInstanceId;
If All(&INSTANCEID) Then
SQLExec("SELECT MAX(A.ACTIVITYNAME), MAX(A.EVENTNAME), MAX(A.WORKLISTNAME) FROM PS_VCHR_WL1 A, PSWORKLIST B WHERE A.BUSPROCNAME = B.BUSPROCNAME AND A.ACTIVITYNAME = B.ACTIVITYNAME AND A.EVENTNAME = B.EVENTNAME AND A.WORKLISTNAME = B.WORKLISTNAME AND A.INSTANCEID = B.INSTANCEID AND A.BUSPROCNAME = :1 AND A.BUSINESS_UNIT = :2 AND A.VOUCHER_ID = :3 AND A.INSTANCEID = :4", VCHR_APPRVL.BUSPROCNAME, VCHR_APPRVL.BUSINESS_UNIT, VCHR_APPRVL.VOUCHER_ID, &INSTANCEID, &ACTIVITYNAME, &EVENTNAME, &WORKLISTNAME);
SQLExec("SELECT INSTSTATUS FROM PSWORKLIST WHERE BUSPROCNAME = :1 AND ACTIVITYNAME = :2 AND EVENTNAME = :3 AND WORKLISTNAME = :4 AND INSTANCEID = :5", VCHR_APPRVL.BUSPROCNAME, &ACTIVITYNAME, &EVENTNAME, &WORKLISTNAME, &INSTANCEID, &INSTSTATUS);
If &INSTSTATUS = 3 Then
Error MsgGet(7045, 4, "Voucher approval status cannot be changed because worklist item has been cancelled.")
End-If;
End-If;
Else
Error MsgGet(7045, 3, "Voucher approval status cannot be changed because voucher status has changed.");
End-If;
/* If (APPR_STATUS = "A" And
%MessageAgent = "") Or
(APPR_STATUS = "P" And
%MessageAgent <> "") Then */
If VCHR_APPRVL.APPR_STATUS = "A" And
%CompIntfcName <> "" Or
VCHR_APPRVL.APPR_STATUS = "D" Then
If &overrideapprover = True Then
rem &OPRID = ""; /*custom commented this line and added the next*/
&OPRID = VCHR_FS.OPRID;
Else
&OPRID = %OperatorId;
End-If;
get_roleuser(&OPRID, &EMAILID, &FORMID, &EMPLID, &ROLEUSER);
rem the following four fields are required;
APPR_FIELDS_WRK.BUSPROCNAME = VCHR_APPRVL.BUSPROCNAME;
APPR_FIELDS_WRK.APPR_RULE_SET = VCHR_APPRVL.APPR_RULE_SET;
APPR_FIELDS_WRK.ROLEUSER = &ROLEUSER;
APPR_FIELDS_WRK.APPR_INSTANCE = VCHR_APPRVL.APPR_INSTANCE;
SQLExec("SELECT GH_BUSINESS_UNIT_O FROM PS_GH_VCHAPPR_DEPT WHERE BUSINESS_UNIT = :1 AND VOUCHER_ID = :2", &BU, &Voucher_ID, &GH_BUSINESS_UNIT_O); */
SQLExec("SELECT GH_BUSINESS_UNIT_O FROM PS_GH_VCHAPPR_DEPT WHERE BUSINESS_UNIT = :1 AND VOUCHER_ID = :2", VCHR_APPRVL.BUSINESS_UNIT, VCHR_APPRVL.VOUCHER_ID, &GH_BUSINESS_UNIT_O);
VCHR_APPRVL_WRK.GH_BUSINESS_UNIT_O.Value = &GH_BUSINESS_UNIT_O;
get_deptid(VCHR_APPRVL.BUSINESS_UNIT, VCHR_APPRVL.VOUCHER_ID, &Dept_Cnt, &DEPTID);
&EMAIL_TEXT = "Please review and take approval action for the following:" | Char(10) | "Business Unit: " | VCHR_APPRVL.BUSINESS_UNIT.Value | Char(10) | "Voucher ID: " | VCHR_APPRVL.VOUCHER_ID | Char(10) | Char(10) | Char(10);
&EMAIL_TEXT = &EMAIL_TEXT | "The following hyperlink will take you to the voucher approval page:" | Char(10);
&URL = GenerateComponentPortalURL("EMPLOYEE", Node.ERP, MenuName.ENTER_VOUCHER_INFORMATION, "GBL", Component.VCHR_APPROVE, Page.VCHR_APPRVL_WF, "U", VCHR_APPRVL.BUSINESS_UNIT, VCHR_APPRVL.VOUCHER_ID);
&EMAIL_TEXT = &EMAIL_TEXT | &URL | Char(10);
&EMAIL_TEXT = &EMAIL_TEXT | Char(10) | Char(10);
&EMAIL_TEXT = &EMAIL_TEXT | "Questions pertaining to this data should be directed to AccountsPayable_GH#guthrie.org" | Char(10);
&EMAIL_TEXT = &EMAIL_TEXT | Char(10) | Char(10);
&EMAIL_TEXT = &EMAIL_TEXT | "****DO NOT REPLY TO THIS EMAIL AS THIS ACCOUNT IS NOT MONITORED****" | Char(10);
&EMAIL_TEXT = &EMAIL_TEXT | Char(10) | Char(10);
GH_VCHR_APR_WRK.EMAILTEXT.Value = &EMAIL_TEXT;
If None(&DEPTID) Then
REM VCHR_APPRVL_WRK.DEPTID.Value = "99999";
MessageBox(0, "", 0, 0, "No Deptid. So assigning 99999", 0);
VCHR_APPRVL_WRK.DEPTID.Value = "99999";
Else
VCHR_APPRVL_WRK.DEPTID.Value = &DEPTID;
End-If;
If VCHR_APPRVL.APPR_STATUS = "D" Then
APPR_FIELDS_WRK.APPR_ACTION = "D";
Else
APPR_FIELDS_WRK.APPR_ACTION = "A";
End-If;
If VCHR_APPRVL.APPR_STATUS = "A" Then
VCHR_APPRVL.APPR_STATUS = "P";
End-If;
virtual_approver();
If &overrideapprover = True Then
&overrideapprover = False;
End-If;
VCHR_APPRVL.APPR_CHECK_FLG = "Y";
rem;
VCHR_APPRVL.APPR_STATUS = APPR_FIELDS_WRK.APPR_STATUS;
remark set up the message for e-mail if denied;
If VCHR_APPRVL.APPR_STATUS = "D" Then
&LANGUAGE_CD = PSOPTIONS.LANGUAGE_CD;
&MESSAGE_SET_NBR = 7045;
&MESSAGE_NBR = 2;
&BIND1 = VCHR_FS.BUSINESS_UNIT | "/" | VCHR_FS.VOUCHER_ID;
&BIND2 = APPR_FIELDS_WRK.ROLEUSER;
&BIND3 = VCHR_FS.VENDOR_ID | ", " | VENDOR.NAME1;
&BIND4 = VCHR_FS.INVOICE_ID | " (" | VCHR_FS.INVOICE_DT | ")";
&BIND5 = VCHR_FS.GROSS_AMT | "(" | VCHR_FS.TXN_CURRENCY_CD | ")";
get_message_text(&MESSAGE_SET_NBR, &MESSAGE_NBR, &BIND1, &BIND2, &BIND3, &BIND4, &BIND5, &MESSAGE_TEXT, &DESCRLONG);
UpdateValue(VCHR_APPRVL_MSG.EMAIL_SUBJECT_LONG, 1, &DESCRLONG);
UpdateValue(VCHR_APPRVL_MSG.EMAIL_TEXTLONG, 1, &MESSAGE_TEXT);
remark get the role to send denials to;
get_denial_role();
VCHR_APPRVL_WRK.RTE_CNTL_TYPE1 = "Business Unit";
VCHR_APPRVL_WRK.RTE_CNTL_TYPE2 = "Administrative Area";
VCHR_APPRVL_WRK.WF_ADMIN_AREA = "AP";
VCHR_APPRVL_WRK.ROLENAME = APPR_FIELDS_WRK.ROLENAME;
End-If;
End-If;
The email text is being saved into a work record field, so the sendmail call doesn't have to be in this event. (It isn't in the code you provided)
In the Component Processor Flow, after SaveEdit there's SavePreChange, Workflow and SavePostChange, but since it is saved in a work record, it's also possible that additional user input is required after the Save Processing flow and therefor it could literally be anywhere.
Have a query like this,
select *
from job_profile
where case
when exists (
select 1
from job_profile
where screening_type_id = 2 and job_category_id = 4
)
then screening_type_id = 2 and job_category_id = 4
else screening_type_id =4
end;
which I need to write this in JPA.
String GET_JOB_VACCINATIONS_BY_JOB_CAT_ID_AND_SCRN_TYPE_ID = "SELECT jobvacc FROM JobVaccination jobvacc WHERE CASE"
+ " WHEN EXISTS ( SELECT 1 FROM JobVaccination jobvacc2 WHERE jobvacc2.jobCategoryMast.jobCategoryId=:jobCategoryId AND jobvacc2.screeningTypeMast.screeningTypeId=:screeningTypeId )"
+ " THEN jobvacc.jobCategoryMast.jobCategoryId=4 AND jobvacc.screeningTypeMast.screeningTypeId=2 "
+ " ELSE jobvacc.screeningTypeMast.screeningTypeId=2"
+ " END";
Tried this way which throws exception like "Caused by: org.hibernate.hql.internal.ast.QuerySyntaxException: unexpected token: = near line 1, column 260 [SELECT............."
Cant we write the case queries in JPA ?
Refereed this link https://en.wikibooks.org/wiki/Java_Persistence/JPQL_BNF#New_in_JPA_2.0 which says yes.
I have a page where the user can select a lot of check boxes, and then have each of the values they select get inserted into a database. I'm using a querystring to submit the values from the inital page to a post page.
The values are pipe-delimited, and the stored procedure runs for every one of them. I also have an integer I submit to the database as well.
A couple problems - first of all, on occasion I get a mid "invalid procedure call" error. And other times, it seems I am submitting way too many characters for the QueryString and so it gets truncated and not all the values get submitted.
Any help is appreciated. Thanks!
The main page that submits the values - Javascript:
function submit()
{
var n = 0;
var stringIDs = "";
//Number of records to submit stored in hidden text box.
for (n=1; n<=parseInt(document.getElementById("txtResultsIndex").value); n++)
{
try
{
var cb = document.getElementById("cbSelection"+n);
if (cb.checked)
{
stringIDs = stringIDs + "|" + document.getElementById("linkNumber"+n).innerText;
}
}
catch(exception)
{}
}
window.open("submit.asp?stringIDs=" + stringIDs + "|&cboResearchedBy=" + document.getElementById("cboResearchedBy").value);
}
The post page classic ASP (where the error seems to be originating):
Dim vSQLInsert, v1ID, RS, stringIDs, cboResearchedBy, CN
'GetDataConnection is included in header file.
Set CN = GetDataConnection
stringIDs = Request.QueryString("stringIDs")
cboResearchedBy = Request.QueryString("cboResearchedBy")
stringIDs = Mid(stringIDs,2,len(stringIDs))
Do While stringIDs <> ""
v1ID = Mid(stringIDs,1,InStr(stringIds,"|")-1)
'Insert data into main table.
vSQLInsert = "spInsert "
vSQLInsert = vSQLInsert & "#vResearchedBy = '" & cboResearchedBy & "',"
vSQLInsert = vSQLInsert & "#vSequenceNumber = '" & v1ID & "'"
Set RS = CN.Execute (vSQLInsert)
stringIDs = Replace(stringIDs, v1ID & "|","")
Loop
Remove Mid function. Place values in a text box to submit to the post page in an array, using a for each loop. Page still takes some time to submit, but no errors result.
vIndex = stripquotes(Request.Form("txtIndex"))
If Request.Form("cboResearchedBy") <> "" Then
vResearchedBy = stripquotes(Request.Form("cboResearchedBy"))
End If
If Request.Form("txtMySeq") <> "" Then
txtMySeq = Request.Form("txtMySeq")
End If
vSeqArray = Split(txtMySeq, "|")
For Each vSeq In vSeqArray
vSQLInsert = "Insert "
vSQLInsert = vSQLInsert & "#vResearchedBy = '" & vResearchedBy & "',"
vSQLInsert = vSQLInsert & "#vSequenceNumber = '" & vSeq & "'"
Response.Write(vSQLInsert)
Set RS = CN.Execute (vSQLInsert)
Next