Wednesday, May 6, 2009

Pass by Reference in C++

Always try to pass objects by reference in C++ in funcation calls as it offers following advantages -

1. Efficient -
Pass by refernce just uses aliases for the object being passed. It does not make copy of the object.

2. Safe -
As reference variable is used for passing the object, possibility of NULL value is avoided.

3. Multiple value return -
Using the reference variable, one can make changes to the members of the object and return as a reference object. Thus, many changed values can be returned.

Wednesday, January 7, 2009

Embedding SQL into Unix Script

Embedding of SQL query in Unix Script -


The automation usability of the Unix Scripting can be enhanced with embedding the SQL queries into a Unix script file.
It can be achieved as mentioned in the below examples -

1.
isql -S -U -P << EOF

EOF

Use isql command with the aforesaid options.
<< EOF says, do the execution of the embedded sql after this command line till word "EOF" is encountered.

The output would be displayed on command prompt only.


2. isql -S -U -P << EOF >analytics_result.txt

EOF


Same as above with one addition , the output can bbe redirected to a file with indirection ">". Here the output file is "analytics_result.txt"


3.
isql -S -U -P -i analytics_query.sql << EOF
EOF


In case of big queries or multiple query execution, all sql stuffs could be packaged into a sql file and the file path could be mentioned with the option "-i".


Scope -

This automation could be used for database functionalities and running database queries as a scheduled job.




Avaneesh
07-01-2009