Wasnt really sure how to phrase this title, every time I think I have this figured out it always comes back to trip me up.
I am using B1 Boyum and storing a string in a variable.
The code looks like this
#STORE30 = '(T3.ItmsGrpNam LIKE 'Comm%%' OR T3.ItmsGrpNam = 'Vended Ancillary' OR T3.ItmsGrpNam = 'Merchant Fee and CC' OR T3.ItmsGrpNam = 'Laundry P&A')'
However this gives me unexpected END errors, ive tried escaping with + on either side of the first one ('Comm%%') which doesnt give me the unexpected end error but stops the string at T3.ItmsGrpNam LIKE
I need to have the whole string including the apostrophes of each of in between.
One day I will get the hang of this, happy to read some resources on best practices if someone can also supply some links.
Did you try this?
#Store30 = '(T3.ItmsGrpNam LIKE ''Comm%%'' OR T3.ItmsGrpNam = ''Vended Ancillary'' OR T3.ItmsGrpNam = ''Merchant Fee and CC'' OR T3.ItmsGrpNam = ''Laundry P&A'')'
When you want to escape the single quotes just use a double single quotes there.
Figured it out
#STORE30 = SQL(SELECT 'T3.ItmsGrpNam LIKE ''Comm%%'' OR T3.ItmsGrpNam = ''Vended Ancillary'' OR T3.ItmsGrpNam = ''Merchant Fee and CC'' OR T3.ItmsGrpNam = ''Laundry P&A''')
Related
I am trying to get rid of "40-S8-7710" Within the string without specifically giving the replace function "40-S8-7710" due to the fact there will be other strings that may contain "50-S2-7710", "11-42-7710" etc..
The code below removes "40-S8-7710" but it also removes everything after.
I am wanting to return "10-7190 20-2071 30-2061 S1-AOUT04X188"
Any Ideas?
Dim NewString As String
Set NewString = "10-7190 20-2071 30-2061 40-S8-7710 S1-AOUT04X188"
NewString = Replace(NewString , Mid(NewString , InStr(NewString , "7710") - 6), "")
MsgBox(NewString)
I was able to figure out how perform the action i was looking for by doing this
NewString= (Replace(NewString, (Mid(NewString, (InStr(NewString, "7710") - 7), 11)), ""))
This would return "10-7190 20-2071 30-2067 S1-AOUT04X188"...... "7710" is the only unique number I could use to pull since the 6 characters to the left of "7710" could be different depending what a user enters. Thanks for the help though.
Left([string],24)+Right([string],13)
sqldf('Select a.guest_id,case when b.guest_id is not null then 'old' else 'new' end as tagging from JDUniqueGuestid as a
left join UniqueGuestidallsource b
ON a.guest_id = b.guest_id', drv="SQLite")
After running the above code getting below mentioned error, kindly help me and resolve the issue
Error: unexpected symbol in " ON a.guest_id"
You have single quotes around the whole query, but also single quotes within the query; it's not being parsed the way you intend it to.
Depending on the larger context, something like this might work:
"Select a.guest_id, case ... 'old' else 'new' ... ON a.guest_id = b.guest_id"
or you might need to escape the single quotes with something like this:
'Select a.guest_id, case ... \'old\' else \'new\' ... ON a.guest_id = b.guest_id'
It depends on the context in which that query string appears, and how it parses quoted strings.
The following code I have written works find. Outputs what I expect.
select distinct
mi_tm.st_event_time,
mi_tm.st_location,
mi_tm.st_log_class,
mi_tm.st_qty,
mi_tm.st_reason,
mi_tm.st_reason_data,
mi_tm.st_sku_code,
mi_tm.st_ulid,
mi_tm.st_user_id,
x_prod.description,
x_supplier.supplier_name
from
mi_tm, x_prod,
x_igd, x_supplier
where
mi_tm.st_date >= {?Start} and
mi_tm.st_date <= {?End} and
mi_tm.st_sku_code = x_prod.prod_code (+) and
mi_tm.st_sku_code = x_igd.prod_code (+) and
x_igd.supplier_no = x_supplier.supplier_no (+) and
mi_tm.st_sku_code like '{?SKU}' and
mi_tm.st_log_class in ('TM_ADJUST_QTY', 'TM_CREATE', 'TM_DELETE')
However for this line
mi_tm.st_sku_code like '{?SKU}' and
I would like it to be able to expect a wildcard parameter, that will return all values run between the dates. Just querying a % seems to crash my report. and I have tried adding '%' around the parameter. But I either get an invalid number error, or SQL not ended properly. I would be grateful for any help on this issue.
Edit: Place this at the bottom
If {?SKU} = '*' then
mi_tm.st_sku_code like '*'
else mi_tm.st_sku_code like '{?SKU}'
Good day.
I am executing a query and encountering:
ORA-01861 literal does not match format string error.
I executed this query and IT WORKED.
SELECT * FROM GCACC_OPERATION_DETAIL WHERE id_notice in (75078741)
AND id_analytical_center in (100000002)
AND interface_date = '2013-06-30'
AND generic_client = 'someGenClient'
AND document_class = 'DOCCLA0001'
AND accounting_tag_identifier = 1
AND generated_actual_acc_doc
IN (select id_accounting_document
from gcacc_accounting_document
where document_status = 'DOCSTA0001');
My other query is written below which DID NOT WORK.
SELECT * FROM GCACC_OPERATION_DETAIL WHERE id_notice IN (75078741)
AND id_analytical_center in (100000002)
AND generic_client = 'someGenClient'
AND document_class = 'DOCCLA0001'
AND accounting_tag_identifier = 1
AND interface_date = '2013-06-30'
AND ind_pending_process = 1
AND operation_type
IN (select cod_develop from gcacc_operation_type where ind_operation = 'B');
This is really weird because the error happens in the date part but I am writing the same syntax for the date part. I maybe missing something silly here and fresher eyes are needed. Thanks in advance!
I don't know what the specific problem is, but assuming "interface_date" is a DATE type, it is bad practice to use literals in a query for a date. This makes the assumption that the default NLS_DATE_FORMAT agrees with your date literal. That will come back to bite you. To ensure that your date constraint is portable, change to this:
AND interface_date = to_date('2013-06-30','YYYY-MM-DD')
This request works as intended:
select dit_in.id data_item_in, dit_out.id data_item_out, alg.id algo_id
from algorithm_run arun
join algorithm_run_of arof on
arof.algorithm_run_id = arun.id
join algorithm_run_input arin on
arin.algorithm_run_id = arun.id
join data_item dit_in on
dit_in.id = arin.data_item_id
join algorithm alg on
alg.id = arof.algorithm_id
join algorithm_run_output arout on
arout.algorithm_run_id = arun.id
join data_item dit_out on
dit_out.id = arout.data_item_id
where alg.id in (182,183,143,162,125,222)
Unfortunately I get an error when I add at the end:
and arun.start_time >= to_date(’01/jun/2011’,’dd/mm/yyyy’)
and arun.start_time < to_date(’01/jul/2011’,’dd/mm/yyyy')
I'm using a web interface, the error message is:
warning: oci_execute() [function.oci-execute]: ORA-00911: invalid character in /opt/csw/apache2/share/htdocs/DAE/sites/default/modules/data_repository/data_repository.inc on line 117.
warning: oci_fetch_row() [function.oci-fetch-row]: ORA-24374: define not done before fetch or execute and fetch in /opt/csw/apache2/share/htdocs/DAE/sites/default/modules/daedatabase/daedatabase_db.inc on line 852.
and arun.start_time < to_date(’01/jul/2011’,’dd/mm/yyyy')
Do I see two different types of quote characters around that last bit? A single quote and a backquote? Or is that just a cut/paste or translation problem?
Try this:
and arun.start_time >= to_date(’01/06/2011’,’dd/mm/yyyy’)
and arun.start_time < to_date(’01/07/2011’,’dd/mm/yyyy’)
or
and arun.start_time >= to_date(’01/jun/2011’,’dd/mon/yyyy’)
and arun.start_time < to_date(’01/jul/2011’,’dd/mon/yyyy’)
The problem is that your date string (01/jun/2011) doesn't match the format specifier (dd/mm/yyyy). You need to either change your date or the specifier, as the above examples show.
As Phil points out, your strings are wrapped in two different quotes marks. It looks like you're mainly use fancy quote marks, from a word processor. This is a problem, because Oracle is expecting plain ASCII apostrophes (ASCII 39).
It would certainly explain why you're getting an ORA-00911 error.
To fix this, you simply need to replace all the ’ with ' .
To avoid it in the future you should use a text editor or IDE when writing code.