I want a column in my database to be of type text (an unlimited amount of text).
In my schema:
bio: { type: text }
Migration file generated:
$this->changeColumn('organization', 'bio', 'text', '', array());
When I try to migrate I get the following error:
- SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ')' at line 1. Failing Query: "ALTER TABLE organization CHANGE bio bio text()"
What is the correct syntax for such a field?
Try to use "string" instead of "text"
bio: { type: string }
Related
I have the following code:
$extracting = $dbNew->query("SELECT *, Format(Date_Sheet, 'Short Date') AS modifiedDate FROM AccessDB WHERE modifiedDate LIKE '%2021%'");
Having the following error:
Fatal error: Uncaught PDOException: SQLSTATE[07002]: COUNT field incorrect: -3010 [Microsoft Access Driver] Too few parameters. Expected 1.
The problem is the "modifiedDate" because if I replace it with the "Date_Sheet" access field after the database table, I can run the query without issues.
Thank you in advance!
I am trying to create an export file from a database view that I created.
I was able to successfully complete the steps to define the query and populate the temp tables but when I attempt to export the data to file I am receiving the error message
'Incorrect syntax near the keyword 'TO'.
This is the complete error:
1:52:06 AM [ 2063] (15) Populate temp tables with values
(AG16_RUN0020)
1:52:06 AM ERROR : Error (156) Error in AGRExecSql:
Couldn't execute statement (156) when (25) Create export file: 42000
[Microsoft][SQL Server Native Client 11.0][SQL Server]Incorrect syntax
near the keyword 'TO'.:
I am using the following for the Create Export File step:
COPY TO EXPORT FILE ='DataFeed.txt',colsep=;,
SELECT degree__1, huid__1,stage__1, f22_schooltag, status_effective_date__1,f21_effdt,last_name__1,first_name__1, middle_name__1, f20_other_last_, name__1,f1_prefix, name_suffix__1,alias_name,client,date_of_birth__1,f3_birth_state,f4_birth_countr, gender__1,f5_marital_stat,ssn__1,f6_itin,f7_military_sta,f8_disabled_vet,us_citizenship__1,f17_citizen_sta,huit_country_code__1,country_of_citizenship__1,visa_type__1,f19_huit_visa_t,ethnicity__1,f9_ethnicity_w,f10_ethnicity_b,f11_ethnicity_a,f12_ethnicity_p,f13_ethnicity_a, f14_ethnicity_h,telephone__1, f18_primary_pho,f15_other_phone, f16_other_phone, type__1,term__1,student_pk__2, student_pk__1,student_pk
FROM $*hlptab25
ORDER BY huid__1 ASC,last_name__1 ASC,first_name__1 ASC
I have tried to just use 'COPY TO' and 'COPY INTO FILE' but the syntax error still persists. I also put parenthesis around the whole SQL statement and that did not resolve the issue.
Has anyone encountered this before - if so how did you resolve it?
Thanks
Using Apache Drill,
I successfully created new plugin : mssql
Configuration:
{
type: "jdbc",
driver: "com.microsoft.sqlserver.jdbc.SQLServerDriver",
url: "jdbc:sqlserver://99.99.99.999:1433;databaseName=ABC",
username: "abcuser",
password: "abcuser",
enabled: true
}
But when i try to query again a table I get an error:
select * from mssql.ABC.dbo.TableName
Error:
org.apache.drill.common.exceptions.UserRemoteException: VALIDATION ERROR: From line 1, column 15 to line 1, column 19: Table 'mssql.ABC.dbo.TableName' not found SQL Query null [Error Id: feba9fdb-1621-438a-9d7c-304e4252a41f on AA99-9AA9A99.xyz.abc.com:31010]
Even the below command returns no tables:
show tables;
It should be like
select * from mssql.dbo.TableName
Very often we are unable to use Partitioned reads in Netezza connector.
Example
When partitioned read = Yes and Generated SQL at Runtime = Yes this works:
SELECT "Firma", "KundeNr", "ArtikkelNr"," LagerstedNr"
FROM dwhusr."TI_FT_Salg"
When Generated SQL at Runtime = No and the query is Autogenerated by DataStage (or we write it our selves) the query looks like this:
SELECT "Firma", "KundeNr", "ArtikkelNr"," LagerstedNr"
FROM dwhusr."TI_FT_Salg"
WHERE mod(datasliceid,[[node-count]])=[[node-number]]
It will then throw an error:
DB_TI_FT_Salg: Unexpected ODBC error occurred. Reason: [SQLCODE=42000][Native=27] ERROR: 'SELECT "Firma", "KundeNr", "ArtikkelNr"," LagerstedNr" FROM dwhusr."TI_FT_Salg" where mod(datasliceid,[[node-count]])=[[node-number]] limit 0'
error ^ found "[" (at char 102) expecting an identifier found a keyword (CC_NZMetadataHelper::describeResultSet, file CC_NZMetadataHelper.cpp, line 5 622)
Please help!
I am writing to from an ODBC to a SQL Server table via the RODBC package, specifically the function sqlSave. It seems that the default var types is charvar(255) for this function. I tried to use the argument of varTypes that is listed within the documentation but it fails.
Here is the table called spikes20 with the Class structure, this in turn is what I am trying to save via sqlSave
sapply(spikes20, class)
Date Day EWW PBR BAC CHTP FB SPY
"Date" "factor" "numeric" "numeric" "numeric" "numeric" "numeric" "numeric"
Here is the code which attempts to write to the SQL Server
require(RODBC)
varTypes = c(as.Date="Date")
channel <-odbcConnect("OptionsAnalytics", uid="me", pwd="you")
sqlSave (channel, spikes20, tablename = NULL, append=TRUE, rownames = FALSE, colnames = TRUE, safer = FALSE, addPK = FALSE, varTypes=varTypes )
The error message that I get says:
Warning messages:
In sqlSave(channel, spikes20, tablename = NULL, append = TRUE, rownames = FALSE, :
column(s) as.Date 'dat' are not in the names of 'varTypes'
I tried to change the varType to:
varTypes=c(Date="Date")
then the error message becomes:
Error in sqlSave(channel, spikes20, tablename = NULL, append = TRUE, rownames = FALSE, :
[RODBC] Failed exec in Update
22007 241 [Microsoft][ODBC SQL Server Driver][SQL Server]Conversion failed when converting date and/or time from character string.
Any help will be appreciated. It seems I cannot decipher to use varTypes correctly...
First, are you really trying to append to a table named NULL?
As far as issues with varTypes goes, in my experience I have had to provide a mapping for all of the variables in the data frame even though the documentation for the varTypes argurment says:
"an optional named character vector giving the DBMSs datatypes to be used for
some (or all) of the columns if a table is to be created"
You need to make sure that the names of your varTypes vector are the column names and the values are the data types as recommended here. So following their example you would have:
tmp <- sqlColumns(channel, correctTableName)
varTypes = as.character(tmp$TYPE_NAME)
names(varTypes) = as.character(tmp$COLUMN_NAME)
varTypes = c(somecolumn="datetime") works for me.