I am attempting to export a query in Sybase SQl Anywhere but am receiving an error when getting to the OUTPUT TO command. My query looks like this:
SELECT User_Name as 'Remote Database', nDaysBehind as 'Days Behind', Time_Received as 'Last Message Received'
FROM DailySynchRptView
WHERE Time_Received < today() -1 AND nDaysBehind > 0
ORDER BY Time_Received ASC
OUTPUT TO c:\daysbehind.txt format ascii
The information that shows up in ISQL when I leave off the "OUTPUT TO" is the following:
Remote Database,Days Behind,Last Message Received
'Rem00027',23,'2011-02-23 16:10:14.000'
'Rem00085',7,'2011-03-11 04:47:02.000'
'Rem00040',5,'2011-03-13 15:22:15.000'
'Rem00074',4,'2011-03-14 16:01:25.000'
'Rem00087',3,'2011-03-15 06:04:16.000'
However, when the OUTPUT TO command is placed in the query, I receive the following error:
Could not execute statement.
Syntax error near 'OUTPUT' on line 5
SQLCODE=-131, ODBC 3 State="42000"
Line 1, column 1
I am open to any suggestions that might help me be able to export the data from the query. I have ran a similar query that returns a single line of information and it does export without errors.
After a while looking at the code, I found that I was missing a semi-colon ; to separate the two sets of commands. Once I added the semi-colon before the OUTPUT line, I was able to export the information.
Related
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
Maybe it is a case of me looking at this for too long. But I have this Oracle update query I am trying to run, I have verified the query works with hardcoded values on SQL Developer, howver when I run it from my flow Mule it fails.can anybody tell me what I am doing wrong?
Here is the query:
<db:update config-ref="DBConf" doc:name="abcd">
<db:dynamic-query><![CDATA[UPDATE myTable
SET TYPE= 'Entry',
ENTERED_DATE=SYSDATE,
ENTRY_BY= 2345,
ENTRY_DATE=TO_DATE('#[flowVars.entryDate]','YYYY-MM-DD')
WHERE ID = 'abcd1234']]>
</db:dynamic-query>
</db:update>
the flowVars.entryDate value is '2017-05-10'
This throws the following Error:
Message : ORA-01841: (full) year must be between -4713 and +9999, and not be 0
(java.sql.SQLDataException). Message payload is of type: Integer
Now the same query works like I said in SQL Developer but not in Mule, Can anybody provide any input
You can find the same problem answer in the following link:
Oracle: year must be between -4713 and +9999, and not be 0
Try this once. TO_DATE('2012-05-12','yyyy-mm-dd').
Delete the quotes for the #[flowvar.entrydate]
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!
while trying ATK4 I've found a problem:
$this->api->db->dsql()->table('person')->set('id', 1)->set('name', 'Test user')->do_replace();
This is not working. Then I looked a little bit deeper in ATK4 source and found in /opt/ipism/www/atk4/lib/DB/dsql.php the lines
public $sql_templates=array(
'select'=>"select [options] [field] [from] [table] [join] [where] [group] [having] [order] [limit]",
'insert'=>"insert [options_insert] into [table_noalias] ([set_fields]) values ([set_values])",
'replace'=>"replace [options_replace] into [table_noalias] ([set_fields]) values ([set_values])",
'update'=>"update [table_noalias] set [set] [where]",
'delete'=>"delete from [table_noalias] [where]",
'truncate'=>'truncate table [table_noalias]',
'describe'=>'desc [table_noalias]',
);
After changing the 'replace'-line into
'replace'=>"replace into [table_noalias] ([set_fields]) values ([set_values])",
it worked for me (removing the options_replace and appending a 's' to set_value). I'm using latest version from git with a MySQL database connection.
But I'm not sure, if I'm using 'do-replace()' in the wrong way?
ByE...
By the way: Is there a way to send fixes, without creating an account on GitHub or somewhere?
Edit: Here is the output if the options_replace isn't removed from the template:
replace [options_replace] into `person` (`id`,`name`) values ("1","John Doe") [:a_2, :a]Application Error: Database Query Failed
Exception_DB, code: 0Additional information: pdo_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 '[options_replace] into `person` (`id`,`name`) values ('1' at line 1 mode: replace params: :a: 1 :a_2: John Doe query: replace [options_replace] into `person` (`id`,`name`) values (:a,:a_2) template: replace [options_replace] into [table_noalias] ([set_fields]) values ([set_values])/opt/ipism/www/atk4/lib/DB/dsql.php:1519
Stack trace:
File Object NameStack Trace/opt/ipism/www/atk4/lib/BaseException.php:63 Exception_DBException_DB->collectBasicData(Null)
/opt/ipism/www/atk4/lib/AbstractObject.php:545 Exception_DBException_DB->__construct("Database Query Failed", Null)
/opt/ipism/www/atk4/lib/DB/dsql.php:1519 sample_project_db_db_dsql_mysqlDB_dsql_mysql->exception("Database Query Failed")
/opt/ipism/www/atk4/lib/DB/dsql.php:1586 sample_project_db_db_dsql_mysqlDB_dsql_mysql->execute()
/opt/ipism/www/atk4/lib/DB/dsql.php:1624 sample_project_db_db_dsql_mysqlDB_dsql_mysql->replace()
/opt/ipism/www/page/test.php:40 sample_project_db_db_dsql_mysqlDB_dsql_mysql->do_replace()
/opt/ipism/www/atk4/lib/AbstractObject.php:306 sample_project_testpage_test->init()
/opt/ipism/www/atk4/lib/ApiFrontend.php:130 sample_projectFrontend->add("page_test", "test", "Content")
/opt/ipism/www/atk4/lib/ApiWeb.php:428 sample_projectFrontend->layout_Content()
/opt/ipism/www/atk4/lib/ApiFrontend.php:39 sample_projectFrontend->addLayout("Content")
/opt/ipism/www/atk4/lib/ApiWeb.php:275 sample_projectFrontend->initLayout()
/opt/ipism/www/index.php:15 sample_projectFrontend->main()
Note: To hide this information from your users, add $config['logger']['web_output']=false to your config.php file. Refer to documentation on 'Logger' for alternative logging options
Replace is similar to "insert" by it's nature, but instead of failing when primary key is duplicated, it replaces the value.
Please add ->debug() to your line before do_replace and give me the output, which would help me understand why that parameter needs removing.
set_value seems to be a typo, I have changed and committed it into master: https://github.com/atk4/atk4/commit/24b20865b9e3345a8e7504dfb68b7ef96335009e
the best way to submit changes is by creating a pull request. The best way to report issues is through "issues" in github currently.
Loading the .tbl file I've got this error:
[nicola#localhost ~]$ mclient -d dbmonet -s "COPY INTO monet.SUPPLIER FROM STDIN USING DELIMITERS ',','\\n','\"'" - < /home/nicola/Scrivania/tabellemonetdb/supplier.tbl
user(nicola):monetdb
password:
missing separator ',' line 0 expecting 6 got 1 fields
failed to import table
current transaction is aborted (please ROLLBACK)
syntax error, unexpected sqlINT in: "0201"
Why do I get this error?
I'm using an ssb schema.
Without knowing anything about the structure of the supplier.tbl file, my guess (from having used SSBM before) would be that it does not use "," as a field separator, but "|".
My SSBM loading command for the supplier table looks like this:
COPY INTO SUPPLIER FROM '/path/to/supplier.tbl' USING DELIMITERS '|', '|\n' LOCKED;