SlideShare uma empresa Scribd logo
1 de 2
Baixar para ler offline
funct_format_sql_statement.c
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include   "constant_definition.h"
#include   "case_constant_definition.h"
#include   "case_constant_sql_stmt_def.h"
#include   "constant_oracle_versions.h"

extern vaciar_cadena();
extern pasar_amayus ();
extern stmtsqlncmp ();

char *formatear_sql_statement ( void *punt_cadena )
        {
        static char order_stmt [MAX_STMT_SIZE];
        static char auxi_stmt [MAX_STMT_SIZE];
        static char auxiliar [MAX_WORD_STMT];

       int    profu_parent =0;
       int    profu_comita =0;
       int    profu_comilla =0;

       int    contador_blanco =0;
       int    largo_cadena=0;
       int    posicion1=0;
       int    posicion2=0;
       int    posicion3=0;
       int    caracter=0;

       largo_cadena = (int )strlen ((char *) punt_cadena);
       vaciar_cadena (order_stmt, MAX_STMT_SIZE);
       vaciar_cadena (auxi_stmt, MAX_STMT_SIZE);

       posicion2=0;

       /* ************ Quitando espacios en blanco ************* */
       for (posicion1=0; posicion1 <= largo_cadena; posicion1++)
               {
               caracter = ((char *) punt_cadena )[posicion1];
               if ( caracter == ASCII_SPACE )
                       if ( contador_blanco == 0 )
                               {
                               contador_blanco++;
                               auxi_stmt [posicion2]=caracter;
                               posicion2++;
                               }
               if ( caracter != ASCII_SPACE)
                       {
                       contador_blanco=0;
                       auxi_stmt[posicion2]=caracter;
                       posicion2++;
                       }
               }
       auxi_stmt[posicion2]=ASCII_FIN_LINEA;
       /* ************ ||||||||||||||||||||||||||| ************* */
       largo_cadena=(int )strlen(auxi_stmt);
       posicion2=0;
       posicion3=0;
       vaciar_cadena (auxiliar,MAX_WORD_STMT);
       for (posicion1=0; posicion1 <= largo_cadena; posicion1++)
               {
               caracter = auxi_stmt [posicion1];
/*             printf ("C [%c=%d] ",caracter,caracter);               */
               if ( caracter != ASCII_SPACE )
                       {
                       auxiliar[posicion3]        = caracter;

                                      Página 1
funct_format_sql_statement.c
/*                  order_stmt[posicion2] = caracter;
                    posicion2++;
                    order_stmt[posicion2] = ASCII_FIN_LINEA;
*/
                     posicion3++;
                     auxiliar[posicion3] = ASCII_FIN_LINEA;
                     }
             else if (caracter == ASCII_SPACE )
                     {
                     if ( ( stmtsqlncmp (auxiliar,"select",6)==0 ) )
                             {
                             strcat (order_stmt," n");
                             strcat (order_stmt,auxiliar);
                             strcat (order_stmt," n");
                             posicion3=0;
                             vaciar_cadena (auxiliar,MAX_WORD_STMT);
                             }
                     else if ( (stmtsqlncmp (auxiliar,"from",4)==0 ) )
                             {
                             strcat (order_stmt," n");
                             strcat (order_stmt,auxiliar);
                             strcat (order_stmt," n");
                             posicion3=0;
                             vaciar_cadena (auxiliar,MAX_WORD_STMT);
                             }
                     else if ( (stmtsqlncmp (auxiliar,"where",5)==0 ) )
                             {
                             strcat (order_stmt," n");
                             strcat (order_stmt,auxiliar);
                             strcat (order_stmt," n");
                             posicion3=0;
                             vaciar_cadena (auxiliar,MAX_WORD_STMT);
                             }
                     else if ( (stmtsqlncmp (auxiliar,"group",5)==0) )
                             {
                             strcat (order_stmt," n");
                             strcat (order_stmt,auxiliar);
                             strcat (order_stmt," n");
                             posicion3=0;
                             vaciar_cadena (auxiliar,MAX_WORD_STMT);
                             }
                     else if ( (stmtsqlncmp (auxiliar,"order",5)==0) )
                             {
                             strcat (order_stmt," n");
                             strcat (order_stmt,auxiliar);
                             strcat (order_stmt," n");
                             posicion3=0;
                             vaciar_cadena (auxiliar,MAX_WORD_STMT);
                             }
                     strcat (order_stmt,auxiliar);
                     strcat (order_stmt,"    ");
                     posicion3=0;
                     vaciar_cadena (auxiliar,MAX_WORD_STMT);
                     }
             }
     return (order_stmt);
     }




                                 Página 2

Mais conteúdo relacionado

