I am getting the following error when running a script
Error while executing 'A_MC_result'. Multiple values exist for variable "A_MM_email_list", however the SQL script has been written to expect only one value for this variable. To accept multiple values for variables only "=" and "<>" can be used for comparison operators. The query used the following operator "".
here is my script :
SELECT sort_name,
id,
pidm,
goremal_email_address,
goremal_status_ind,
goremal_preferred_ind,
goremal_emal_code
FROM donor,goremal
WHERE donor.pidm = goremal_pidm
AND upper(goremal_email_address) = upper('%'||:A_MM_email_list||'%')
AND :A_BT_submit is not null
I am attempting to enter multiple email addresses and return certain data.
I tried an 'IN' clause but that did not work either.
Thoughts?
Related
SPLIT_PART function used in a select statement in Snowflake Stored procedure returns null value.
var stmt5 = snowflake.CreateStatement({sqltext:`Select SPLIT_PART(SPLIT_PART(:1,''/'',2),''.gz'',1)`,binds:[stagename]});
var queryText=stmt5.getSqlText();
var x=stmt5.execute();
x.next();
stagename is retrieved from the List #my_stage command result and the result of the Split Part is used in the Copy Command for inserting records into a snowflake table.
If somebody responds will share the code thru an email to help me fix the issue. Thanks in advance.
You're using JavaScript with backticks, so there's no need to escape the single quotes. By doing so, it actually looks like an empty string. This is how it would look in your SQL history tab:
Select SPLIT_PART(SPLIT_PART(:1,''/'',2),''.gz'',1)
If you put a file name in and try that:
Select SPLIT_PART(SPLIT_PART('mypath/myfile.gz',''/'',2),''.gz'',1)
This doesn't actually return a null value. It's a syntax error, so maybe this execute call is in a try/catch block. That would return a null value when you try to use .next(),
Try it with the quotes single:
var stmt5 = snowflake.CreateStatement({sqltext:`Select SPLIT_PART(SPLIT_PART(:1,'/',2),'.gz',1)`,binds:[stagename]});
I am trying to set a string variable with the following format "YYYY-MM-DD HH:MM:SS" as a column value in Matillion with an SQL script component.
My initial code was this:
UPDATE "DB_MX_DEV"."STAGING".${target_table}
SET insertion_date = '2022-09-24 19:14:10';
The code from above worked with no problem. The table column is updated with that value (note that the value is hardcoded for testing purposes). However, when I try to run the following code:
UPDATE "DB_MX_DEV"."STAGING".${target_table}
SET insertion_date = (${fecha_insercion});
I got this error message:
SQL compilation error:
syntax error line 2 at position 32 unexpected '19'.
syntax error line 2 at position 36 unexpected '28'.
syntax error line 2 at position 39 unexpected '51'.
The fecha_insercion variable had this value 2022-12-06 19:28:51. I don't understand why if I reference the variable the code does not work. I tried to set the variable type both as text and datetime types but the error persist.
Why are you using parens to surround the variable? If you use single quotes it works fine. Like this:
UPDATE "DB_MX_DEV"."STAGING".${target_table}
SET insertion_date = '${fecha_insercion}';
My query used in an SSRS report:
SELECT DISTINCT
asm.AssemblyCode,
asm.AssemblyRestorationDesc,
asm.AssemblyUnit,
asm.AssemblyGuid,
(SELECT SUM(m.MarkerQuantity)
FROM Marker m
WHERE m.AssemblyGuid = asm.AssemblyGuid
AND m.MarkerExcludeFromScope = 'False'
AND m.ContractGuid IN (#Contract)
AND m.Deleted = 0) AS Quantity,
(SELECT SUM(smkr.MarkerQuantity)
FROM BaselineMarker smkr
WHERE smkr.AssemblyCode = asm.AssemblyCode
AND smkr.MarkerExcludeFromScope = 'False'
AND smkr.Deleted = 0) AS BaselineQuantity,
(SELECT SUM(sa.AllowanceQuantity)
FROM BaselineAllowance sa
WHERE sa.AssemblyCode = asm.AssemblyCode
AND sa.Deleted = 0) AS AllowanceQuantity
FROM
Assembly asm
WHERE
asm.Deleted = 0
ORDER BY
asm.AssemblyCode, asm.AssemblyRestorationDesc, asm.AssemblyUnit, asm.AssemblyGuid
Throws an odd error that isn't really making sense given that the report works if I select a single value for the #Contract parameter instead of multiple values, which tells me the parameter itself is set up fine. Also, if I set the parameter itself to a single value parameter instead of calling multiple values, it works fine too.
The report also works if I manually enter the GUIDs by replacing the line AND m.ContractGuid IN (#Contract) with:
AND m.ContractGuid IN ('60A38AD0-F24F-DF11-A19C-00111103CDB5', 'F8C018CA-A00C-4BB1-B920-D460786F6820')
Could the parameter not be returning a list in the correct format?
Nothing should be odd about the parameter. It's Name is Contract, its prompt is Contract, its data type is text, it allows multiple values, the values are taken from a simple query. The return value is the contract guid, and the return prompt is the contract name.
The error I get is:
An error has occurred during report processing. (rsProcessingAborted)
Query execution failed for dataset 'RestorationSummary'.
(rsErrorExecutingCommand) Must declare the scalar variable
"#Contract". Incorrect syntax near the keyword 'AS'. Incorrect syntax
near the keyword 'AS'.
The question is as for delphi coders as for c++ builder coders, cuz I'm using the same components.
I'm trying to fill labels on the form by the data from database. I do a SELECT query via TADOQuery. But when I try to get a result, I always get an error like "ADOQuery1: Field 'count' not found".
'id' passed to the function is an autoincrement field value, which is EXACTLY exists in database (it was got via DBLookupComboBox). Also, executing the query manually to show result in DBGrid is successfull.
Querying without parameters and writing 'id' value to query string fails too.
What's the problem? Here's the code.
void TSellForm::LoadData(int id) {
TADOQuery* q = DataModule1->ADOQuery1;
q->Active = false;
try
{
q->SQL->Text = "select * from drugs where(id=:id)";
q->Parameters->ParamByName("id")->Value = IntToStr(id);
q->ExecSQL();
this->LabelAvail->Caption = q->FieldByName("count")->Value;
}
catch (Exception* e) {
MessageBox(NULL, PChar(WideString(e->Message)),
L"Exception", MB_OK|MB_ICONWARNING);
}
q->SQL->Clear();
}
ExecSQL is only used for SQL statements that don't return a recordset, and to determine the results you use RowsAffected.
For SELECT statements (which return a recordset), you use Open or set Active to true.
Also, count is a reserved word in most SQL dialects (as in SELECT Count(*) FROM ..., so if you have a column with that name you're going to need to escape it, typically by using either [] or double-quotes around it or by aliasing it in the SELECT itself.
ADOQuery1->Close();
ADOQuery1->SQL->Text= "SELECT * FROM reportTble WHERE (firstName =:firstName) " ;
ADOQuery1->Parameters->ParamByName("firstName")->Value = textBox->Text ;
ADOQuery1->Open();
This is how you can use ADOQuery
I'm having some trouble trying to set a 'WHERE field IN ...' clause in CodeIgniter using SQLite. I got an array of all where clause conditions called $conditions, and added the WHERE IN clause in this way:
$this->browse_model->conditions['username IN'] = "(SELECT like_to FROM likes WHERE like_from = '".$this->user->username."')";
and inside of my browse_model I use the following code to run the query:
$get = $this->db->get_where('users', $this->conditions, 6, $_SESSION['browse_page']*6);
but somehow when I use the condition I wrote above it is giving me the following error:
Fatal error: Call to a member function execute() on a non-object in
../www/system/database/drivers/pdo/pdo_driver.php on line 193
As far as I'm concerned the 'field IN array' statement is allowed in SQLite too, so I really don't know why this isn't working. Does anyone know how to make this work?
Thanks in advance!
Greets,
Skyfe.
EDIT: Tried setting the condition in the following way and didn't get an error but neither any results:
$this->browse_model->conditions['username'] = "IN (SELECT like_to FROM likes WHERE like_from = '".$this->user->username."')";
So I guess that's still not the correct way to do it..
EDIT2: 'Fixed' it, somehow it didn't interpetate the field => value way of notating the where clause correctly for the IN statement, so defined it in a custom string:
$this->browse_model->custom_condition = username IN (SELECT like_to FROM likes WHERE like_from = '".$this->user->username."')
Their is some problem in formatting IN clause,
SELECT * FROM users WHERE gender = 'f' AND gender_preference = 'm' AND username IN (SELECT like_to FROM likes WHERE like_from = 'testtest')