The compiler stores a NULL pointer to the pure virtual function in the V-Table and thus identifies it.
This blog provides some ready-made tips, tricks, tweaks & interview questions-answers on C, C++, Perl, Shell Scripting and UNIX Commands.
Friday, July 20, 2012
What is the difference between copy constructor and assignment?
A copy constructor is used to initialize a newly declared variable from an existing variable. This makes a deep copy like assignment, but the basic difference are as follows :
- There is no need to test to see if it is being initialized from itself.
- There is no need to clean up (eg, delete) an existing value (there is none).
- A reference to itself is not returned.
Monday, July 16, 2012
What are the modules included in SybPerl?
Sybperl (Sybase extensions to Perl) includes the following four modules:
1. Sybase::DBlib
2. Sybase::CTlib
3. Sybase::BCP
4. Sybase::Sybperl
1. Sybase::DBlib
2. Sybase::CTlib
3. Sybase::BCP
4. Sybase::Sybperl
Sunday, July 15, 2012
How do you check SQL error codes easily in DB2?
You can run the following query :
VALUES SQLERRM(<Error Code>)
For Example, if the error code is "-171" then the query should be :
VALUES SQLERRM(-171)
which shows SQL0171N and its equivalent error description - "THE DATA TYPE, LENGTH, OR VALUE OF ARGUMENT IS INVALID".
VALUES SQLERRM(<Error Code>)
For Example, if the error code is "-171" then the query should be :
VALUES SQLERRM(-171)
which shows SQL0171N and its equivalent error description - "THE DATA TYPE, LENGTH, OR VALUE OF ARGUMENT IS INVALID".
How do you generate and format report in Perl?
#!C:/Perl/bin/perl
format STDOUT_TOP =
-----------------------------------------------------------------------
@||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
"MERA BAZZAR - TERA BAZZAR"
-----------------------------------------------------------------------
@<<<<< @<<<<<<<<< @<<<<<<<<<<<<<<<<<<<<<< @<<<<<<<< @<<<<<<<< @>>>>>>> @>>>> @#
CODE,DATE,DESCRIPTION,PRICE,QUANTITY,AMOUNT,Page,$%
-----------------------------------------------------------------------
.
format STDOUT =
@<<<<< @>>>>>>>>> @<<<<<<<<<<<<<<<<<<< @####.## $ @######### @####.## $
$CODE,$DATE,$DESCRIPTION,$PRICE,$QUANTITY,$AMOUNT
.
format STDOUT_TOTAL =
-----------------------------------------------------------------------
TOTAL = @###.## $
$TOTAL
.
open(INP, "item.dat") || die "Can't read file - $!\n";
while (<INP>)
{
($CODE,$DATE,$DESCRIPTION,$PRICE,$QUANTITY) = split(/\t/);
$AMOUNT=$PRICE * $QUANTITY;
write;
$TOTAL += $AMOUNT;
}
close(INP);
$~ = "STDOUT_TOTAL";
write;
# Footer
$^L = '-' x 71 . "\n Copyright, 2012, MERA BAZZAR - TERA BAZZAR \n" . '-' x 71 . "\n";
print ("$^L");
The ITEM.DAT file should contail the following data of columns separated by a TAB :
SOA01 01-01-2012 LUX 01.35 03
SOA02 03-01-2012 LYRIL 01.15 06
SOA03 02-02-2012 DOVE 01.20 09
SOA04 04-02-2012 HAMMAM 01.10 03
SOA05 12-02-2012 NIRMA 01.36 06
SOA06 03-03-2012 RIN 01.50 09
SOA07 10-03-2012 SURF 01.85 03
SOA08 04-04-2012 DETOL 01.90 06
format STDOUT_TOP =
-----------------------------------------------------------------------
@||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
"MERA BAZZAR - TERA BAZZAR"
-----------------------------------------------------------------------
@<<<<< @<<<<<<<<< @<<<<<<<<<<<<<<<<<<<<<< @<<<<<<<< @<<<<<<<< @>>>>>>> @>>>> @#
CODE,DATE,DESCRIPTION,PRICE,QUANTITY,AMOUNT,Page,$%
-----------------------------------------------------------------------
.
format STDOUT =
@<<<<< @>>>>>>>>> @<<<<<<<<<<<<<<<<<<< @####.## $ @######### @####.## $
$CODE,$DATE,$DESCRIPTION,$PRICE,$QUANTITY,$AMOUNT
.
format STDOUT_TOTAL =
-----------------------------------------------------------------------
TOTAL = @###.## $
$TOTAL
.
open(INP, "item.dat") || die "Can't read file - $!\n";
while (<INP>)
{
($CODE,$DATE,$DESCRIPTION,$PRICE,$QUANTITY) = split(/\t/);
$AMOUNT=$PRICE * $QUANTITY;
write;
$TOTAL += $AMOUNT;
}
close(INP);
$~ = "STDOUT_TOTAL";
write;
# Footer
$^L = '-' x 71 . "\n Copyright, 2012, MERA BAZZAR - TERA BAZZAR \n" . '-' x 71 . "\n";
print ("$^L");
The ITEM.DAT file should contail the following data of columns separated by a TAB :
SOA01 01-01-2012 LUX 01.35 03
SOA02 03-01-2012 LYRIL 01.15 06
SOA03 02-02-2012 DOVE 01.20 09
SOA04 04-02-2012 HAMMAM 01.10 03
SOA05 12-02-2012 NIRMA 01.36 06
SOA06 03-03-2012 RIN 01.50 09
SOA07 10-03-2012 SURF 01.85 03
SOA08 04-04-2012 DETOL 01.90 06
Friday, July 13, 2012
SQL0803N: One or more values in the INSERT statement, UPDATE statement, or foreign key update caused by a DELETE statement are not valid because the primary key, unique constraint or unique index identified by "1" constrains table "STMT_REVISION".
Run the following query to trace the error:
For Example:
SELECT INDNAME, INDSCHEMA
FROM SYSCAT.INDEXES
WHERE IID = 1
AND TABSCHEMA = 'FIG_ADS'
AND TABNAME = 'STMT_REVISION';
SELECT INDNAME, INDSCHEMA
FROM SYSCAT.INDEXES
WHERE IID = <Index Id>
AND TABSCHEMA = '<Schema Name>'
AND TABNAME = '<Table Name>';
For Example:
SELECT INDNAME, INDSCHEMA
FROM SYSCAT.INDEXES
WHERE IID = 1
AND TABSCHEMA = 'FIG_ADS'
AND TABNAME = 'STMT_REVISION';
What is the difference between do() & prepare() ?
The do() method usually creates, prepares, executes and destroys a statement handle each time. It can be used for non repeated non-SELECT statement (or with drivers that don't support placeholders). For example, if you're doing an UPDATE, INSERT or DELETE there are no data that come back from the database. So you can say:
$dbh->do('DELETE FROM people WHERE age > 65');
do() returns either a true or false value. To be precise, it returns the number of affected rows on success.
On the contrary, the prepare( ) method will almost inevitably result in better performance, particularly on databases which do actually cache the statement. Always replace do( ) with prepare( ) and execute( ) in a loop to attain best performance.
Explain the difference between a static library and a dynamic library.
Static libraries are loaded when the program is compiled and dynamically-linked libraries are loaded in while the program is running. Dynamic libraries reduces the overall footprint of memory as against the static library because linking to static libraries includes the actual code for the library function(s)/procedure(s) with the executable. Dynamic Libraries are kept at specific location and are usually shared among all the processes that use.
Tuesday, July 3, 2012
How do you find out available DSNs?
#!C:/Perl/bin/perl -w
use DBI;
foreach my $dsn ( DBI->data_sources('ODBC') )
{
print "$dsn\n";
}
How do you find out DBI drivers installed?
#!C:/Perl/bin/perl -w
use DBI;
my @drivers = DBI->available_drivers;
print join("\n", @drivers);
Subscribe to:
Posts
(
Atom
)