Destaque (8)

Func time sleep.c
Func time sleep.cFunc time sleep.c
Func time sleep.c
 
Funciones auxiliares.c
Funciones auxiliares.cFunciones auxiliares.c
Funciones auxiliares.c
 
Func dyn proc_func_set.c
Func dyn proc_func_set.cFunc dyn proc_func_set.c
Func dyn proc_func_set.c
 
Func dyn size_set.c
Func dyn size_set.cFunc dyn size_set.c
Func dyn size_set.c
 
Func dyn title_set.c
Func dyn title_set.cFunc dyn title_set.c
Func dyn title_set.c
 
Orastat line command
Orastat line commandOrastat line command
Orastat line command
 
Menu orastat.c
Menu orastat.cMenu orastat.c
Menu orastat.c
 
Senten500.c
Senten500.cSenten500.c
Senten500.c
 

Semelhante a Funct format sql_statement.c

Ugly code
Ugly codeUgly code
Ugly code
Odd-e
 
Hacking parse.y (RubyKansai38)
Hacking parse.y (RubyKansai38)Hacking parse.y (RubyKansai38)
Hacking parse.y (RubyKansai38)
ujihisa
 

Semelhante a Funct format sql_statement.c (20)

Ugly code
Ugly codeUgly code
Ugly code
 
Climbing the Abstract Syntax Tree (Midwest PHP 2020)
Climbing the Abstract Syntax Tree (Midwest PHP 2020)Climbing the Abstract Syntax Tree (Midwest PHP 2020)
Climbing the Abstract Syntax Tree (Midwest PHP 2020)
 
Climbing the Abstract Syntax Tree (IPC Fall 2017)
Climbing the Abstract Syntax Tree (IPC Fall 2017)Climbing the Abstract Syntax Tree (IPC Fall 2017)
Climbing the Abstract Syntax Tree (IPC Fall 2017)
 
Interpret this... (PHPem 2016)
Interpret this... (PHPem 2016)Interpret this... (PHPem 2016)
Interpret this... (PHPem 2016)
 
Climbing the Abstract Syntax Tree (ScotlandPHP 2018)
Climbing the Abstract Syntax Tree (ScotlandPHP 2018)Climbing the Abstract Syntax Tree (ScotlandPHP 2018)
Climbing the Abstract Syntax Tree (ScotlandPHP 2018)
 
Climbing the Abstract Syntax Tree (DPC 2017)
Climbing the Abstract Syntax Tree (DPC 2017)Climbing the Abstract Syntax Tree (DPC 2017)
Climbing the Abstract Syntax Tree (DPC 2017)
 
Climbing the Abstract Syntax Tree (phpDay 2017)
Climbing the Abstract Syntax Tree (phpDay 2017)Climbing the Abstract Syntax Tree (phpDay 2017)
Climbing the Abstract Syntax Tree (phpDay 2017)
 
Climbing the Abstract Syntax Tree (Bulgaria PHP 2016)
Climbing the Abstract Syntax Tree (Bulgaria PHP 2016)Climbing the Abstract Syntax Tree (Bulgaria PHP 2016)
Climbing the Abstract Syntax Tree (Bulgaria PHP 2016)
 
Climbing the Abstract Syntax Tree (CodeiD PHP Odessa 2017)
Climbing the Abstract Syntax Tree (CodeiD PHP Odessa 2017)Climbing the Abstract Syntax Tree (CodeiD PHP Odessa 2017)
Climbing the Abstract Syntax Tree (CodeiD PHP Odessa 2017)
 
Climbing the Abstract Syntax Tree (PHP South Africa 2017)
Climbing the Abstract Syntax Tree (PHP South Africa 2017)Climbing the Abstract Syntax Tree (PHP South Africa 2017)
Climbing the Abstract Syntax Tree (PHP South Africa 2017)
 
QA Auotmation Java programs,theory
QA Auotmation Java programs,theory QA Auotmation Java programs,theory
QA Auotmation Java programs,theory
 
Climbing the Abstract Syntax Tree (PHP UK 2018)
Climbing the Abstract Syntax Tree (PHP UK 2018)Climbing the Abstract Syntax Tree (PHP UK 2018)
Climbing the Abstract Syntax Tree (PHP UK 2018)
 
Climbing the Abstract Syntax Tree (Southeast PHP 2018)
Climbing the Abstract Syntax Tree (Southeast PHP 2018)Climbing the Abstract Syntax Tree (Southeast PHP 2018)
Climbing the Abstract Syntax Tree (Southeast PHP 2018)
 
Climbing the Abstract Syntax Tree (Forum PHP 2017)
Climbing the Abstract Syntax Tree (Forum PHP 2017)Climbing the Abstract Syntax Tree (Forum PHP 2017)
Climbing the Abstract Syntax Tree (Forum PHP 2017)
 
