I created an ExecuteSQL Calculation:
ExecuteSQL ( "SELECT BaseRent FROM obj_Unit_CurrentRenter_RentAmount WHERE RenterUnitID = ? AND CurRent = 1" ; "," ; ""; RenterUnitID)
I've verified that is works when I take out the AND CurRent = 1 clause. However, with that part in it, the calculation returns a ?.
CurRent is a Number field.
The problem is that your field name CurRent collides with the reserved word CURRENT.
Change your formula to:
ExecuteSQL ( "SELECT BaseRent FROM obj_Unit_CurrentRenter_RentAmount WHERE RenterUnitID = ? AND \"CurRent\" = 1" ; "," ; ""; RenterUnitID)
Related
I'm using PostgreSQL and I have a table which includes week numbers of the year in its columns. I try to update by increasing these columns' values in nested loops.
I have the following query which attempts to increase the related field of a record.
foreach ( $updateVotes as $key => $value ) {
for ( $week = 1; $week < 53 ; $week++) {
$increaseValue = $value['week_'.$week];
$this->db->set("week_".$week , "week_".$week. " +".$increaseValue, "FALSE");
}
$this->db->where('id', $id)
->update('votes');
}
To achieve my aim, I need output like the one below:
UPDATE "votes"
SET week_1 = week_1 +20,
week_2 = week_2 +50,
...
WHERE id = 1
However, when I run the query, it produces the following SQL:
UPDATE "votes"
SET "week_1" = 'week_1 +20',
"week_2" = 'week_2 +50',
...
WHERE id = 1
As it also produces single quotes, it throws errors like this:
column 'week_1 +20' cannot found
How can I escape these single quotes and run the query successfully?
According to the official document here, you should pass FALSE (Bool) instead of "FALSE" (String) like this
$this->db->set("week_".$week , "week_".$week. " +".$increaseValue, FALSE);
Hope this helps!
Remove Double quotes from "FALSE" into FALSE
I need to do a simple query, Select Statement
I want to search in Table all record with value "ValueA, ValueB".
If I use this code, not work well:
String255 valueToFilter;
valueToFilter = 'ValueA, ValueB';
select count (RecId) from MyTable
where MyTable.Field like valueToFilter ;
But not working, I need to keep all record with value "ValueA" or "ValueB", if in the file there is value like : "ValueA, ValueC" I want to get too.
I don't know the number of values (valueToFilter).
Thanks!
From my point of view the easiest way to accomplish this is to split your filter string:
String255 valueToFilterA = 'ValueA';
String255 valueToFilterB = 'ValueB';
;
select count (RecId) from MyTable
where MyTable.Field like valueToFilterA
|| MyTable.Field like valueToFilterB;
If you don't know the number of values you should use query object to add ranges dynamically:
Query query = new Query();
QueryRun queryRun;
QueryBuildDataSource qbds;
QueryBuildRange queryRange;
container conValues;
;
qbds = query.addDataSource(tableNum(MyTable));
for (i = 1; i <= conlen(conValues); i++)
{
queryRange = qbds.addRange(fieldNum(MyTable, Field));
queryRange.value(SysQuery::valueLike(conPeek(conValues, i)));
}
queryRun = new QueryRun(query);
info(strFmt("Records count %1", SysQuery::countTotal(queryRun)));
This ABAP code works but it works only once. I run this code with different parameters but result data does not change. How can I solve it?
PARAMETERS : S_MONTH LIKE ISELLIST-MONTH OBLIGATORY.
SELECT-OPTIONS : S_DATE FOR SY-DATUM.
AT SELECTION-SCREEN ON VALUE-REQUEST FOR S_MONTH.
PERFORM GET_DATES.
FORM GET_DATES.
DATA: MONTH LIKE ISELLIST-MONTH,
FIRST_DAY LIKE SY-DATUM,
LAST_DAY LIKE SY-DATUM.
MONTH = SY-DATUM+0(6). "default
CALL FUNCTION 'POPUP_TO_SELECT_MONTH'
EXPORTING
ACTUAL_MONTH = MONTH
IMPORTING
SELECTED_MONTH = MONTH.
IF SY-SUBRC <> 0.
"put some message
ENDIF.
CONCATENATE MONTH '01' INTO FIRST_DAY.
CALL FUNCTION 'RP_LAST_DAY_OF_MONTHS'
EXPORTING
DAY_IN = FIRST_DAY
IMPORTING
LAST_DAY_OF_MONTH = LAST_DAY.
IF SY-SUBRC <> 0.
"put some message
ENDIF.
S_DATE-LOW = FIRST_DAY.
S_DATE-HIGH = LAST_DAY.
S_DATE-SIGN = 'I'.
S_DATE-OPTION = 'BT'.
APPEND S_DATE.
S_MONTH = MONTH.
ENDFORM.
Add REFRESH S_DATE. before the APPEND S_DATE. You are now just appending every selection you make.
I have a record in an Informix table. The table columns look like this:
acct_no integer,
suffix char(1),
meter_num char(20),
date_read datetime year to second not null ,
counter smallint,
reading integer not null ,
typeofread char(1),
estimated char(1),
time_billed datetime year to second
Using Informix's dbaccess tool:
select *
from ws_mtrread
where acct_no = 113091000
and suffix = " "
order by date_read desc;
this result (newest shown) is returned and works whether or not I use one or two spaces for suffix.
acct_no 113091000
suffix
meter_num 34153205
date_read 2013-09-09 23:31:15
counter 0
reading 1240
typeofread g
estimated
time_billed 2013-10-22 11:48:21
However, this Perl DBI query
my $sql_statement =
"select * ".
"from ws_mtrread ".
"where acct_no = ? ".
"and suffix = ? ".
"order by date_read desc ; ";
does not work. I can fetch the row without specifying $suffix, so I know the row exists.
I believe this is an error on my part in representing the suffix. In this example suffix is equal to a string of two spaces.
How do I represent spaces correctly, so the query works? Here is the rest of the code I used to fetch the row.
my $test_acct_no = 113091000;
my $suffix = " ";
my $pt_sel_hdl = $DBHdl->prepare($sql_statement);
$pt_sel_hdl->execute($test_acct_no, $DBHdl->quote($suffix));
my $ws_mtr_read_rec_ref = $pt_sel_hdl->fetchrow_hashref;
After the call, $ws_mtr_read_rec_ref is undefined.
Don't use DBI's quote method here:
$pt_sel_hdl->execute($test_acct_no, $DBHdl->quote($suffix));
When you use ? placeholders in your SQL, the database driver will correctly parameterize the query arguments that you pass to execute. You are probably creating a query that is searching for the literal string " " (including the quotes) when you want to search for (just two spaces.)
So this should be all you need:
$pt_sel_hdl->execute($test_acct_no, $suffix);
I have a Crystal Report which has two paramaters: {?EmailVerifyStatus} and {?Company}. I want it so that when the two paramaters are blank the report gets all the records.
Here is my current code:
(if {?EmailVerifyStatus}='Y' THEN {PREH.udEmailVerify}='Y'
ELSE IF {?EmailVerifyStatus}='N' THEN {PREH.udEmailVerify}='N'
ELSE 1=1)
and
(if {?Company} <> '0' then not (IF "," & ToText({PREH.PRCo},0,'') & "," IN "," & {?Company} & "," THEN 0=1 ELSE 1=1) else 1=1 )
But, it is only returning the records with a 'Y' value.
You have to check if parameters have set a value with the hasvalue() function. Then you can do this:
(not(hasvalue({?EmailVerifyStatus})) or {PREH.udEmailVerify} = {?EmailVerifyStatus}) and
(not(hasvalue({?PRCo})) or {PREH.Co} = {?Company})
I dont understand your second condition ...