INSERT INTO alias (nom, command, argc, help) VALUES ('alias', 'select nom from alias;', 0, 'print every alias''s name');
insert into alias (nom, command, argc, help) values ('var', 'select nom from var', 0, 'print avery var/named var content');
insert into alias (nom, command, argc) values ('var', 'select nom,value from var where nom=$1 order by id', 1);
-insert into alias (nom, command, argc, inf, help) values ('memo', 'insert into memo (word, rem) values ($1, $2);', 1, '1', 'list memo''s name/record new one/');
+insert into alias (nom, command, argc, inf, help) values ('memo', 'insert into memo (word, rem) values ($1, $2);', 1, '1', 'list memo''s name');
insert into alias (nom, command, argc) values ('memo', 'select distinct word from memo', 0);
-insert into alias (nom, command, argc, help) values ('mem', 'select id,rem from memo where word=$1 order by id', 1, 'print memo content');
+insert into alias (nom, command, argc, help) values ('memo', 'select id,rem from memo where word=$1 order by id', 1, 'print memo content');
insert into alias (nom, command, argc, help) values ('help', 'select distinct nom from alias', 0, 'help itself (add "command to get specific help")');
insert into alias (nom, command, argc) values ('help', 'select distinct id,nom,command from alias where nom=$1', 1);
+insert into alias (nom, command, argc) values ('help', 'select id,nom,command from alias where nom=$1 and argc=$2', 1);
}
bool sqlpg::alias(vector<string> a){
clog<<"alias start here\n";
- string nom=a[0], as=toString(a.size()-1).c_str(), i;
+ string nom=a[0], as=toString(a.size()-1), i;
int argca=2, inf=0;
const char *valuea[2]={nom.c_str(), as.c_str()};
int lengtha[2]={nom.size(), as.size()};
clog<<"for finish, \n";
if(inf==1){
clog<<"inf==1\n";
- t=a[argc+1];
- clog<<"for infinite (j="<<argc+2<<"; j<="<<asize-1<<") t="<<t<<endl;
- for(int j=argc+2; j<=asize-1; j++){
+ t=a[argc];
+ clog<<"for infinite (j="<<argc+1<<"; j<="<<asize-1<<") t="<<t<<endl;
+ for(int j=argc+1; j<=asize-1; j++){
t=t+" "+a[j];
clog<<"bcl t="<<t<<endl;
}
res=PQprepare(conn, "execalias",cmd2.c_str(), argc+inf, NULL);
clog<<"PQprepart done(cmd2="<<cmd2<<" argc+inf="<<argc+inf<<"\n";
testSQL(res);
- res=PQexecPrepared(conn, "execalias", argc+inf, value, length, binary, 0);
- clog<<"PQexecPrepared done argc+inf="<<argc+inf<<endl;
+ res=PQexecPrepared(conn, "execalias", argc, value, length, binary, 0);
+ clog<<"PQexecPrepared done argc="<<argc<<endl;
testSQL(res);
print();
exec("DEALLOCATE execalias");