Climbing the Abstract Syntax Tree (PHP Russia 2019)
Climbing the Abstract Syntax Tree (PHP Russia 2019)Climbing the Abstract Syntax Tree (PHP Russia 2019)
Climbing the Abstract Syntax Tree (PHP Russia 2019)
 
Hacking parse.y (RubyKansai38)
Hacking parse.y (RubyKansai38)Hacking parse.y (RubyKansai38)
Hacking parse.y (RubyKansai38)
 
Climbing the Abstract Syntax Tree (PHP Developer Days Dresden 2018)
Climbing the Abstract Syntax Tree (PHP Developer Days Dresden 2018)Climbing the Abstract Syntax Tree (PHP Developer Days Dresden 2018)
Climbing the Abstract Syntax Tree (PHP Developer Days Dresden 2018)
 
week-17x
week-17xweek-17x
week-17x
 
week-18x
week-18xweek-18x
week-18x
 
Implementing Software Machines in C and Go
Implementing Software Machines in C and GoImplementing Software Machines in C and Go
Implementing Software Machines in C and Go
 

Mais de albertinous

Local functions preceded_calls.h
Local functions preceded_calls.hLocal functions preceded_calls.h
Local functions preceded_calls.h
albertinous
 
Func menu mostrar.c
Func menu mostrar.cFunc menu mostrar.c
Func menu mostrar.c
albertinous
 
Func dyn statement_set.c
Func dyn statement_set.cFunc dyn statement_set.c
Func dyn statement_set.c
albertinous
 
Func dyn column_set.c
Func dyn column_set.cFunc dyn column_set.c
Func dyn column_set.c
albertinous
 
Extern functions funciones_auxiliares.h
Extern functions funciones_auxiliares.hExtern functions funciones_auxiliares.h
Extern functions funciones_auxiliares.h
albertinous
 
Decode name mode.c
Decode name mode.cDecode name mode.c
Decode name mode.c
albertinous
 
Decode name lock.c
Decode name lock.cDecode name lock.c
Decode name lock.c
albertinous
 
Decode lock mode.c
Decode lock mode.cDecode lock mode.c
Decode lock mode.c
albertinous
 
Decode command oracle.c
Decode command oracle.cDecode command oracle.c
Decode command oracle.c
albertinous
 
Constant oracle versions.h
Constant oracle versions.hConstant oracle versions.h
Constant oracle versions.h
albertinous
 
Constant definition.h
Constant definition.hConstant definition.h
Constant definition.h
albertinous
 
Case constant sql_stmt_def.h
Case constant sql_stmt_def.hCase constant sql_stmt_def.h
Case constant sql_stmt_def.h
albertinous
 
Case constant func_def.h
Case constant func_def.hCase constant func_def.h
Case constant func_def.h
albertinous
 
Case constant definition.h
Case constant definition.hCase constant definition.h
Case constant definition.h
albertinous
 
Ver menu opcion.c
Ver menu opcion.cVer menu opcion.c
Ver menu opcion.c
albertinous
 

Mais de albertinous (17)

Resource1
Resource1Resource1
Resource1
 
Local functions preceded_calls.h
Local functions preceded_calls.hLocal functions preceded_calls.h
Local functions preceded_calls.h
 
Func menu mostrar.c
Func menu mostrar.cFunc menu mostrar.c
Func menu mostrar.c
 
Func dyn statement_set.c
Func dyn statement_set.cFunc dyn statement_set.c
Func dyn statement_set.c
 
Func dyn column_set.c
Func dyn column_set.cFunc dyn column_set.c
Func dyn column_set.c
 
Extern functions funciones_auxiliares.h
Extern functions funciones_auxiliares.hExtern functions funciones_auxiliares.h
Extern functions funciones_auxiliares.h
 
Decode name mode.c
Decode name mode.cDecode name mode.c
Decode name mode.c
 
Decode name lock.c
Decode name lock.cDecode name lock.c
Decode name lock.c
 
Decode lock mode.c
Decode lock mode.cDecode lock mode.c
Decode lock mode.c
 
Decode command oracle.c
Decode command oracle.cDecode command oracle.c
Decode command oracle.c
 
Constant oracle versions.h
Constant oracle versions.hConstant oracle versions.h
Constant oracle versions.h
 
Constant definition.h
Constant definition.hConstant definition.h
Constant definition.h
 
Case constant sql_stmt_def.h
Case constant sql_stmt_def.hCase constant sql_stmt_def.h
Case constant sql_stmt_def.h
 
Case constant func_def.h
Case constant func_def.hCase constant func_def.h
Case constant func_def.h
 
