on 06-18-2018 8:56 AM
Hi
I need to execute batch process in hdbsql and I need a log file to check what was wrong
I've read about -f option: returns all SQL statements that are sent to the database instance
That's exactly what I want, but I don't know how to use this option.
Could you please help me?
Not quite sure that this feature will help you a lot, but hey, you asked for examples, so take these:
No option:
hdbsql -U s12dev "SELECT count(*) from fact"
COUNT(*)
10000000
1 row selected (overall time 574.115 msec; server time 268 usec)
-f option (printout the SQL commands😞
hdbsql -U s12dev -f "SELECT count(*) from fact"
SELECT count(*) from fact
COUNT(*)
10000000
1 row selected (overall time 1301.303 msec; server time 139.424 msec)
-fn option (printout the SQL commands with additional line numbering😞
hdbsql -U s12dev -fn "SELECT count(*) from fact"
1) SELECT count(*) from fact
COUNT(*)
10000000
1 row selected (overall time 606.342 msec; server time 178 usec)
-x option (run quietly (no messages, only query output)):
hdbsql -U s12dev -fn -x "SELECT count(*) from fact"
COUNT(*)
10000000
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thanks Lars, you're rigtht. It doesn't help me.
I'm working in a linux enviroment, I'm executing this code:
rm SQLFILE_TMP.sh
echo "hdbsql <<!EOF" > SQLFILE_TMP.sh #enter into hdbsql
echo "\I ${PASSDIR}/${HNUSER}" >> SQLFILE_TMP.sh #connecting to hana
echo "\mu" >> SQLFILE_TMP.sh #sql multiline
cat ${SQLFILE} >> SQLFILE_TMP.sh #I pass del sql file with linux enviroment variables
echo "!EOF" >> SQLFILE_TMP.sh #end. Now SQLFILE_TMP.sh has all the sql + connection
ksh SQLFILE_TMP.sh > logfile 2>&1
The logfile has data of execution, errors of execution but no sql. If we have a lot of querys is very dificult to know wich one was wrong. Do you understand me? can you help me?
Alright, I don't care how you build up the script that you eventually call.
Show the final script and I look into why it fails.
Some general points, though:
Anyhow, even on Linux the following produces an output file that includes the SQL statements:
hdbsql -U ddude -f -o /tmp/out.txt "SELECT count(*) from fact"
cat /tmp/out.txt
SELECT count(*) from fact
COUNT(*)
10000000
In case of an error, this is also recorded:
hdbsql -U ddude -f -o /tmp/out.txt "SELECT count(*) from factX"
* 259: invalid table name: Could not find table/view FACTX in schema DEVDUDE: line 1 col 22 (at pos 21) SQLSTATE: HY000
cat /tmp/out.txt
SELECT count(*) from factX
* 259: invalid table name: Could not find table/view FACTX in schema DEVDUDE: line 1 col 22 (at pos 21) SQLSTATE: HY000
User | Count |
---|---|
84 | |
23 | |
11 | |
9 | |
8 | |
5 | |
5 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.