Programming Blog
1,127 FOLLOWERS
A blog about programs basically written in Java and C language.
Programming Blog
6y ago
Read csv file in grails Add CsvGrailsPlugin This plugin adds dynamic methods 'eachCsvLine' to each of the following classes:- java.lang.String - java.io.File - java.io.InputStream - java.io.Reader Example-def csvReader(){def filePath="C:\\Users\\Ram\\Downloads\\Client & Fee charge.csv"int i = 0;new File(filePath1).eachCsvLine { tokens -> if (i == 0) { i = i + 1; return } i = i + 1; def rollNumber = Integer.parseInt(tokens[0]); de ..read more
Programming Blog
6y ago
Case in Select statement Syntax- Select CASE WHEN(condition) THEN 'Statement' WHEN(condition) THEN 'Statement' ELSE 'Statement' END Example- Select Name, CASE WHEN(a.application_status=3) THEN 'Assigned' WHEN(a.application_status=4) THEN 'Submitted' WHEN(a.application_status=8) THEN 'Report Accepted' ELSE 'NA' END as 'Application Status', From Application a ..read more
Programming Blog
6y ago
RLIKE OPERATOR IN MYSQLIn this tutorial, I will show you the use of RLIKE operator in MYSQL. RLIKE Operator performs a pattern match of a string expression against a pattern. The pattern is supplied as an argument. SYNTAX : SELECT COLUMN NAMES FROM TABLE NAME WHERE COLUMN NAME RLIKE EXPRESSION; Here expression is any valid expression; EXAMPLE : Query to fetch names which have vowels (i.e., a, e, i, o and u) as both their first and last characters. SELECT * FROM (table name) WHERE name RLIKE '^[aeiouAEIOU].*[aeiouAEIOU ..read more
Programming Blog
6y ago
plsql program to insert data dynamically at runtime by taking input from the user declareval1 number := &Enter_value;val2 varchar2(20) := '&Enter';Tab_Name varchar2(50) := 'dynamic_value';sql_stmt varchar2(2000);begin sql_stmt := 'Insert into '||Tab_Name||' values(:1 , :2)'; execute immediate sql_stmt using val1,val2;end; /*---------------------------------------------- In this procedure, we use bind variables to map the input variables at run time.Table_name is not mapped using bind variables that's why i directly with the variable('Tab_Name').Execute immediate is used to exec ..read more
Programming Blog
6y ago
In this tutorial i will show you the PLSQL code to create a table dynamically at run time DECLARE SQL_STMT VARCHAR2(500); VAL1 VARCHAR2(50) := 'DYNAMIC_COL1 NUMBER'; VAL2 VARCHAR2(50) := 'COLUMN_2 VARCHAR2(100)'; ---column with their datatypes tabname varchar2(100) := 'Auto_Created'; ---table name BEGIN SQL_STMT := 'CREATE TABLE ' ||TabName|| '(' ||val1||',' ||VAL2|| /*.......Any number of columns................*/ ')'; EXECUTE IMMEDIATE SQL_STMT ; END; In this code, we provide the desired table name which is stored in variable 'tabname'we store the column names with their respec ..read more
Programming Blog
6y ago
I have done this question by two methods By using loops declare counts number :=0; counts1 number :=0; str1 varchar2(500) :=LOWER('This is the string'); begin for i in 1..length(str1) loop if(substr(str1,i,1) in ('a','e','i','o','u')) then counts := counts + 1; else counts1 := counts1 + 1; end if; end loop; dbms_output.put_line('Input : '||str1); dbms_output.put_line('Total vovels :' ||counts); dbms_output.put_line('Total consonants :' ||counts1); end; By using regular expressions declare counts number := 0; counts1 nu ..read more
Programming Blog
6y ago
Method 1 : By using FOR loop in PLSQL DECLARE l_string1 VARCHAR2 (100) := 'deeps sti dna thgil neewteb kcuts si emit ehT'; l_string2 VARCHAR2 (100); BEGIN FOR indx IN REVERSE 1 .. LENGTH (l_string1) LOOP l_string2 := l_string2 || SUBSTR (l_string1, indx, 1); --dbms_output.put_line(l_string2); END LOOP; DBMS_OUTPUT.put_line (l_string2); END; / Method 2 : By using REVERSE() function available in Oracle declare string1 VARCHAR2(100) :='deeps sti dna thgil neewteb kcuts si emit ehT'; begin SELECT REVERSE(string1) into string1 from dual; dbms_output.put_line ..read more
Programming Blog
6y ago
#include<stdio.h> long factorial(int);Pascal Triangle int main() { int i, n, c; printf("How many rows you want in pascal triangle?\n"); scanf("%d",&n); for ( i = 0 ; i < n ; i++ ) { for ( c = 0 ; c <= ( n - i - 2 ) ; c++ ) printf(" "); for( c = 0 ; c <= i ; c++ ) printf("%ld",factorial(i)/(factorial(c)*factorial(i-c))); printf("\n"); } return 0; } long factorial(int n) { int c; long result = 1; for( c = 1 ; c <= n ; c++ ) result = result*c; return ( result ..read more
Programming Blog
6y ago
PL/SQL code to find factorial of a number entered by user DECLARE num number; factorial number; FUNCTION fact(x number) RETURN number IS f number; BEGIN f := 1; for i in 1..x loop f := f*i; end loop;RETURN f; END; BEGIN num:= &enter_number; -- to take input from user factorial := fact(num); dbms_output.put_line(' Factorial of '|| num || ' is ' || factorial); END ..read more