Case constant definition.h
Case constant definition.hCase constant definition.h
Case constant definition.h
 
Ver menu opcion.c
Ver menu opcion.cVer menu opcion.c
Ver menu opcion.c
 
Orasta500.c
Orasta500.cOrasta500.c
Orasta500.c
 

Último

+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
?#DUbAI#??##{{(☎️+971_581248768%)**%*]'#abortion pills for sale in dubai@
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
panagenda
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Safe Software
 

Último (20)

Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Manulife - Insurer Innovation Award 2024
Manulife - Insurer Innovation Award 2024Manulife - Insurer Innovation Award 2024
Manulife - Insurer Innovation Award 2024
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 

Funct format sql_statement.c

  • 1. funct_format_sql_statement.c #include <stdio.h> #include <stdlib.h> #include <string.h> #include "constant_definition.h" #include "case_constant_definition.h" #include "case_constant_sql_stmt_def.h" #include "constant_oracle_versions.h" extern vaciar_cadena(); extern pasar_amayus (); extern stmtsqlncmp (); char *formatear_sql_statement ( void *punt_cadena ) { static char order_stmt [MAX_STMT_SIZE]; static char auxi_stmt [MAX_STMT_SIZE]; static char auxiliar [MAX_WORD_STMT]; int profu_parent =0; int profu_comita =0; int profu_comilla =0; int contador_blanco =0; int largo_cadena=0; int posicion1=0; int posicion2=0; int posicion3=0; int caracter=0; largo_cadena = (int )strlen ((char *) punt_cadena); vaciar_cadena (order_stmt, MAX_STMT_SIZE); vaciar_cadena (auxi_stmt, MAX_STMT_SIZE); posicion2=0; /* ************ Quitando espacios en blanco ************* */ for (posicion1=0; posicion1 <= largo_cadena; posicion1++) { caracter = ((char *) punt_cadena )[posicion1]; if ( caracter == ASCII_SPACE ) if ( contador_blanco == 0 ) { contador_blanco++; auxi_stmt [posicion2]=caracter; posicion2++; } if ( caracter != ASCII_SPACE) { contador_blanco=0; auxi_stmt[posicion2]=caracter; posicion2++; } } auxi_stmt[posicion2]=ASCII_FIN_LINEA; /* ************ ||||||||||||||||||||||||||| ************* */ largo_cadena=(int )strlen(auxi_stmt); posicion2=0; posicion3=0; vaciar_cadena (auxiliar,MAX_WORD_STMT); for (posicion1=0; posicion1 <= largo_cadena; posicion1++) { caracter = auxi_stmt [posicion1]; /* printf ("C [%c=%d] ",caracter,caracter); */ if ( caracter != ASCII_SPACE ) { auxiliar[posicion3] = caracter; Página 1
  • 2. funct_format_sql_statement.c /* order_stmt[posicion2] = caracter; posicion2++; order_stmt[posicion2] = ASCII_FIN_LINEA; */ posicion3++; auxiliar[posicion3] = ASCII_FIN_LINEA; } else if (caracter == ASCII_SPACE ) { if ( ( stmtsqlncmp (auxiliar,"select",6)==0 ) ) { strcat (order_stmt," n"); strcat (order_stmt,auxiliar); strcat (order_stmt," n"); posicion3=0; vaciar_cadena (auxiliar,MAX_WORD_STMT); } else if ( (stmtsqlncmp (auxiliar,"from",4)==0 ) ) { strcat (order_stmt," n"); strcat (order_stmt,auxiliar); strcat (order_stmt," n"); posicion3=0; vaciar_cadena (auxiliar,MAX_WORD_STMT); } else if ( (stmtsqlncmp (auxiliar,"where",5)==0 ) ) { strcat (order_stmt," n"); strcat (order_stmt,auxiliar); strcat (order_stmt," n"); posicion3=0; vaciar_cadena (auxiliar,MAX_WORD_STMT); } else if ( (stmtsqlncmp (auxiliar,"group",5)==0) ) { strcat (order_stmt," n"); strcat (order_stmt,auxiliar); strcat (order_stmt," n"); posicion3=0; vaciar_cadena (auxiliar,MAX_WORD_STMT); } else if ( (stmtsqlncmp (auxiliar,"order",5)==0) ) { strcat (order_stmt," n"); strcat (order_stmt,auxiliar); strcat (order_stmt," n"); posicion3=0; vaciar_cadena (auxiliar,MAX_WORD_STMT); } strcat (order_stmt,auxiliar); strcat (order_stmt," "); posicion3=0; vaciar_cadena (auxiliar,MAX_WORD_STMT); } } return (order_stmt); } Página 2